Abort on unused programmer parameters
An unused programmer parameter is a sign that the user wanted to either
do something not supported by the programmer or misspelled a parameter
which may be essential for the given programmer.
Aborting is the only safe choice. If the programmer parameter is unused
because of an error during programmer init, aborting would have happened
anyway due to that error.
Corresponding to flashrom svn r1708.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
diff --git a/flashrom.c b/flashrom.c
index 41e7bd8..86e64a2 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -392,13 +392,23 @@
programmer_may_write = 1;
programmer_param = param;
- msg_pdbg("Initializing %s programmer\n",
- programmer_table[programmer].name);
+ msg_pdbg("Initializing %s programmer\n", programmer_table[programmer].name);
ret = programmer_table[programmer].init();
if (programmer_param && strlen(programmer_param)) {
- msg_perr("Unhandled programmer parameters: %s\n",
- programmer_param);
- /* Do not error out here, the init itself was successful. */
+ if (ret != 0) {
+ /* It is quite possible that any unhandled programmer parameter would have been valid,
+ * but an error in actual programmer init happened before the parameter was evaluated.
+ */
+ msg_pwarn("Unhandled programmer parameters (possibly due to another failure): %s\n",
+ programmer_param);
+ } else {
+ /* Actual programmer init was successful, but the user specified an invalid or unusable
+ * (for the current programmer configuration) parameter.
+ */
+ msg_perr("Unhandled programmer parameters: %s\n", programmer_param);
+ msg_perr("Aborting.\n");
+ ret = ERROR_FATAL;
+ }
}
return ret;
}