docproc: add variables for subcommand and filename
authorJani Nikula <jani.nikula@intel.com>
Thu, 12 May 2016 13:15:39 +0000 (16:15 +0300)
committerJonathan Corbet <corbet@lwn.net>
Sat, 14 May 2016 15:56:37 +0000 (09:56 -0600)
Improves clarity. No functional changes.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
scripts/docproc.c

index e267e621431a6b83768ac5efa5d37eba6fb2f55c..48abc01a920e0cc002b4910852036a4acae5eff8 100644 (file)
@@ -500,6 +500,7 @@ static void parse_file(FILE *infile)
 
 int main(int argc, char *argv[])
 {
+       const char *subcommand, *filename;
        FILE * infile;
        int i;
 
@@ -513,15 +514,19 @@ int main(int argc, char *argv[])
                usage();
                exit(1);
        }
+
+       subcommand = argv[1];
+       filename = argv[2];
+
        /* Open file, exit on error */
-       infile = fopen(argv[2], "r");
+       infile = fopen(filename, "r");
        if (infile == NULL) {
                fprintf(stderr, "docproc: ");
-               perror(argv[2]);
+               perror(filename);
                exit(2);
        }
 
-       if (strcmp("doc", argv[1]) == 0) {
+       if (strcmp("doc", subcommand) == 0) {
                /* Need to do this in two passes.
                 * First pass is used to collect all symbols exported
                 * in the various files;
@@ -557,10 +562,10 @@ int main(int argc, char *argv[])
                        fprintf(stderr, "Warning: didn't use docs for %s\n",
                                all_list[i]);
                }
-       } else if (strcmp("depend", argv[1]) == 0) {
+       } else if (strcmp("depend", subcommand) == 0) {
                /* Create first part of dependency chain
                 * file.tmpl */
-               printf("%s\t", argv[2]);
+               printf("%s\t", filename);
                defaultline       = noaction;
                internalfunctions = adddep;
                externalfunctions = adddep;
@@ -571,7 +576,7 @@ int main(int argc, char *argv[])
                parse_file(infile);
                printf("\n");
        } else {
-               fprintf(stderr, "Unknown option: %s\n", argv[1]);
+               fprintf(stderr, "Unknown option: %s\n", subcommand);
                exit(1);
        }
        fclose(infile);