summaryrefslogtreecommitdiff
path: root/src/journal-remote/journal-remote-main.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-15 19:47:41 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-17 21:08:50 +0100
commit9c7f2201731fe04cc41aa067c8be21d35b803bce (patch)
tree37062ed9b0440e546fbf5f3407b80d89b1bb5f49 /src/journal-remote/journal-remote-main.c
parentc3470872c6c12d64c895643bd3b02022beb0589e (diff)
downloadsystemd-9c7f2201731fe04cc41aa067c8be21d35b803bce.tar.gz
journal-remote: convert to parse_boolean_argument() and fix type confusion
We were passing a reference to 'int arg_seal' to config_parse_bool(), which expects a 'bool *'. Luckily, this would work, because 'bool' is smaller than 'int', so config_parse_bool() would set the least-significant byte of arg_seal. At least I think so. But let's use consistent types ;) Also, modernize style a bit and don't use integers in boolean context.
Diffstat (limited to 'src/journal-remote/journal-remote-main.c')
-rw-r--r--src/journal-remote/journal-remote-main.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index b9e793c08c..355a258be1 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -14,6 +14,7 @@
#include "journal-remote.h"
#include "main-func.h"
#include "memory-util.h"
+#include "parse-argument.h"
#include "pretty-print.h"
#include "process-util.h"
#include "rlimit-util.h"
@@ -34,8 +35,8 @@ static const char* arg_listen_raw = NULL;
static const char* arg_listen_http = NULL;
static const char* arg_listen_https = NULL;
static char** arg_files = NULL; /* Do not free this. */
-static int arg_compress = true;
-static int arg_seal = false;
+static bool arg_compress = true;
+static bool arg_seal = false;
static int http_socket = -1, https_socket = -1;
static char** arg_gnutls_log = NULL;
@@ -965,28 +966,15 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_COMPRESS:
- if (optarg) {
- r = parse_boolean(optarg);
- if (r < 0)
- return log_error_errno(r, "Failed to parse --compress= parameter.");
-
- arg_compress = !!r;
- } else
- arg_compress = true;
-
+ r = parse_boolean_argument("--compress", optarg, &arg_compress);
+ if (r < 0)
+ return r;
break;
case ARG_SEAL:
- if (optarg) {
- r = parse_boolean(optarg);
- if (r < 0)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Failed to parse --seal= parameter.");
-
- arg_seal = !!r;
- } else
- arg_seal = true;
-
+ r = parse_boolean_argument("--seal", optarg, &arg_seal);
+ if (r < 0)
+ return r;
break;
case ARG_GNUTLS_LOG: {