From: openocd-gerrit <ope...@us...> - 2025-06-29 07:34:21
|
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 46aa9c0e526f39c61b2c08ac1d21c998ad34259e (commit) from 9b660bbd1957ffc1fd86485ceef5200f8968aeb6 (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 46aa9c0e526f39c61b2c08ac1d21c998ad34259e Author: Jan Matyas <jan...@co...> Date: Tue Jun 17 13:17:23 2025 +0200 openocd.c: 'init' should fail if GDB service cannot be created If it is not possible to create a GDB service for a certain target (for example the given TCP port is already occupied), the "init" command should fail, but it currently does not. Fix this by checking the return code of gdb_target_add_all(). Steps to reproduce: 1) Make the port 3333/tcp occupied. For example by: nc -l 3333 2) In another terminal, launch OpenOCD. Use the gdb_port 3333 (which is the default). For example: path/to/your/openocd \ -c "adapter driver ..." \ -c "jtag newtap ..." -c "target create ..." 3) Observe the outcome: Before this patch: Error "couldn't bind gdb to socket on port 3333: Address already in use" is displayed but OpenOCD keeps running. After this patch: The error message is displayed and OpenOCD exits - as expected. Change-Id: I63c283a9a1095167b78e69e9ee879c378a6b9f2a Signed-off-by: Jan Matyas <jan...@co...> Reviewed-on: https://review.openocd.org/c/openocd/+/8957 Tested-by: jenkins Reviewed-by: zapb <de...@za...> Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/openocd.c b/src/openocd.c index 3fbece395..e63a9661a 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -170,7 +170,8 @@ COMMAND_HANDLER(handle_init_command) jtag_poll_unmask(save_poll_mask); /* initialize telnet subsystem */ - gdb_target_add_all(all_targets); + if (gdb_target_add_all(all_targets) != ERROR_OK) + return ERROR_FAIL; target_register_event_callback(log_target_callback_event_handler, CMD_CTX); ----------------------------------------------------------------------- Summary of changes: src/openocd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |