From c38fd2be9be33c92f26f200276625dcf9957e7ac Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Thu, 19 Jan 2017 05:13:30 -0500 Subject: [PATCH] Convert logical booleans in client_config_t to bool type. --- src/cfg.rl | 14 +++++++------- src/ndhc.c | 2 +- src/ndhc.h | 10 +++++----- src/rfkill.c | 4 ++-- src/rfkill.h | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cfg.rl b/src/cfg.rl index e5833ae..524f2ee 100644 --- a/src/cfg.rl +++ b/src/cfg.rl @@ -50,11 +50,11 @@ struct cfgparse { action background { switch (ccfg.ternary) { case 1: - client_config.background_if_no_lease = 1; + client_config.background_if_no_lease = true; gflags_detach = 1; break; case -1: - client_config.background_if_no_lease = 0; + client_config.background_if_no_lease = false; gflags_detach = 0; default: break; @@ -74,14 +74,14 @@ struct cfgparse { } action now { switch (ccfg.ternary) { - case 1: client_config.abort_if_no_lease = 1; break; - case -1: client_config.abort_if_no_lease = 0; default: break; + case 1: client_config.abort_if_no_lease = true; break; + case -1: client_config.abort_if_no_lease = false; default: break; } } action quit { switch (ccfg.ternary) { - case 1: client_config.quit_after_lease = 1; break; - case -1: client_config.quit_after_lease = 0; default: break; + case 1: client_config.quit_after_lease = true; break; + case -1: client_config.quit_after_lease = false; default: break; } } action request { set_client_addr(ccfg.buf); } @@ -171,7 +171,7 @@ struct cfgparse { action rfkill_idx { uint32_t t = atoi(ccfg.buf); client_config.rfkillIdx = t; - client_config.enable_rfkill = 1; + client_config.enable_rfkill = true; } action version { print_version(); exit(EXIT_SUCCESS); } action help { show_usage(); exit(EXIT_SUCCESS); } diff --git a/src/ndhc.c b/src/ndhc.c index 6e251aa..dd8e425 100644 --- a/src/ndhc.c +++ b/src/ndhc.c @@ -92,7 +92,7 @@ struct client_config_t client_config = { .arp = "\0\0\0\0\0\0", .clientid_len = 0, .metric = 0, - .foreground = 1, + .foreground = true, }; void set_client_addr(const char v[static 1]) { cs.clientAddr = inet_addr(v); } diff --git a/src/ndhc.h b/src/ndhc.h index 2ce2260..9786431 100644 --- a/src/ndhc.h +++ b/src/ndhc.h @@ -50,11 +50,11 @@ struct client_state_t { }; struct client_config_t { - char foreground; // Do not fork - char quit_after_lease; // Quit after obtaining lease - char abort_if_no_lease; // Abort if no lease - char background_if_no_lease; // Fork to background if no lease - char enable_rfkill; // Listen for rfkill events + bool foreground; // Do not fork + bool quit_after_lease; // Quit after obtaining lease + bool abort_if_no_lease; // Abort if no lease + bool background_if_no_lease; // Fork to background if no lease + bool enable_rfkill; // Listen for rfkill events char interface[IFNAMSIZ]; // The name of the interface to use char clientid[64]; // Optional client id to use uint8_t clientid_len; // Length of the clientid diff --git a/src/rfkill.c b/src/rfkill.c index 421fec2..ba4fed8 100644 --- a/src/rfkill.c +++ b/src/rfkill.c @@ -37,13 +37,13 @@ #include "ndhc.h" #include "rfkill.h" -int rfkill_open(char enable_rfkill[static 1]) +int rfkill_open(bool enable_rfkill[static 1]) { if (!*enable_rfkill) return -1; int r = open("/dev/rfkill", O_RDONLY|O_CLOEXEC|O_NONBLOCK); if (r < 0) { - *enable_rfkill = 0; + *enable_rfkill = false; log_line("rfkill disabled: could not open /dev/rfkill: %s", strerror(errno)); } diff --git a/src/rfkill.h b/src/rfkill.h index e322234..b66adf6 100644 --- a/src/rfkill.h +++ b/src/rfkill.h @@ -35,7 +35,7 @@ enum { RFK_DISABLED, }; -int rfkill_open(char enable_rfkill[static 1]); +int rfkill_open(bool enable_rfkill[static 1]); int rfkill_get(struct client_state_t cs[static 1], int check_idx, uint32_t rfkidx);