]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
util: inline argconfig_parse_byte()
authorCaleb Sander Mateos <csander@purestorage.com>
Tue, 16 Jul 2024 16:10:48 +0000 (10:10 -0600)
committerDaniel Wagner <wagi@monom.org>
Wed, 17 Jul 2024 14:57:45 +0000 (16:57 +0200)
argconfig_parse_byte() is only used in argconfig_parse_type().
For consistency with the other cases, inline it into the function.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
util/argconfig.c
util/argconfig.h

index 8a4d0aa98979d56fa260f7132f050de32420cd3d..87487eae7156ca1fcc9e8904da3954f2d5465cbe 100644 (file)
@@ -142,19 +142,6 @@ static int argconfig_error(char *type, const char *opt, const char *arg)
        return -EINVAL;
 }
 
-int argconfig_parse_byte(const char *opt, const char *str, unsigned char *val)
-{
-       char *endptr;
-       unsigned long tmp = strtoul(str, &endptr, 0);
-
-       if (errno || tmp >= 1 << 8 || str == endptr)
-               return argconfig_error("byte", opt, str);
-
-       *val = tmp;
-
-       return 0;
-}
-
 static int argconfig_parse_type(struct argconfig_commandline_options *s, struct option *option,
                                int index)
 {
@@ -173,9 +160,15 @@ static int argconfig_parse_type(struct argconfig_commandline_options *s, struct
                if (errno || optarg == endptr)
                        ret = argconfig_error("integer", option[index].name, optarg);
                break;
-       case CFG_BYTE:
-               ret = argconfig_parse_byte(option[index].name, optarg, (uint8_t *)value);
+       case CFG_BYTE: {
+               unsigned long tmp = strtoul(optarg, &endptr, 0);
+
+               if (errno || tmp >= 1 << 8 || optarg == endptr)
+                       ret = argconfig_error("byte", option[index].name, optarg);
+               else
+                       *((uint8_t *)value) = tmp;
                break;
+       }
        case CFG_SHORT: {
                unsigned long tmp = strtoul(optarg, &endptr, 0);
 
index 17ff5fa10b39590632346bd8997634405f51b4af..3dff25a3273713a26e07edb2bfd15b3314bffadc 100644 (file)
@@ -180,7 +180,6 @@ int argconfig_parse_comma_sep_array_u32(char *string, __u32 *val,
                                        unsigned int max_length);
 int argconfig_parse_comma_sep_array_u64(char *string, __u64 *val,
                                        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);
 bool argconfig_parse_seen(struct argconfig_commandline_options *options,