diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2013-08-13 07:09:57 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2013-08-13 07:09:57 +0000 |
commit | 20a36baf56afac4896c8abe5a94dbe974a25dbc9 (patch) | |
tree | 3dcc5846a0fee64271b2395f10385c86bc50d76c | |
parent | c4f44df55fbe624e283ce3db83e1dea6925fd5da (diff) | |
download | flashrom-20a36baf56afac4896c8abe5a94dbe974a25dbc9.tar.gz flashrom-20a36baf56afac4896c8abe5a94dbe974a25dbc9.tar.bz2 flashrom-20a36baf56afac4896c8abe5a94dbe974a25dbc9.zip |
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>
-rw-r--r-- | flashrom.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/flashrom.c b/flashrom.c index 41e7bd826..86e64a28e 100644 --- a/flashrom.c +++ b/flashrom.c @@ -392,13 +392,23 @@ int programmer_init(enum programmer prog, const char *param) 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; } |