summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-26 17:47:13 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-26 19:25:17 +0300
commit5d987629d9df6f9eeb76079a99810d57c820219e (patch)
tree4efb16c123e8aacf1724a1002416f42ab0f98fb5 /src
parentd98ab6f2ae54ed5c97f64479de506bb7ab2e64a5 (diff)
cam: options: Don't initialise variable-length arrays
According to clang, variable-length arrays can't be initialised. Don't do so, and explicitly set the last element to 0 instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/cam/options.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cam/options.cpp b/src/cam/options.cpp
index 172d40f7..b80d361e 100644
--- a/src/cam/options.cpp
+++ b/src/cam/options.cpp
@@ -382,8 +382,8 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
* Allocate short and long options arrays large enough to contain all
* options.
*/
- char shortOptions[options_.size() * 3 + 2] = {};
- struct option longOptions[options_.size() + 1] = {};
+ char shortOptions[options_.size() * 3 + 2];
+ struct option longOptions[options_.size() + 1];
unsigned int ids = 0;
unsigned int idl = 0;
@@ -419,6 +419,9 @@ OptionsParser::Options OptionsParser::parse(int argc, char **argv)
}
}
+ shortOptions[ids] = '\0';
+ memset(&longOptions[idl], 0, sizeof(longOptions[idl]));
+
opterr = 0;
while (true) {