[libcamera-devel] [PATCH 4/4] cam: Improve when usage information is printed
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Feb 20 15:37:36 CET 2019
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>
---
src/cam/main.cpp | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/cam/main.cpp b/src/cam/main.cpp
index 522d2f0d3373dc25..9f4c8e26751d982c 100644
--- a/src/cam/main.cpp
+++ b/src/cam/main.cpp
@@ -41,6 +41,8 @@ void signalHandler(int signal)
static int parseOptions(int argc, char *argv[])
{
+ int ret = 0;
+
KeyValueParser formatKeyValue;
formatKeyValue.addOption("width", OptionInteger, "Width in pixels",
ArgumentRequired);
@@ -67,15 +69,14 @@ 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;
+ ret = -EINVAL;
- if (argc == 1 || options.isSet(OptHelp)) {
+ if (ret || options.isSet(OptHelp))
parser.usage();
- return 1;
- }
- return 0;
+ return ret;
}
static bool configureStreams(Camera *camera, std::vector<Stream *> &streams)
--
2.20.1
More information about the libcamera-devel
mailing list