The internal variable 'gdb_actual_connections' is used by log and
by semihosting to determine if there are active GDB connections.
Keep the variable local in server's code and only export its value
through a dedicated function.
This solves the issue detected by 'parse' of the variable defined
as global but not declared in any include file.
Change-Id: I6e14f4cb1097787404094636f8a2a291340222dd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7673
Tested-by: jenkins
The function jtag_debug_state_machine_() is only used by a static
inline function and declared inside it as private.
The static analyser 'sparse' complains that the function is
defined as global but not cross checked against a prototype in an
include file.
Move the declaration outside the inline function so it get visible
by interface.c, which already includes interface.h
While there, change the argument type from 'unsigned' to 'unsigned
int' to pass checkpatch check.
Change-Id: Ia5dfb92dc4bc6d52ead4f0cb8c68319c83ff85b0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7672
Tested-by: jenkins
Let source file to include its file .h to validate the exported
prototypes.
Detected through 'sparse' tool.
Change-Id: I6197f21c857833dafc3d6e3b750c764bf4610abd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7671
Tested-by: jenkins
The static analyser 'sparse' complains about values bigger that
255 that gets cast-ed and/or stored in an 8 bit variable.
Rework the functions:
- h_u32_to_le()
- h_u32_to_be()
- h_u24_to_le()
- h_u24_to_be()
- h_u16_to_le()
- h_u16_to_be()
to avoid all the related warnings, without adding any functional
change. Any modern compiler should not be impacted by this.
Change-Id: I0b84043600a41c72d0e4ddb3dd195d69e3b2896b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7670
Tested-by: jenkins
The new committed files add some warning from the static analyser
'sparse':
- Don't assign pointer to 0, use NULL.
- switch with no cases.
Fix them.
Change-Id: I2c02d629bd80b71c8e42553be5d9388bb9b6bcd0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7668
Tested-by: jenkins
The static analyser 'sparse' complains that the functions
clear_malloc() and fill_malloc() are defined global but not cross
checked against a prototype in an include file.
Rework replacements.h and replacements.c to let the former be
included by the latter.
Change-Id: I536393a9c3718dcd7e144cde8f02e169f64c88e0
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7667
Tested-by: jenkins
Don't use 'extern' in a C file, but declare the exported function
in a H file.
This helps validating the function prototype across declaration
and use.
Detected through 'sparse' tool.
Change-Id: I2c22b084fb513f4b3b1b1db96dfbc8fa4bfe7238
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7666
Tested-by: jenkins
The static analyser 'sparse' complains, while compiling a jtag
driver, that the struct adapter_driver is declared in the file as
non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?
Move the list of adapter_driver's declaration in interface.h
Drop the preprocessor #ifdef/#endif around the declaration, as it
has no effect when the declaration is not used and/or the symbol
does not exist.
Change-Id: I5b8f5fe48a89ff0ffce38d547c551cd196379fbf
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7665
Tested-by: jenkins
Let source files to include its file .h to validate the exported
prototypes.
Detected through 'sparse' tool.
Change-Id: I217c2903fdb19e1a2cce39d2536a903c3d72f3f7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7664
Tested-by: jenkins
The static analyser 'sparse' complains, while compiling a pld
driver, that the struct pld_driver is declared in the file as
non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?
Move the list of pld_driver's declaration in pld.h
Change-Id: I0f917aecc7534c1b51af0afa9b32ccfd33db3511
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7663
Tested-by: jenkins
The static analyser 'sparse' complains, while compiling a nor
driver, that the struct flash_driver is declared in the file as
non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?
Move the list of flash_driver's declaration in driver.h
Fix some incorrect non-const declaration and remove redundant
forward declarations.
Change-Id: I5e41d094307aac4a57dfa9a70496ff3cf180bd92
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7662
Tested-by: jenkins
The static analyser 'sparse' complains, while compiling a nand
driver, that the struct nand_flash_controller is declared in the
file as non static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?
Move the list of nand_flash_controller's declaration in driver.h
While there, drop the unused/commented boundary scan controller.
Change-Id: I7dc32cef55be13ba537abe0f4c47b135d837126c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7661
Tested-by: jenkins
The static analyser 'sparse' complains, while compiling a rtos'
file, that the struct rtos_type is declared in the file as non
static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?
Move the list of rtos_type's declaration in rtos.h
Change-Id: Ia96dff077407a6653b11920519c1724e4c1167a3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7660
Tested-by: jenkins
The static analyser 'sparse' complains, while compiling a target's
file, that the struct target_type is declared in the file as non
static, but it is not exposed through an include file.
The message is:
warning: symbol 'XXX' was not declared. Should it be static?
Move the list of target_type's declaration in target_type.h
While there, fix a name clash in stm8.c
Change-Id: Ia9c681e0825cfd04d509616dbc04a0cf4944f379
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7659
Tested-by: jenkins
To perform any meaningful manipulations with DR the corresponding IR should
be set to a relevant instruction, not BYPASS, so warn the user accordingly.
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Change-Id: I42580ecd75ae824a4145f6f17f0df9bcf825b50f
Reviewed-on: https://review.openocd.org/c/openocd/+/7654
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
It's customary to use [] brackets to mean the argument is optional, but
drscan requires at least one pair of "num_bits value" so change it to ().
In common regular expressions * means 0 or more, and + means 1 or more,
so change that too.
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Change-Id: Ib15d833bda2aa398ad1345a042f97d91c98dbf66
Reviewed-on: https://review.openocd.org/c/openocd/+/7653
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
While there, add the missing .usage field and move in target.c the
enum nvp_assert.
Change-Id: Ia4f2f962887b5a35faeaa4eae128fa2865569b24
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7559
Tested-by: jenkins
Reorganize the code to parse the command line only once.
Add check for successful memory allocation.
Change-Id: Ibf6068e177c09e93150d11aecfcf079348c47c21
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7555
Tested-by: jenkins
For some trivial case only, replace calls to jim-nvp with calls
to the new OpenOCD nvp.
Change-Id: Ifd9aff32b67748af8ab808e6a6b6e64f5271b888
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7553
Tested-by: jenkins
New gcc does not understand that the variable 'restore_ms' is set
to 'true' only when the variable 'ms' is assigned in
static int xtensa_write_dirty_registers(...)
{
xtensa_reg_val_t ms;
bool restore_ms = false;
...
if (...) {
ms = regval;
restore_ms = true;
...
}
...
if (restore_ms) {
USE(ms);
}
...
}
and complains about possible use of uninitialized variable 'ms'.
Sadly initialize 'ms' to zero to hide this false positive.
Change-Id: I1fb3949070c8abbf4aa45a740f0ca2fdb753d4fa
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7681
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Reviewed-by: Ian Thompson <ianst@cadence.com>
Tested-by: jenkins
Current code tests a function pointer against a numeric value that
is the same enum type as returned by the pointed function.
Clearly the author was willing to call the function and check its
returned value.
Fix the check by calling the function.
Detected through 'sparse' tool.
Change-Id: I27d18d26c2c797160a397daa32835c199014b70b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Checkpatch-ignore: GIT_COMMIT_ID
Fixes: 237e894805 ("reworked etm/etb into a generic etm part with trace capture")
Reviewed-on: https://review.openocd.org/c/openocd/+/7599
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Commit 07e1ebcc12 ("jtag: drivers: with pointers, use NULL
instead of 0") incorrectly inverts the check, making the driver's
pathmove operation not functional and triggering two clang errors.
Fix the check on malloc() returned pointer.
Change-Id: If1f220aca67452adbcd3a1c9cf691fc984b16b27
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 07e1ebcc12 ("jtag: drivers: with pointers, use NULL instead of 0")
Reviewed-on: https://review.openocd.org/c/openocd/+/7656
Tested-by: jenkins
When gatemate_set_instr() fails, the array pointed by
bit_file.raw_file.data is not freed.
Issue identified by OpenOCD Jenkins clang build.
Free the array while propagating the error.
Change-Id: I2f7fadee903f9c65cdc9ab9b52ccb5803b48a59d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 682f927f8e ("pld: add support for cologne chip gatemate fpgas")
Reviewed-on: https://review.openocd.org/c/openocd/+/7632
Tested-by: jenkins
Reviewed-by: Daniel Anselmi <danselmi@gmx.ch>
Let source file to include its file .h to validate the exported
prototypes.
Detected through 'sparse' tool.
Change-Id: I8ae2f8f1fdaea5683e157247463533b17237e464
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7602
Tested-by: jenkins
On 32 bit hosts, gcc should consider constants without suffix as
32 bits values.
Use the suffix 'ULL' to guarantee it is a 64 bit.
Detected through 'sparse' tool.
Change-Id: I205ca986968fef9a536f87492d1f6c80e41829f3
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7601
Tested-by: jenkins
Don't compare pointers with 0, use NULL when needed.
Don't assign pointer to 0, use NULL.
Detected through 'sparse' tool.
Change-Id: Ifa81ba961c0d490cc74880b4a46b620e6358f779
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7598
Tested-by: jenkins
Don't compare pointers with 0, use NULL when needed.
Don't assign pointer to 0, use NULL.
Don't pass 0 ad pointer argument, pass NULL.
Detected through 'sparse' tool.
Change-Id: I3f867cb9c0903f6e396311e7b3970ee5fb3a4231
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7597
Tested-by: jenkins
Let source file to include its file .h to validate the exported
prototypes.
Detected through 'sparse' tool.
Change-Id: I5de107b4f8a468f0e37f06171f5f0c3c0546db1a
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7596
Tested-by: jenkins
Add static type to symbols that are not used elsewhere.
Detected through 'sparse' tool.
Change-Id: I2bdac5d2b06a6dbed5c27bfdb1cf36eee90ad823
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7594
Tested-by: jenkins
On 32 bit hosts, gcc should consider constants without suffix as
32 bits values. Adding a cast to convert it to 64 bits should not
be enough.
Use the suffix 'ULL' to guarantee it is a 64 bit.
Detected through 'sparse' tool.
Change-Id: If6be35bd3cbbc7c3a83e0da1407e611f07ff6e06
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7593
Tested-by: jenkins
Don't compare pointers with 0, use NULL when needed.
Don't assign pointer to 0, use NULL.
Don't pass 0 ad pointer argument, pass NULL.
While there, check for return value from malloc(), replace an
assert() with a LOG_ERROR(), drop a useless cast.
Detected through 'sparse' tool.
Change-Id: Ia7cf52221b12198aba1a07ebdfaf57ce341d5699
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7592
Tested-by: jenkins
Add static type to symbols that are not used elsewhere.
Detected through 'sparse' tool.
Change-Id: I00e151d2466868a5dce028444d326defb80d4826
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7591
Tested-by: jenkins
It looks like a false positive.
Scan-build considers as possible to:
- have list_empty() return false;
- list_for_each_safe() to not execute any loop, thus not assigning
a non-NULL value to 'block';
- the NULL pointer 'block' is passed to list_del().
This is not possible because with list_empty(), the loop runs at
least once.
Rewrite the function to simplify the code and making it easier for
scan-build to check it.
This also drops an incorrect use of list_for_each_safe(), where
the 'safe' version was not required.
Change-Id: Ia8b1d221cf9df73db1196e3f51986023dcaf78eb
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 8d1dcf293a ("target/espressif: add application tracing functionality over JTAG")
Reviewed-on: https://review.openocd.org/c/openocd/+/7608
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Tested-by: jenkins
When the function xtensa_queue_dbg_reg_read() returns error, the
array 'tmp' remains not initialized and scan-build complains while
computing buf_get_u32() that:
Result of operation is garbage or undefined
Check the returned value of xtensa_queue_dbg_reg_read() and
propagate it.
Change-Id: If0aaad068b97ef0a76560e262d16429afd469585
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Fixes: 8d1dcf293a ("target/espressif: add application tracing functionality over JTAG")
Reviewed-on: https://review.openocd.org/c/openocd/+/7607
Tested-by: jenkins
Reviewed-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Below warnings are fixed.
1- A function declaration without a prototype is deprecated in all
versions of C [-Werror,-Wstrict-prototypes]
2- error: variable set but not used [-Werror,-Wunused-but-set-variable]
Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I1cf14b8e5e3e732ebc9cacc4b1cb9009276a8ea9
Reviewed-on: https://review.openocd.org/c/openocd/+/7569
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins