summaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2012-04-15 14:09:16 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2012-04-15 14:09:16 +0000
commite99a2bb5e9bf62a595cad715b12d0493dd96bbe0 (patch)
tree0cf2b8a88c5f8bdc12f8bb54e3df043344e84066 /layout.c
parentaf88565364b8c8a7a08aaff81fa8f76501b266ee (diff)
downloadflashrom-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.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/layout.c b/layout.c
index 90d3cce..379ee8c 100644
--- a/layout.c
+++ b/layout.c
@@ -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;
}
OpenPOWER on IntegriCloud