|
From: openocd-gerrit <ope...@us...> - 2026-09-13 04:55:07
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 54a33aeab039b7eaad7a9ee5856ed2235800e0b1 (commit)
from bd521b22217b64c47573d084a3ce49a03b1e0e61 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 54a33aeab039b7eaad7a9ee5856ed2235800e0b1
Author: Tomas Vanek <va...@fb...>
Date: Fri Aug 21 17:57:41 2026 +0200
flash/nor: drop some exit() calls
and replace them by passing appropriate error codes.
Change-Id: I1cd42b6bfaf630026a01545e1dd8dc1a3ba1b760
Signed-off-by: Tomas Vanek <va...@fb...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9860
Reviewed-by: Antonio Borneo <bor...@gm...>
Tested-by: jenkins
diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c
index 108b66750..2633d4cbc 100644
--- a/src/flash/nor/cfi.c
+++ b/src/flash/nor/cfi.c
@@ -2607,7 +2607,9 @@ int cfi_probe(struct flash_bank *bank)
return retval;
/* check device/manufacturer ID for known non-CFI flashes. */
- cfi_fixup_non_cfi(bank);
+ retval = cfi_fixup_non_cfi(bank);
+ if (retval != ERROR_OK)
+ return retval;
/* query only if this is a CFI compatible flash,
* otherwise the relevant info has already been filled in
diff --git a/src/flash/nor/non_cfi.c b/src/flash/nor/non_cfi.c
index f096ba69c..4a229de54 100644
--- a/src/flash/nor/non_cfi.c
+++ b/src/flash/nor/non_cfi.c
@@ -455,7 +455,7 @@ static const struct non_cfi non_cfi_flashes[] = {
}
};
-void cfi_fixup_non_cfi(struct flash_bank *bank)
+int cfi_fixup_non_cfi(struct flash_bank *bank)
{
unsigned int mask;
struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -474,7 +474,7 @@ void cfi_fixup_non_cfi(struct flash_bank *bank)
/* only fixup jedec flashes found in table */
if (!non_cfi->mfr)
- return;
+ return ERROR_OK;
cfi_info->not_cfi = true;
@@ -544,6 +544,7 @@ void cfi_fixup_non_cfi(struct flash_bank *bank)
cfi_info->pri_ext = pri_ext;
} else if ((cfi_info->pri_id == 0x1) || (cfi_info->pri_id == 0x3)) {
LOG_ERROR("BUG: non-CFI flashes using the Intel commandset are not yet supported");
- exit(-1);
+ return ERROR_NOT_IMPLEMENTED;
}
+ return ERROR_OK;
}
diff --git a/src/flash/nor/non_cfi.h b/src/flash/nor/non_cfi.h
index 47d7e59f6..f92ad9d58 100644
--- a/src/flash/nor/non_cfi.h
+++ b/src/flash/nor/non_cfi.h
@@ -20,6 +20,6 @@ struct non_cfi {
uint8_t status_poll_mask;
};
-void cfi_fixup_non_cfi(struct flash_bank *bank);
+int cfi_fixup_non_cfi(struct flash_bank *bank);
#endif /* OPENOCD_FLASH_NOR_NON_CFI_H */
diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c
index e84721333..121627bab 100644
--- a/src/flash/nor/str7x.c
+++ b/src/flash/nor/str7x.c
@@ -145,7 +145,7 @@ static int str7x_build_block_list(struct flash_bank *bank)
break;
default:
LOG_ERROR("BUG: unknown bank->size encountered");
- exit(-1);
+ return ERROR_FAIL;
}
num_sectors = b0_sectors + b1_sectors;
@@ -197,9 +197,10 @@ FLASH_BANK_COMMAND_HANDLER(str7x_flash_bank_command)
str7x_info->busy_bits = (FLASH_LOCK | FLASH_BSYA1 | FLASH_BSYA0);
str7x_info->disable_bit = (1 << 1);
- if (strcmp(CMD_ARGV[6], "STR71x") == 0)
+ int retval = ERROR_OK;
+ if (strcmp(CMD_ARGV[6], "STR71x") == 0) {
str7x_info->register_base = 0x40100000;
- else if (strcmp(CMD_ARGV[6], "STR73x") == 0) {
+ } else if (strcmp(CMD_ARGV[6], "STR73x") == 0) {
str7x_info->register_base = 0x80100000;
str7x_info->busy_bits = (FLASH_LOCK | FLASH_BSYA0);
} else if (strcmp(CMD_ARGV[6], "STR75x") == 0) {
@@ -207,13 +208,17 @@ FLASH_BANK_COMMAND_HANDLER(str7x_flash_bank_command)
str7x_info->disable_bit = (1 << 0);
} else {
LOG_ERROR("unknown STR7x variant: '%s'", CMD_ARGV[6]);
- free(str7x_info);
- return ERROR_FLASH_BANK_INVALID;
+ retval = ERROR_FLASH_BANK_INVALID;
}
- str7x_build_block_list(bank);
+ if (retval == ERROR_OK)
+ retval = str7x_build_block_list(bank);
- return ERROR_OK;
+ if (retval != ERROR_OK) {
+ free(bank->driver_priv);
+ bank->driver_priv = NULL;
+ }
+ return retval;
}
/* wait for flash to become idle or report errors.
diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c
index 9efac241a..2fa0db99d 100644
--- a/src/flash/nor/str9x.c
+++ b/src/flash/nor/str9x.c
@@ -95,7 +95,7 @@ static int str9x_build_block_list(struct flash_bank *bank)
break;
default:
LOG_ERROR("BUG: unknown bank->size encountered");
- exit(-1);
+ return ERROR_FAIL;
}
num_sectors = b0_sectors + b1_sectors;
@@ -142,9 +142,12 @@ FLASH_BANK_COMMAND_HANDLER(str9x_flash_bank_command)
str9x_info = malloc(sizeof(struct str9x_flash_bank));
bank->driver_priv = str9x_info;
- str9x_build_block_list(bank);
-
- return ERROR_OK;
+ int retval = str9x_build_block_list(bank);
+ if (retval != ERROR_OK) {
+ free(bank->driver_priv);
+ bank->driver_priv = NULL;
+ }
+ return retval;
}
static int str9x_protect_check(struct flash_bank *bank)
diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c
index b7156a1ae..016f07410 100644
--- a/src/flash/nor/str9xpec.c
+++ b/src/flash/nor/str9xpec.c
@@ -224,7 +224,7 @@ static int str9xpec_build_block_list(struct flash_bank *bank)
break;
default:
LOG_ERROR("BUG: unknown bank->size encountered");
- exit(-1);
+ return ERROR_FAIL;
}
num_sectors = b0_sectors + b1_sectors;
@@ -282,12 +282,16 @@ FLASH_BANK_COMMAND_HANDLER(str9xpec_flash_bank_command)
str9xpec_info->tap = jtag_tap_by_position(jtag_info->tap->abs_chain_position - 1);
str9xpec_info->isc_enable = 0;
- str9xpec_build_block_list(bank);
+ int retval = str9xpec_build_block_list(bank);
+ if (retval != ERROR_OK) {
+ free(bank->driver_priv);
+ bank->driver_priv = NULL;
+ }
/* clear option byte register */
buf_set_u32(str9xpec_info->options, 0, 64, 0);
- return ERROR_OK;
+ return retval;
}
static int str9xpec_blank_check(struct flash_bank *bank, unsigned int first,
diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c
index 57e53dca1..5829d862b 100644
--- a/src/flash/nor/tcl.c
+++ b/src/flash/nor/tcl.c
@@ -606,7 +606,8 @@ COMMAND_HANDLER(handle_flash_fill_command)
break;
default:
LOG_ERROR("BUG: can't happen");
- exit(-1);
+ retval = ERROR_FAIL;
+ goto done;
}
if (padding_at_end) {
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/cfi.c | 4 +++-
src/flash/nor/non_cfi.c | 7 ++++---
src/flash/nor/non_cfi.h | 2 +-
src/flash/nor/str7x.c | 19 ++++++++++++-------
src/flash/nor/str9x.c | 11 +++++++----
src/flash/nor/str9xpec.c | 10 +++++++---
src/flash/nor/tcl.c | 3 ++-
7 files changed, 36 insertions(+), 20 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|