jtag/drivers/ulink: fix clang static analyzer warning

scan-build-9:
Description: Access to field 'payload_in' results in a dereference
 of a null pointer (loaded from field 'queue_start')
File: src/jtag/drivers/ulink.c
Line: 2216

Set input/output_signals conditionally if ulink_append_get_signals_cmd()
and ulink_execute_queued_commands() returns no error.
Do not fail driver initialisation as the signals are only printed.

Change-Id: I6c842f0e9a604712abf7444a2fa95ba5810de1ff
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5520
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
This commit is contained in:
Tomas Vanek 2020-03-13 15:13:21 +01:00 committed by Oleksij Rempel
parent c064440162
commit 6dcd255b7b
1 changed files with 9 additions and 6 deletions

View File

@ -2210,14 +2210,17 @@ static int ulink_init(void)
}
ulink_clear_queue(ulink_handle);
ulink_append_get_signals_cmd(ulink_handle);
ulink_execute_queued_commands(ulink_handle, 200);
ret = ulink_append_get_signals_cmd(ulink_handle);
if (ret == ERROR_OK)
ret = ulink_execute_queued_commands(ulink_handle, 200);
/* Post-process the single CMD_GET_SIGNALS command */
input_signals = ulink_handle->queue_start->payload_in[0];
output_signals = ulink_handle->queue_start->payload_in[1];
if (ret == ERROR_OK) {
/* Post-process the single CMD_GET_SIGNALS command */
input_signals = ulink_handle->queue_start->payload_in[0];
output_signals = ulink_handle->queue_start->payload_in[1];
ulink_print_signal_states(input_signals, output_signals);
ulink_print_signal_states(input_signals, output_signals);
}
ulink_clear_queue(ulink_handle);