summaryrefslogtreecommitdiff
path: root/src/cam/main.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-03-23 06:05:46 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-03-27 18:26:15 +0200
commitf8386836dfda04c626e63ba9d64c1a4f63867dfa (patch)
tree087c476c791cca82602f19fec0d372ba1e7abbbf /src/cam/main.cpp
parent3f906920e4d448441c442be1ce6c7376e33d4237 (diff)
cam: Separate options valid() and empty()
An empty option list is not necessarily an error. Add a new empty() function to test the option list for emptiness, and modify the valid() function to only notify parsing errors. As a side effect this allows accessing partially parsed options, which may be useful in the future. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/cam/main.cpp')
-rw-r--r--src/cam/main.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 1ca7862b..e7490c32 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -67,9 +67,12 @@ static int parseOptions(int argc, char *argv[])
parser.addOption(OptList, OptionNone, "List all cameras", "list");
options = parser.parse(argc, argv);
- if (!options.valid() || options.isSet(OptHelp)) {
+ if (!options.valid())
+ return -EINVAL;
+
+ if (options.empty() || options.isSet(OptHelp)) {
parser.usage();
- return !options.valid() ? -EINVAL : -EINTR;
+ return options.empty() ? -EINVAL : -EINTR;
}
return 0;