Attention is currently required from: Felix Singer, Thomas Heijligen, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk, Peter Marheine.
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67649 )
Change subject: flashrom.c: Drop `programmer_param` global variable
......................................................................
Patch Set 1: Code-Review+1
(2 comments)
Patchset:
PS1:
Not sure if anybody checked that there is no NULL pointer introduced
on any call path that leads to extract_programmer_param_str().
File flashrom.c:
https://review.coreboot.org/c/flashrom/+/67649/comment/8c02dca8_e9e8a9ea
PS1, Line 297: &
That this is a pointer inside a const struct and works made me realize
how odd the extract_param() signature is. We pass a pointer to a char
pointer that gets never changed, so we could as well pass the char pointer
directly.
--
To view, visit https://review.coreboot.org/c/flashrom/+/67649
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I59397451ea625bd431b15848bad5ec7cb926f22d
Gerrit-Change-Number: 67649
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Wed, 14 Sep 2022 14:12:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Jonathon Hall.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/3892469c_be8739a9
PS1, Line 9: commit 3b8b93e
> Thanks for the comments on CB:66659 shame not to have caught them in the week before 😞 […]
Hmmm, how do I explain it more clearly... Ah, just look at CB:67649 and its small size, together with CB:67094 they achieve the goal CB:66659 intended to do: no more `programmer_param` global variable. 😊
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Comment-Date: Wed, 14 Sep 2022 13:09:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Thomas Heijligen <src(a)posteo.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Comment-In-Reply-To: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-MessageType: comment
Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/67649 )
Change subject: flashrom.c: Drop `programmer_param` global variable
......................................................................
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(a)gmail.com>
---
M flashrom.c
1 file changed, 30 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/49/67649/1
diff --git a/flashrom.c b/flashrom.c
index f8c5e73..2604594 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -38,7 +38,6 @@
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 @@
/* 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 @@
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)
--
To view, visit https://review.coreboot.org/c/flashrom/+/67649
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I59397451ea625bd431b15848bad5ec7cb926f22d
Gerrit-Change-Number: 67649
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: newchange
Attention is currently required from: Jonathon Hall.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/7a7a3639_ea39621a
PS1, Line 9: commit 3b8b93e
> I commented on CB:66659 about the biggest problems I saw. […]
Thanks for the comments on CB:66659 shame not to have caught them in the week before 😞
Not sure what you mean that CB:67094 is a great starting point? It doesn't constraint `programmer_param` to `programmer_init()` it is still accessed in `extract_programmer_param_str()`. As you said one would only need to plumb but only because of all the prior work so why not just go all the way and have this commit fixed up rather than abandoned? CB:67094 is merely a half realised variant of this patch or CB:66659. The overall patch intent doesn't appear to be the issue just some very unfortunate teething issues that got missed in the switch over.
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Comment-Date: Wed, 14 Sep 2022 12:25:55 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Thomas Heijligen <src(a)posteo.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Comment-In-Reply-To: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-MessageType: comment
Attention is currently required from: Jonathon Hall.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67619 )
Change subject: flashrom.c: Don't crash when programmer parameter string is NULL
......................................................................
Patch Set 1:
(1 comment)
Commit Message:
https://review.coreboot.org/c/flashrom/+/67619/comment/48369127_ca7c8622
PS1, Line 9: commit 3b8b93e
> Jonathon, Thank you for preparing this patch. […]
I commented on CB:66659 about the biggest problems I saw. If you want to get rid of the `programmer_param` global variable, CB:67094 is a great starting point, as it constrains the `programmer_param` global variable to the scope of the `programmer_init()` function. One would only need to plumb the variable through several function calls.
--
To view, visit https://review.coreboot.org/c/flashrom/+/67619
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie13bdcf63c23d912dc9b774ae279f1ae5883e287
Gerrit-Change-Number: 67619
Gerrit-PatchSet: 1
Gerrit-Owner: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-CC: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Comment-Date: Wed, 14 Sep 2022 10:47:39 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Thomas Heijligen <src(a)posteo.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Comment-In-Reply-To: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-MessageType: comment
Attention is currently required from: Felix Singer, Nico Huber, Thomas Heijligen, Edward O'Callaghan, Anastasia Klimchuk.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67094 )
Change subject: programmer_init: Work on a mutable copy of programmer params
......................................................................
Patch Set 4: Code-Review+2
--
To view, visit https://review.coreboot.org/c/flashrom/+/67094
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If6bb2e5e4312b07f756615984bd3757e92b86b0a
Gerrit-Change-Number: 67094
Gerrit-PatchSet: 4
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 14 Sep 2022 09:32:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Felix Singer, Thomas Heijligen, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk.
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/67094 )
Change subject: programmer_init: Work on a mutable copy of programmer params
......................................................................
Patch Set 4:
(2 comments)
File flashrom.c:
https://review.coreboot.org/c/flashrom/+/67094/comment/3021820f_0e8e6d1a
PS2, Line 172: free(programmer_param);
> We didn't do so before. If somebody tries to use it later we're in trouble […]
Decided to squash it.
File flashrom.c:
https://review.coreboot.org/c/flashrom/+/67094/comment/f5f25229_e8bf483a
PS3, Line 157: -1
> probably `ERROR_FATAL` to be consistent with return codes with the rest of the function.
Done
--
To view, visit https://review.coreboot.org/c/flashrom/+/67094
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If6bb2e5e4312b07f756615984bd3757e92b86b0a
Gerrit-Change-Number: 67094
Gerrit-PatchSet: 4
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Comment-Date: Wed, 14 Sep 2022 09:17:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: comment
Attention is currently required from: Felix Singer, Nico Huber, Thomas Heijligen, Angel Pons, Anastasia Klimchuk.
Hello Felix Singer, build bot (Jenkins), Thomas Heijligen, Edward O'Callaghan, Angel Pons, Anastasia Klimchuk, Peter Marheine,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/67094
to look at the new patch set (#4).
Change subject: programmer_init: Work on a mutable copy of programmer params
......................................................................
programmer_init: Work on a mutable copy of programmer params
The signature of extract_param() was wrong all the time. It actually
modifies the passed, global `programmer_param` string. This only com-
piled w/o warnings because of a deficiency of the strstr() API. It
takes a const string as argument but returns a mutable pointer to
a substring of it.
As we take a const parameter string in the libflashrom API and should
not change that, we create a copy in programmer_init() instead.
Now that we free our copy of the programmer parameters at the end of
programmer_init() it's more obvious that the string can only be used
during initialization. So also clear `programmer_param` inside
programmer_init() instead of programmer_shutdown().
Change-Id: If6bb2e5e4312b07f756615984bd3757e92b86b0a
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M flashrom.c
1 file changed, 38 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/94/67094/4
--
To view, visit https://review.coreboot.org/c/flashrom/+/67094
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: If6bb2e5e4312b07f756615984bd3757e92b86b0a
Gerrit-Change-Number: 67094
Gerrit-PatchSet: 4
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Nico Huber <nico.h(a)gmx.de>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newpatchset