diff mbox series

[2/4] server_hawkbit: do not raise error in case of unrecognized option

Message ID 20200208134705.6547-2-sbabic@denx.de
State Accepted
Headers show
Series [1/4] server_general: do not raise error in case of unrecognized option | expand

Commit Message

Stefano Babic Feb. 8, 2020, 1:47 p.m. UTC
This allows to have a two-stage parsing of the command line parameters
with general parameters parsed by the suricatta module. Each stage
cannot raise an error because it is not responsible for all parameters,
but just for a part of them.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 suricatta/server_hawkbit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c
index 55aa419..65edb8e 100644
--- a/suricatta/server_hawkbit.c
+++ b/suricatta/server_hawkbit.c
@@ -1519,6 +1519,7 @@  server_op_res_t server_start(char *fname, int argc, char *argv[])
 
 	/* reset to optind=1 to parse suricatta's argument vector */
 	optind = 1;
+	opterr = 0;
 	while ((choice = getopt_long(argc, argv, "t:i:c:u:p:xr:y::w:k:g:",
 				     long_options, NULL)) != -1) {
 		switch (choice) {
@@ -1595,9 +1596,9 @@  server_op_res_t server_start(char *fname, int argc, char *argv[])
 			channel_data_defaults.retry_sleep =
 			    (unsigned int)strtoul(optarg, NULL, 10);
 			break;
+		/* Ignore not recognized options, they can be already parsed by the caller */
 		case '?':
-		default:
-			return SERVER_EINIT;
+			break;
 		}
 	}