|
From: openocd-gerrit <ope...@us...> - 2023-06-02 20:59:12
|
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 0e526314a155c73e5eac2dc6bdea0235738ca1a2 (commit)
via 00603bf15638347256b1c330bafbeaef0d4d8287 (commit)
from 72131e05e9337f1f950f604f5e07683e887ce3ab (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 0e526314a155c73e5eac2dc6bdea0235738ca1a2
Author: Antonio Borneo <bor...@gm...>
Date: Sat May 27 17:01:58 2023 +0200
flash: jtagspi: fix clang build warning
Clang is unable to fully track the content of the array
write_buffer[] and incorrectly complains that it could contain
some uninitialized value.
To help clang to track the execution flow, rewrite the handling of
the buffer by using simpler indexing and by moving away cmd_byte
from the first buffer's element to the variable cmd_byte.
While there:
- fix the error codes returned while parsing the command line and
- use directly command_print_sameline() instead of passing through
intermediate buffers.
Change-Id: I1969e896887ea3a4abebee057cc04c03005fa57c
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/7718
Tested-by: jenkins
diff --git a/src/flash/nor/jtagspi.c b/src/flash/nor/jtagspi.c
index 866548a7e..6bb3af9b7 100644
--- a/src/flash/nor/jtagspi.c
+++ b/src/flash/nor/jtagspi.c
@@ -301,24 +301,18 @@ COMMAND_HANDLER(jtagspi_handle_set)
COMMAND_HANDLER(jtagspi_handle_cmd)
{
struct flash_bank *bank;
- unsigned int index = 1;
- const int max = 21;
- uint8_t num_write, num_read, write_buffer[max], read_buffer[1 << CHAR_BIT];
- uint8_t data, *ptr;
- char temp[4], output[(2 + max + (1 << CHAR_BIT)) * 3 + 8];
- int retval;
+ const unsigned int max = 20;
+ uint8_t cmd_byte, num_read, write_buffer[max], read_buffer[1 << CHAR_BIT];
LOG_DEBUG("%s", __func__);
- if (CMD_ARGC < 3) {
- command_print(CMD, "jtagspi: not enough arguments");
+ if (CMD_ARGC < 3)
return ERROR_COMMAND_SYNTAX_ERROR;
- }
- num_write = CMD_ARGC - 2;
+ uint8_t num_write = CMD_ARGC - 3;
if (num_write > max) {
- LOG_ERROR("at most %d bytes may be send", max);
- return ERROR_COMMAND_SYNTAX_ERROR;
+ command_print(CMD, "at most %d bytes may be send", max);
+ return ERROR_COMMAND_ARGUMENT_INVALID;
}
/* calling flash_command_get_bank without probing because we like to be
@@ -326,33 +320,31 @@ COMMAND_HANDLER(jtagspi_handle_cmd)
"release from power down" is needed before probing when flash is in
power down mode.
*/
- retval = CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, 0,
+ int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_probe_optional, 0,
&bank, false);
- if (ERROR_OK != retval)
+ if (retval != ERROR_OK)
return retval;
- COMMAND_PARSE_NUMBER(u8, CMD_ARGV[index++], num_read);
+ COMMAND_PARSE_NUMBER(u8, CMD_ARGV[1], num_read);
+ COMMAND_PARSE_NUMBER(u8, CMD_ARGV[2], cmd_byte);
- snprintf(output, sizeof(output), "spi: ");
- for (ptr = &write_buffer[0] ; index < CMD_ARGC; index++) {
- COMMAND_PARSE_NUMBER(u8, CMD_ARGV[index], data);
- *ptr++ = data;
- snprintf(temp, sizeof(temp), "%02" PRIx8 " ", data);
- strncat(output, temp, sizeof(output) - strlen(output) - 1);
- }
- strncat(output, "-> ", sizeof(output) - strlen(output) - 1);
+ for (unsigned int i = 0; i < num_write; i++)
+ COMMAND_PARSE_NUMBER(u8, CMD_ARGV[i + 3], write_buffer[i]);
/* process command */
- ptr = &read_buffer[0];
- retval = jtagspi_cmd(bank, write_buffer[0], &write_buffer[1], num_write - 1, ptr, -num_read);
+ retval = jtagspi_cmd(bank, cmd_byte, write_buffer, num_write, read_buffer, -num_read);
if (retval != ERROR_OK)
return retval;
- for ( ; num_read > 0; num_read--) {
- snprintf(temp, sizeof(temp), "%02" PRIx8 " ", *ptr++);
- strncat(output, temp, sizeof(output) - strlen(output) - 1);
- }
- command_print(CMD, "%s", output);
+ command_print_sameline(CMD, "spi: %02" PRIx8, cmd_byte);
+
+ for (unsigned int i = 0; i < num_write; i++)
+ command_print_sameline(CMD, " %02" PRIx8, write_buffer[i]);
+
+ command_print_sameline(CMD, " ->");
+
+ for (unsigned int i = 0; i < num_read; i++)
+ command_print_sameline(CMD, " %02" PRIx8, read_buffer[i]);
return ERROR_OK;
}
commit 00603bf15638347256b1c330bafbeaef0d4d8287
Author: Antonio Borneo <bor...@gm...>
Date: Sat May 27 15:56:44 2023 +0200
flash: psoc4: fix clang error
Clang 15.0.7 complains about snprintf output truncation due to
output between 13 and 22 bytes into a destination of size 20.
Increase the size of the buffer.
Change-Id: I0369255ca1bc02a0cf494f765e91a608c960a0d6
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/7717
Tested-by: jenkins
diff --git a/src/flash/nor/psoc4.c b/src/flash/nor/psoc4.c
index fb462c1e5..1064fa93d 100644
--- a/src/flash/nor/psoc4.c
+++ b/src/flash/nor/psoc4.c
@@ -779,7 +779,7 @@ static int psoc4_probe(struct flash_bank *bank)
flash_size_in_kb = psoc4_info->user_bank_size / 1024;
}
- char macros_txt[20] = "";
+ char macros_txt[22] = "";
if (num_macros > 1)
snprintf(macros_txt, sizeof(macros_txt), " in %" PRIu32 " macros", num_macros);
-----------------------------------------------------------------------
Summary of changes:
src/flash/nor/jtagspi.c | 52 +++++++++++++++++++++----------------------------
src/flash/nor/psoc4.c | 2 +-
2 files changed, 23 insertions(+), 31 deletions(-)
hooks/post-receive
--
Main OpenOCD repository
|