logger: Fix -h option handling 39/148039/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 6 Sep 2017 10:31:28 +0000 (12:31 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 6 Sep 2017 10:31:28 +0000 (12:31 +0200)
Commit a7f94864f ("[4.0] logger: Major initialization refactor") broken
-h option handling.

This commit restores original behaviour - -h makes server exit after
printing help screen.

Change-Id: If5084bece8eb4e2a182ffaaf7d09a2073576d5eb

src/logger/logger.c

index 08e38bf..eb1a98f 100644 (file)
@@ -2256,9 +2256,12 @@ int main(int argc, char** argv)
        signal(SIGPIPE, SIG_IGN);
 
        struct logger_config_data data;
-       if ((r = prepare_config_data(&data, argc, argv)) < 0) {
-               printf("Unable to prepare config (%s). Exiting.\n", strerror(-r));
-               return DLOG_EXIT_ERR_CONFIG;
+       if ((r = prepare_config_data(&data, argc, argv)) != 0) {
+               if (r < 0) {
+                       printf("Unable to prepare config (%s). Exiting.\n", strerror(-r));
+                       return DLOG_EXIT_ERR_CONFIG;
+               } else
+                       return DLOG_EXIT_SUCCESS;  // handle -h option
        }
 
        struct logger server;