Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/72824 )
Change subject: programmer_table.c: Simplify name_to_entry() fn ......................................................................
programmer_table.c: Simplify name_to_entry() fn
Change-Id: I0fea6b16bca3024dd49ad56f5d2e39eb998159fa Signed-off-by: Edward O'Callaghan quasisec@google.com --- M programmer_table.c 1 file changed, 17 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/24/72824/1
diff --git a/programmer_table.c b/programmer_table.c index c4834d0..2568ea8 100644 --- a/programmer_table.c +++ b/programmer_table.c @@ -179,22 +179,19 @@
const struct programmer_entry *programmer_name_to_entry(const char *name) { - unsigned prog; - if (strlen(name) == 0) { const struct programmer_entry *const default_programmer = CONFIG_DEFAULT_PROGRAMMER_NAME; if (default_programmer) return default_programmer; }
- for (prog = 0; prog < programmer_table_size; prog++) { + for (unsigned int prog = 0; prog < programmer_table_size; prog++) { if (strcmp(name, programmer_table[prog]->name) == 0) - break; + return programmer_table[prog]; } - if (prog >= programmer_table_size) { - msg_ginfo("Error: Unknown programmer "%s". Valid choices are:\n", name); - list_programmers_linebreak(0, 80, 0); - return NULL; - } - return programmer_table[prog]; + + msg_ginfo("Error: Unknown programmer "%s". Valid choices are:\n", name); + list_programmers_linebreak(0, 80, 0); + + return NULL; }