Author: hailfinger
Date: Wed Jan 11 03:10:11 2012
New Revision: 1484
URL: http://flashrom.org/trac/flashrom/changeset/1484

Log:
Postpone layout file reading

Layout file reading should happen after option parsing like all other
file accesses.
Guard against multiple --layout parameters.

Followup fix for r1483: Remove -m short option from getopt.

Signed-off-by: Carl-Daniel Hailfinger <[email protected]>
Acked-by: Stefan Tauner <[email protected]>

Modified:
   trunk/cli_classic.c

Modified: trunk/cli_classic.c
==============================================================================
--- trunk/cli_classic.c Wed Jan  4 01:48:27 2012        (r1483)
+++ trunk/cli_classic.c Wed Jan 11 03:10:11 2012        (r1484)
@@ -177,7 +177,7 @@
        enum programmer prog = PROGRAMMER_INVALID;
        int ret = 0;
 
-       static const char optstring[] = "r:Rw:v:nVEfc:m:l:i:p:Lzh";
+       static const char optstring[] = "r:Rw:v:nVEfc:l:i:p:Lzh";
        static const struct option long_options[] = {
                {"read",                1, NULL, 'r'},
                {"write",               1, NULL, 'w'},
@@ -198,6 +198,7 @@
        };
 
        char *filename = NULL;
+       char *layoutfile = NULL;
        char *tempstr = NULL;
        char *pparam = NULL;
 
@@ -273,9 +274,12 @@
                        force = 1;
                        break;
                case 'l':
-                       tempstr = strdup(optarg);
-                       if (read_romlayout(tempstr))
+                       if (layoutfile) {
+                               fprintf(stderr, "Error: --layout specified "
+                                       "more than once. Aborting.\n");
                                cli_classic_abort_usage();
+                       }
+                       layoutfile = strdup(optarg);
                        break;
                case 'i':
                        tempstr = strdup(optarg);
@@ -373,9 +377,6 @@
                cli_classic_abort_usage();
        }
 
-       if (process_include_args())
-               cli_classic_abort_usage();
-
        /* FIXME: Print the actions flashrom will take. */
 
        if (list_supported) {
@@ -390,6 +391,11 @@
        }
 #endif
 
+       if (layoutfile && read_romlayout(layoutfile))
+               cli_classic_abort_usage();
+       if (process_include_args())
+               cli_classic_abort_usage();
+
        /* Does a chip with the requested name exist in the flashchips array? */
        if (chip_to_probe) {
                for (flash = flashchips; flash && flash->name; flash++)

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to