summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-01-25 22:25:30 -0800
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-01-29 18:34:51 +0000
commita55c72594c50e7372d6cad815e5ebba0d0f4817f (patch)
tree9c27ec147210e0c370fd61be583f6c541d3ba451
parent36a318c56cc4e0faac19ed89afeff15a105b8a58 (diff)
downloadphosphor-watchdog-a55c72594c50e7372d6cad815e5ebba0d0f4817f.tar.gz
phosphor-watchdog-a55c72594c50e7372d6cad815e5ebba0d0f4817f.zip
argument: Fix use of optarg
getopt supports no_argument, required_argument, and optional_argument types of arguments. Getopt returns NULL in optarg if no argument was given in the case of no_argument or optional_argument types. Use this value to determine if we should use optarg or trueString. Change-Id: I414c4d3c2923844cff13a070357269c5b48048c9 Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--argument.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/argument.cpp b/argument.cpp
index 11d9814..8931969 100644
--- a/argument.cpp
+++ b/argument.cpp
@@ -65,7 +65,7 @@ ArgumentParser::ArgumentParser(int argc, char** argv)
if (i->val)
{
- arguments[i->name] = (i->has_arg ? optarg : trueString);
+ arguments[i->name] = (optarg ? optarg : trueString);
}
}
}
OpenPOWER on IntegriCloud