[libcamera-devel] [PATCH v2 4/4] cam: Improve when usage information is printed
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Feb 25 20:42:01 CET 2019
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 at ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart at 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();
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list