Message ID | 20190224171407.7856-5-niklas.soderlund@ragnatech.se |
---|---|
State | Accepted |
Commit | 374c102073bf8712dc5433f778ca39f85bb97f9c |
Headers | show |
Series |
|
Related | show |
Hi Niklas, Thank you for the patch. On Sun, Feb 24, 2019 at 06:14:07PM +0100, Niklas Söderlund wrote: > Running the cam tool without any options results in the tool to exit > with EXIT_FAILURE but no usage being printed, this is confusing. Improve > this by also printing the usage text. > > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/cam/main.cpp | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/src/cam/main.cpp b/src/cam/main.cpp > index 522d2f0d3373dc25..90859fe04abfb944 100644 > --- a/src/cam/main.cpp > +++ b/src/cam/main.cpp > @@ -67,12 +67,9 @@ static int parseOptions(int argc, char *argv[]) > parser.addOption(OptList, OptionNone, "List all cameras", "list"); > > options = parser.parse(argc, argv); > - if (!options.valid()) > - return -EINVAL; > - > - if (argc == 1 || options.isSet(OptHelp)) { > + if (!options.valid() || options.isSet(OptHelp)) { > parser.usage(); > - return 1; > + return !options.valid() ? -EINVAL : -EINTR; > } > > return 0; > @@ -207,7 +204,7 @@ int main(int argc, char **argv) > > ret = parseOptions(argc, argv); > if (ret < 0) > - return EXIT_FAILURE; > + return ret == -EINTR ? 0 : EXIT_FAILURE; > > CameraManager *cm = CameraManager::instance(); >
diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 522d2f0d3373dc25..90859fe04abfb944 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -67,12 +67,9 @@ static int parseOptions(int argc, char *argv[]) parser.addOption(OptList, OptionNone, "List all cameras", "list"); options = parser.parse(argc, argv); - if (!options.valid()) - return -EINVAL; - - if (argc == 1 || options.isSet(OptHelp)) { + if (!options.valid() || options.isSet(OptHelp)) { parser.usage(); - return 1; + return !options.valid() ? -EINVAL : -EINTR; } return 0; @@ -207,7 +204,7 @@ int main(int argc, char **argv) ret = parseOptions(argc, argv); if (ret < 0) - return EXIT_FAILURE; + return ret == -EINTR ? 0 : EXIT_FAILURE; CameraManager *cm = CameraManager::instance();
Running the cam tool without any options results in the tool to exit with EXIT_FAILURE but no usage being printed, this is confusing. Improve this by also printing the usage text. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- src/cam/main.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)