]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
util: Fix argconfig.c linux kernel check patch error and warnings
authorTokunori Ikegami <ikegami.t@gmail.com>
Sun, 28 May 2023 12:47:06 +0000 (21:47 +0900)
committerDaniel Wagner <wagi@monom.org>
Thu, 1 Jun 2023 17:45:53 +0000 (19:45 +0200)
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
util/argconfig.c
util/argconfig.h

index 64835ac9fd5f51fa2574164bbd818354ad11a035..f101527ef73d60153f9b22d5cda635d2144e081f 100644 (file)
@@ -185,6 +185,7 @@ static int argconfig_parse_type(struct argconfig_commandline_options *s, struct
                break;
        case CFG_BOOL: {
                int tmp = strtol(optarg, &endptr, 0);
+
                if (errno || tmp < 0 || tmp > 1 || optarg == endptr)
                        ret = argconfig_error("0 or 1", option[index].name, optarg);
                else
@@ -196,6 +197,7 @@ static int argconfig_parse_type(struct argconfig_commandline_options *s, struct
                break;
        case CFG_SHORT: {
                unsigned long tmp = strtoul(optarg, &endptr, 0);
+
                if (errno || tmp >= 1 << 16 || optarg == endptr)
                        ret = argconfig_error("short", option[index].name, optarg);
                else
@@ -204,6 +206,7 @@ static int argconfig_parse_type(struct argconfig_commandline_options *s, struct
        }
        case CFG_POSITIVE: {
                uint32_t tmp = strtoul(optarg, &endptr, 0);
+
                if (errno || optarg == endptr)
                        ret = argconfig_error("word", option[index].name, optarg);
                else
@@ -318,7 +321,7 @@ static int argconfig_parse_val(struct argconfig_commandline_options *s, struct o
 
 bool argconfig_output_format_json(bool set)
 {
-       static bool output_format_json = false;
+       static bool output_format_json;
 
        if (set)
                output_format_json = true;
@@ -428,8 +431,7 @@ out:
        return ret;
 }
 
-int argconfig_parse_comma_sep_array(char *string, int *val,
-                                        unsigned max_length)
+int argconfig_parse_comma_sep_array(char *string, int *val, unsigned int max_length)
 {
        int ret = 0;
        unsigned long v;
@@ -475,7 +477,7 @@ int argconfig_parse_comma_sep_array(char *string, int *val,
 }
 
 int argconfig_parse_comma_sep_array_short(char *string, unsigned short *val,
-                                         unsigned max_length)
+                                         unsigned int max_length)
 {
        int ret = 0;
        unsigned long v;
@@ -519,9 +521,8 @@ int argconfig_parse_comma_sep_array_short(char *string, unsigned short *val,
        }
 }
 
-int argconfig_parse_comma_sep_array_long(char *string,
-                                             unsigned long long *val,
-                                             unsigned max_length)
+int argconfig_parse_comma_sep_array_long(char *string, unsigned long long *val,
+                                        unsigned int max_length)
 {
        int ret = 0;
        char *tmp;
index 0fc631c05fa91f8e57288086e769860f433968eb..eaf8375abbfaba0ffcf47815d355998070c5c93f 100644 (file)
@@ -169,13 +169,11 @@ void argconfig_print_help(const char *program_desc,
                          struct argconfig_commandline_options *options);
 int argconfig_parse(int argc, char *argv[], const char *program_desc,
                    struct argconfig_commandline_options *options);
-int argconfig_parse_comma_sep_array(char *string, int *ret,
-                                        unsigned max_length);
+int argconfig_parse_comma_sep_array(char *string, int *ret, unsigned int max_length);
 int argconfig_parse_comma_sep_array_short(char *string, unsigned short *ret,
-                                         unsigned max_length);
-int argconfig_parse_comma_sep_array_long(char *string,
-                                             unsigned long long *ret,
-                                             unsigned max_length);
+                                         unsigned int max_length);
+int argconfig_parse_comma_sep_array_long(char *string, unsigned long long *ret,
+                                        unsigned int max_length);
 int argconfig_parse_byte(const char *opt, const char *str, unsigned char *val);
 
 void print_word_wrapped(const char *s, int indent, int start, FILE *stream);