diff options
author | hailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2012-01-11 02:10:11 +0000 |
---|---|---|
committer | hailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2012-01-11 02:10:11 +0000 |
commit | 9ab4530430272db21cad93af8080809e0cdabb5e (patch) | |
tree | 8d36cfbbef0787c3884ab3265ff63ebd213a542d /cli_classic.c | |
parent | 234fb84eb42ed6718a23b99e822ea3d726e8b995 (diff) | |
download | flashrom-9ab4530430272db21cad93af8080809e0cdabb5e.tar.gz |
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 <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1484 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'cli_classic.c')
-rw-r--r-- | cli_classic.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/cli_classic.c b/cli_classic.c index 7ce74e5..7661612 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -177,7 +177,7 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) }; char *filename = NULL; + char *layoutfile = NULL; char *tempstr = NULL; char *pparam = NULL; @@ -273,9 +274,12 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) } #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++) |