]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: fix sparse warnings for declaration
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Sun, 19 Aug 2018 16:57:31 +0000 (12:57 -0400)
committerKeith Busch <keith.busch@intel.com>
Mon, 20 Aug 2018 18:40:50 +0000 (12:40 -0600)
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
argconfig.c

index 3fda34d7af4f1363f57927518c534041c6a9a390..2689cd32f5f91d8a79849cd23b40a9b5e69c9904 100644 (file)
@@ -304,6 +304,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                        char **opts = ((char **)value_addr);
                        int remaining_space = CFG_MAX_SUBOPTS;
                        int enddefault = 0;
+                       int r;
                        while (0 && *opts != NULL) {
                                if (*opts == END_DEFAULT)
                                        enddefault = 1;
@@ -317,9 +318,8 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                                opts += 2;
                        }
 
-                       int r =
-                           argconfig_parse_subopt_string(optarg, opts,
-                                                         remaining_space);
+                       r = argconfig_parse_subopt_string(optarg, opts,
+                                       remaining_space);
                        if (r == 2) {
                                fprintf(stderr,
                                        "Error Parsing Sub-Options: Too many options!\n");
@@ -335,6 +335,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                           s->config_type == CFG_FILE_RP ||
                           s->config_type == CFG_FILE_WP) {
                        const char *fopts = "";
+                       FILE *f;
                        if (s->config_type == CFG_FILE_A)
                                fopts = "a";
                        else if (s->config_type == CFG_FILE_R)
@@ -348,7 +349,7 @@ int argconfig_parse(int argc, char *argv[], const char *program_desc,
                        else if (s->config_type == CFG_FILE_WP)
                                fopts = "w+";
 
-                       FILE *f = fopen(optarg, fopts);
+                       f = fopen(optarg, fopts);
                        if (f == NULL) {
                                fprintf(stderr, "Unable to open %s file: %s\n",
                                        s->option, optarg);
@@ -372,6 +373,7 @@ int argconfig_parse_subopt_string(char *string, char **options,
 {
        char **o = options;
        char *tmp;
+       size_t toklen;
 
        if (!string || !strlen(string)) {
                *(o++) = NULL;
@@ -382,7 +384,6 @@ int argconfig_parse_subopt_string(char *string, char **options,
        tmp = calloc(strlen(string) + 2, 1);
        strcpy(tmp, string);
 
-       size_t toklen;
        toklen = strcspn(tmp, "=");
 
        if (!toklen) {