aboutsummaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2022-09-14 16:45:10 +0200
committerAngel Pons <th3fanbus@gmail.com>2022-09-18 21:40:56 +0000
commit813c68ad9cf2bc61b9923b3eab429ed318359281 (patch)
treefa23f1d8b10280f35fbb90ae04c74b81313cf78e /flashrom.c
parentca61c3dd3efcdf1aa5c7ea055514b0985e5fff48 (diff)
downloadflashrom-813c68ad9cf2bc61b9923b3eab429ed318359281.tar.gz
flashrom-813c68ad9cf2bc61b9923b3eab429ed318359281.tar.bz2
flashrom-813c68ad9cf2bc61b9923b3eab429ed318359281.zip
flashrom.c: Drop `programmer_param` global variable
The `programmer_param` global variable is only valid within the scope of the `programmer_init()` function, which calls a programmer-specific init function that calls `extract_programmer_param_str()` to obtain the value of programmer-specific parameters. Get rid of this global variable by piping the "programmer_param" string through a function parameter specifically added for this purpose in the past, but was not used yet. Change-Id: I59397451ea625bd431b15848bad5ec7cb926f22d Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/67649 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/flashrom.c b/flashrom.c
index f8c5e730..26045943 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -38,7 +38,6 @@ const char flashrom_version[] = FLASHROM_VERSION;
const char *chip_to_probe = NULL;
static const struct programmer_entry *programmer = NULL;
-static char *programmer_param = NULL;
/*
* Programmers supporting multiple buses can have differing size limits on
@@ -150,36 +149,37 @@ int programmer_init(const struct programmer_entry *prog, const char *param)
/* Default to allowing writes. Broken programmers set this to 0. */
programmer_may_write = true;
+ struct programmer_cfg cfg;
+
if (param) {
- programmer_param = strdup(param);
- if (!programmer_param) {
+ cfg.params = strdup(param);
+ if (!cfg.params) {
msg_perr("Out of memory!\n");
return ERROR_FATAL;
}
} else {
- programmer_param = NULL;
+ cfg.params = NULL;
}
msg_pdbg("Initializing %s programmer\n", programmer->name);
- ret = programmer->init(NULL);
- if (programmer_param && strlen(programmer_param)) {
+ ret = programmer->init(&cfg);
+ if (cfg.params && strlen(cfg.params)) {
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);
+ cfg.params);
} 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("Unhandled programmer parameters: %s\n", cfg.params);
msg_perr("Aborting.\n");
ret = ERROR_FATAL;
}
}
- free(programmer_param);
- programmer_param = NULL;
+ free(cfg.params);
return ret;
}
@@ -294,7 +294,7 @@ static char *extract_param(char *const *haystack, const char *needle, const char
char *extract_programmer_param_str(const struct programmer_cfg *cfg, const char *param_name)
{
- return extract_param(&programmer_param, param_name, ",");
+ return extract_param(&cfg->params, param_name, ",");
}
static int check_block_eraser(const struct flashctx *flash, int k, int log)