diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-04-15 14:09:16 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-04-15 14:09:16 +0000 |
commit | e99a2bb5e9bf62a595cad715b12d0493dd96bbe0 (patch) | |
tree | 0cf2b8a88c5f8bdc12f8bb54e3df043344e84066 /layout.c | |
parent | af88565364b8c8a7a08aaff81fa8f76501b266ee (diff) | |
download | flashrom-e99a2bb5e9bf62a595cad715b12d0493dd96bbe0.zip flashrom-e99a2bb5e9bf62a595cad715b12d0493dd96bbe0.tar.gz |
Check for duplicate -i arguments
And a tiny cleanup.
Corresponding to flashrom svn r1523.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'layout.c')
-rw-r--r-- | layout.c | 34 |
1 files changed, 25 insertions, 9 deletions
@@ -201,6 +201,17 @@ int read_romlayout(char *name) } #endif +/* returns the index of the entry (or a negative value if it is not found) */ +int find_include_arg(const char *const name) +{ + unsigned int i; + for (i = 0; i < num_include_args; i++) { + if (!strcmp(include_args[i], name)) + return i; + } + return -1; +} + /* register an include argument (-i) for later processing */ int register_include_arg(char *name) { @@ -214,6 +225,11 @@ int register_include_arg(char *name) return 1; } + if (find_include_arg(name) != -1) { + msg_gerr("Duplicate region name: \"%s\".\n", name); + return 1; + } + include_args[num_include_args] = name; num_include_args++; return 0; @@ -250,17 +266,17 @@ int process_include_args(void) if (num_include_args == 0) return 0; - for (i = 0; i < num_include_args; i++) { - /* User has specified an area, but no layout file is loaded. */ - if (!romimages) { - msg_gerr("Region requested (with -i \"%s\"), " - "but no layout data is available.\n", - include_args[i]); - return 1; - } + /* User has specified an area, but no layout file is loaded. */ + if (!romimages) { + msg_gerr("Region requested (with -i \"%s\"), " + "but no layout data is available.\n", + include_args[0]); + return 1; + } + for (i = 0; i < num_include_args; i++) { if (find_romentry(include_args[i]) < 0) { - msg_gerr("Invalid region specified: \"%s\"\n", + msg_gerr("Invalid region specified: \"%s\".\n", include_args[i]); return 1; } |