summaryrefslogtreecommitdiffstats
path: root/ichspi.c
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2022-06-20 10:01:08 +0200
committerThomas Heijligen <src@posteo.de>2022-08-24 20:54:07 +0000
commit75b745544191b7c27db24563f54b64a0b6fdbf31 (patch)
tree443a89cf2df2618bfb61d22cc65af21b226610fc /ichspi.c
parent1b880756d43e499d3dcd13a5d138ec1da9a59ace (diff)
downloadflashrom-75b745544191b7c27db24563f54b64a0b6fdbf31.tar.gz
flashrom-75b745544191b7c27db24563f54b64a0b6fdbf31.tar.bz2
flashrom-75b745544191b7c27db24563f54b64a0b6fdbf31.zip
ichspi.c: Clean up get_ich_spi_mode_param()
Instead of checking for the variable arg in multiple compound statements, separate it out in its own branch and return 0 if arg is NULL. Signed-off-by: Felix Singer <felixsinger@posteo.net> Change-Id: Id1038568ff25cf6f0895b26921cc4a0d7bcfabb7 Reviewed-on: https://review.coreboot.org/c/flashrom/+/65248 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'ichspi.c')
-rw-r--r--ichspi.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ichspi.c b/ichspi.c
index c73ac3f20..030cd92cd 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1875,20 +1875,22 @@ enum ich_spi_mode {
static int get_ich_spi_mode_param(enum ich_spi_mode *ich_spi_mode)
{
char *const arg = extract_programmer_param_str("ich_spi_mode");
- if (arg && !strcmp(arg, "hwseq")) {
+ if (!arg) {
+ return 0;
+ } else if (!strcmp(arg, "hwseq")) {
*ich_spi_mode = ich_hwseq;
msg_pspew("user selected hwseq\n");
- } else if (arg && !strcmp(arg, "swseq")) {
+ } else if (!strcmp(arg, "swseq")) {
*ich_spi_mode = ich_swseq;
msg_pspew("user selected swseq\n");
- } else if (arg && !strcmp(arg, "auto")) {
+ } else if (!strcmp(arg, "auto")) {
msg_pspew("user selected auto\n");
*ich_spi_mode = ich_auto;
- } else if (arg && !strlen(arg)) {
+ } else if (!strlen(arg)) {
msg_perr("Missing argument for ich_spi_mode.\n");
free(arg);
return ERROR_FATAL;
- } else if (arg) {
+ } else {
msg_perr("Unknown argument for ich_spi_mode: %s\n", arg);
free(arg);
return ERROR_FATAL;