Author: stefanct Date: Sun Apr 15 16:09:16 2012 New Revision: 1523 URL: http://flashrom.org/trac/flashrom/changeset/1523
Log: Check for duplicate -i arguments.
And a tiny cleanup.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at Acked-by: Uwe Hermann uwe@hermann-uwe.de
Modified: trunk/layout.c
Modified: trunk/layout.c ============================================================================== --- trunk/layout.c Sun Apr 15 15:16:32 2012 (r1522) +++ trunk/layout.c Sun Apr 15 16:09:16 2012 (r1523) @@ -201,6 +201,17 @@ } #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 @@ 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 @@ 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; }