Layout file reading should happen after option parsing like all other file accesses. Guard against multiple --layout parameters.
Side note: This fixes an inconsistency which impacts the log file patch.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-postpone_layoutfile_reading/cli_classic.c =================================================================== --- flashrom-postpone_layoutfile_reading/cli_classic.c (Revision 1482) +++ flashrom-postpone_layoutfile_reading/cli_classic.c (Arbeitskopie) @@ -204,6 +204,7 @@ };
char *filename = NULL; + char *layoutfile = NULL; char *tempstr = NULL; char *pparam = NULL;
@@ -290,9 +291,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); @@ -390,9 +394,6 @@ cli_classic_abort_usage(); }
- if (process_include_args()) - cli_classic_abort_usage(); - /* FIXME: Print the actions flashrom will take. */
if (list_supported) { @@ -407,6 +408,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++)