diff options
author | Eric Engestrom <eric@engestrom.ch> | 2017-05-24 21:23:15 +0100 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2017-12-04 19:37:33 +0000 |
commit | 0c30fa5503d8d3508704c513a0ce3c24f764e103 (patch) | |
tree | 27d85668f9ff8cd1323278962654a69f7e7403e7 | |
parent | 58e056ab2d715113a8893ec16ed5c93ca72c68bd (diff) |
option-parser: replace int/0/1 with bool/false/true
These are already used as bools by all callers, let's make that official.
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Daniel Stone <daniels@collabora.com>
-rw-r--r-- | shared/option-parser.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/shared/option-parser.c b/shared/option-parser.c index e8d9b3b7..0f93464c 100644 --- a/shared/option-parser.c +++ b/shared/option-parser.c @@ -25,6 +25,7 @@ #include "config.h" +#include <stdbool.h> #include <stdlib.h> #include <stdint.h> #include <stdio.h> @@ -35,7 +36,7 @@ #include "config-parser.h" #include "string-helpers.h" -static int +static bool handle_option(const struct weston_option *option, char *value) { char* p; @@ -43,23 +44,23 @@ handle_option(const struct weston_option *option, char *value) switch (option->type) { case WESTON_OPTION_INTEGER: if (!safe_strtoint(value, option->data)) - return 0; - return 1; + return false; + return true; case WESTON_OPTION_UNSIGNED_INTEGER: errno = 0; * (uint32_t *) option->data = strtoul(value, &p, 10); if (errno != 0 || p == value || *p != '\0') - return 0; - return 1; + return false; + return true; case WESTON_OPTION_STRING: * (char **) option->data = strdup(value); - return 1; + return true; default: assert(0); } } -static int +static bool long_option(const struct weston_option *options, int count, char *arg) { int k, len; @@ -76,17 +77,17 @@ long_option(const struct weston_option *options, int count, char *arg) if (!arg[len + 2]) { * (int32_t *) options[k].data = 1; - return 1; + return true; } } else if (arg[len+2] == '=') { return handle_option(options + k, arg + len + 3); } } - return 0; + return false; } -static int +static bool long_option_with_arg(const struct weston_option *options, int count, char *arg, char *param) { @@ -108,16 +109,16 @@ long_option_with_arg(const struct weston_option *options, int count, char *arg, return handle_option(options + k, param); } - return 0; + return false; } -static int +static bool short_option(const struct weston_option *options, int count, char *arg) { int k; if (!arg[1]) - return 0; + return false; for (k = 0; k < count; k++) { if (options[k].short_name != arg[1]) @@ -127,25 +128,25 @@ short_option(const struct weston_option *options, int count, char *arg) if (!arg[2]) { * (int32_t *) options[k].data = 1; - return 1; + return true; } } else if (arg[2]) { return handle_option(options + k, arg + 2); } else { - return 0; + return false; } } - return 0; + return false; } -static int +static bool short_option_with_arg(const struct weston_option *options, int count, char *arg, char *param) { int k; if (!arg[1]) - return 0; + return false; for (k = 0; k < count; k++) { if (options[k].short_name != arg[1]) @@ -157,7 +158,7 @@ short_option_with_arg(const struct weston_option *options, int count, char *arg, return handle_option(options + k, param); } - return 0; + return false; } int |