Browse Source

openocd: remove NULL comparisons with checkpatch [1/2]

Patch generated automatically through the new checkpatch with
flags "--types COMPARISON_TO_NULL --fix-inplace".
This only fixes the comparisons
	if (symbol == NULL)
	if (symbol != NULL)
The case of NULL on the left side of the comparison is not tested.

Some automatic fix is incorrect and has been massaged by hands:
	-	if (*psig == NULL)
	+	if (*!psig)
changed as
	+	if (!*psig)

Change-Id: If4a1e2b4e547e223532e8e3d9da89bf9cb382ce6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6351
Tested-by: jenkins
jim
Antonio Borneo 1 year ago
parent
commit
3917823187
71 changed files with 181 additions and 181 deletions
  1. +4
    -4
      src/flash/nand/core.c
  2. +3
    -3
      src/flash/nor/at91sam3.c
  3. +3
    -3
      src/flash/nor/at91sam4.c
  4. +1
    -1
      src/flash/nor/at91sam7.c
  5. +1
    -1
      src/flash/nor/at91samd.c
  6. +2
    -2
      src/flash/nor/core.c
  7. +1
    -1
      src/flash/nor/jtagspi.c
  8. +3
    -3
      src/flash/nor/pic32mx.c
  9. +2
    -2
      src/flash/nor/tcl.c
  10. +1
    -1
      src/flash/nor/virtual.c
  11. +1
    -1
      src/flash/nor/xcf.c
  12. +3
    -3
      src/helper/command.c
  13. +2
    -2
      src/helper/log.c
  14. +1
    -1
      src/helper/replacements.c
  15. +2
    -2
      src/jtag/core.c
  16. +1
    -1
      src/jtag/drivers/at91rm9200.c
  17. +2
    -2
      src/jtag/drivers/cmsis_dap.c
  18. +4
    -4
      src/jtag/drivers/driver.c
  19. +4
    -4
      src/jtag/drivers/ftdi.c
  20. +1
    -1
      src/jtag/drivers/jtag_dpi.c
  21. +1
    -1
      src/jtag/drivers/jtag_vpi.c
  22. +2
    -2
      src/jtag/drivers/libusb_helper.c
  23. +1
    -1
      src/jtag/drivers/remote_bitbang.c
  24. +1
    -1
      src/jtag/drivers/rlink.c
  25. +3
    -3
      src/jtag/drivers/stlink_usb.c
  26. +1
    -1
      src/jtag/drivers/usb_blaster/usb_blaster.c
  27. +4
    -4
      src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c
  28. +2
    -2
      src/jtag/hla/hla_interface.c
  29. +1
    -1
      src/jtag/tcl.c
  30. +1
    -1
      src/rtos/FreeRTOS.c
  31. +1
    -1
      src/rtos/ThreadX.c
  32. +2
    -2
      src/rtos/chibios.c
  33. +1
    -1
      src/rtos/eCos.c
  34. +1
    -1
      src/rtos/embKernel.c
  35. +6
    -6
      src/rtos/hwthread.c
  36. +1
    -1
      src/rtos/linux.c
  37. +1
    -1
      src/rtos/mqx.c
  38. +1
    -1
      src/rtos/nuttx.c
  39. +4
    -4
      src/rtos/riot.c
  40. +5
    -5
      src/rtos/rtos.c
  41. +2
    -2
      src/rtos/uCOS-III.c
  42. +1
    -1
      src/rtos/zephyr.c
  43. +16
    -16
      src/server/gdb_server.c
  44. +4
    -4
      src/server/tcl_server.c
  45. +2
    -2
      src/server/telnet_server.c
  46. +1
    -1
      src/svf/svf.c
  47. +2
    -2
      src/target/aarch64.c
  48. +1
    -1
      src/target/arc.c
  49. +1
    -1
      src/target/arm_adi_v5.c
  50. +2
    -2
      src/target/arm_adi_v5.h
  51. +1
    -1
      src/target/armv7a.c
  52. +1
    -1
      src/target/armv7m.c
  53. +4
    -4
      src/target/armv8.c
  54. +1
    -1
      src/target/armv8_cache.c
  55. +2
    -2
      src/target/cortex_a.c
  56. +4
    -4
      src/target/esirisc.c
  57. +1
    -1
      src/target/esirisc_jtag.c
  58. +1
    -1
      src/target/etm.c
  59. +1
    -1
      src/target/hla_target.c
  60. +7
    -7
      src/target/lakemont.c
  61. +2
    -2
      src/target/ls1_sap.c
  62. +2
    -2
      src/target/mem_ap.c
  63. +1
    -1
      src/target/mips_m4k.c
  64. +13
    -13
      src/target/nds32_aice.c
  65. +1
    -1
      src/target/riscv/riscv-013.c
  66. +2
    -2
      src/target/riscv/riscv.c
  67. +1
    -1
      src/target/semihosting_common.c
  68. +15
    -15
      src/target/target.c
  69. +2
    -2
      src/target/target_request.c
  70. +4
    -4
      src/target/x86_32_common.c
  71. +1
    -1
      src/transport/transport.c

+ 4
- 4
src/flash/nand/core.c View File

@@ -682,7 +682,7 @@ int nand_write_page(struct nand_device *nand, uint32_t page,
if (nand->blocks[block].is_erased == 1)
nand->blocks[block].is_erased = 0;

if (nand->use_raw || nand->controller->write_page == NULL)
if (nand->use_raw || !nand->controller->write_page)
return nand_write_page_raw(nand, page, data, data_size, oob, oob_size);
else
return nand->controller->write_page(nand, page, data, data_size, oob, oob_size);
@@ -695,7 +695,7 @@ int nand_read_page(struct nand_device *nand, uint32_t page,
if (!nand->device)
return ERROR_NAND_DEVICE_NOT_PROBED;

if (nand->use_raw || nand->controller->read_page == NULL)
if (nand->use_raw || !nand->controller->read_page)
return nand_read_page_raw(nand, page, data, data_size, oob, oob_size);
else
return nand->controller->read_page(nand, page, data, data_size, oob, oob_size);
@@ -769,7 +769,7 @@ int nand_read_data_page(struct nand_device *nand, uint8_t *data, uint32_t size)
{
int retval = ERROR_NAND_NO_BUFFER;

if (nand->controller->read_block_data != NULL)
if (nand->controller->read_block_data)
retval = (nand->controller->read_block_data)(nand, data, size);

if (retval == ERROR_NAND_NO_BUFFER) {
@@ -809,7 +809,7 @@ int nand_write_data_page(struct nand_device *nand, uint8_t *data, uint32_t size)
{
int retval = ERROR_NAND_NO_BUFFER;

if (nand->controller->write_block_data != NULL)
if (nand->controller->write_block_data)
retval = (nand->controller->write_block_data)(nand, data, size);

if (retval == ERROR_NAND_NO_BUFFER) {


+ 3
- 3
src/flash/nor/at91sam3.c View File

@@ -3545,7 +3545,7 @@ COMMAND_HANDLER(sam3_handle_info_command)
int r;

/* bank0 must exist before we can do anything */
if (chip->details.bank[0].bank == NULL) {
if (!chip->details.bank[0].bank) {
x = 0;
need_define:
command_print(CMD,
@@ -3571,7 +3571,7 @@ need_define:
if (!(chip->details.bank[x].present))
continue;

if (chip->details.bank[x].bank == NULL)
if (!chip->details.bank[x].bank)
goto need_define;

if (chip->details.bank[x].probed)
@@ -3606,7 +3606,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command)
return ERROR_TARGET_NOT_HALTED;
}

if (chip->details.bank[0].bank == NULL) {
if (!chip->details.bank[0].bank) {
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
at91sam3_flash.name);
return ERROR_FAIL;


+ 3
- 3
src/flash/nor/at91sam4.c View File

@@ -3092,7 +3092,7 @@ COMMAND_HANDLER(sam4_handle_info_command)
int r;

/* bank0 must exist before we can do anything */
if (chip->details.bank[0].bank == NULL) {
if (!chip->details.bank[0].bank) {
x = 0;
need_define:
command_print(CMD,
@@ -3118,7 +3118,7 @@ need_define:
if (!(chip->details.bank[x].present))
continue;

if (chip->details.bank[x].bank == NULL)
if (!chip->details.bank[x].bank)
goto need_define;

if (chip->details.bank[x].probed)
@@ -3153,7 +3153,7 @@ COMMAND_HANDLER(sam4_handle_gpnvm_command)
return ERROR_TARGET_NOT_HALTED;
}

if (chip->details.bank[0].bank == NULL) {
if (!chip->details.bank[0].bank) {
command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
at91sam4_flash.name);
return ERROR_FAIL;


+ 1
- 1
src/flash/nor/at91sam7.c View File

@@ -1040,7 +1040,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command)
return ERROR_COMMAND_SYNTAX_ERROR;

bank = get_flash_bank_by_num_noprobe(0);
if (bank == NULL)
if (!bank)
return ERROR_FLASH_BANK_INVALID;
if (strcmp(bank->driver->name, "at91sam7")) {
command_print(CMD, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]);


+ 1
- 1
src/flash/nor/at91samd.c View File

@@ -1064,7 +1064,7 @@ static COMMAND_HELPER(get_u64_from_hexarg, unsigned int num, uint64_t *value)
char *check = NULL;
*value = strtoull(&(CMD_ARGV[num][2]), &check, 16);
if ((value == 0 && errno == ERANGE) ||
check == NULL || *check != 0) {
!check || *check != 0) {
command_print(CMD, "Invalid 64-bit hex value in argument %d.",
num + 1);
return ERROR_COMMAND_SYNTAX_ERROR;


+ 2
- 2
src/flash/nor/core.c View File

@@ -70,7 +70,7 @@ int flash_driver_protect(struct flash_bank *bank, int set, unsigned int first,
/* force "set" to 0/1 */
set = !!set;

if (bank->driver->protect == NULL) {
if (!bank->driver->protect) {
LOG_ERROR("Flash protection is not supported.");
return ERROR_FLASH_OPER_UNSUPPORTED;
}
@@ -491,7 +491,7 @@ static int flash_iterate_address_range_inner(struct target *target,
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}

if (c->prot_blocks == NULL || c->num_prot_blocks == 0) {
if (!c->prot_blocks || c->num_prot_blocks == 0) {
/* flash driver does not define protect blocks, use sectors instead */
iterate_protect_blocks = false;
}


+ 1
- 1
src/flash/nor/jtagspi.c View File

@@ -172,7 +172,7 @@ static int jtagspi_probe(struct flash_bank *bank)
free(bank->sectors);
info->probed = false;

if (bank->target->tap == NULL) {
if (!bank->target->tap) {
LOG_ERROR("Target has no JTAG tap");
return ERROR_FAIL;
}


+ 3
- 3
src/flash/nor/pic32mx.c View File

@@ -714,7 +714,7 @@ static int pic32mx_probe(struct flash_bank *bank)
}

/* Check for PIC32mx1xx/2xx */
for (i = 0; pic32mx_devs[i].name != NULL; i++) {
for (i = 0; pic32mx_devs[i].name; i++) {
if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) {
if ((pic32mx_devs[i].name[0] == '1') || (pic32mx_devs[i].name[0] == '2'))
pic32mx_info->dev_type = (pic32mx_devs[i].name[1] == '7') ? MX_17X_27X : MX_1XX_2XX;
@@ -819,14 +819,14 @@ static int pic32mx_info(struct flash_bank *bank, struct command_invocation *cmd)
}

int i;
for (i = 0; pic32mx_devs[i].name != NULL; i++) {
for (i = 0; pic32mx_devs[i].name; i++) {
if (pic32mx_devs[i].devid == (device_id & 0x0fffffff)) {
command_print_sameline(cmd, "PIC32MX%s", pic32mx_devs[i].name);
break;
}
}

if (pic32mx_devs[i].name == NULL)
if (!pic32mx_devs[i].name)
command_print_sameline(cmd, "Unknown");

command_print_sameline(cmd, " Ver: 0x%02x",


+ 2
- 2
src/flash/nor/tcl.c View File

@@ -99,7 +99,7 @@ COMMAND_HANDLER(handle_flash_info_command)

/* If the driver does not implement protection, we show the default
* state of is_protected array - usually protection state unknown */
if (p->driver->protect_check == NULL) {
if (!p->driver->protect_check) {
retval = ERROR_FLASH_OPER_UNSUPPORTED;
} else {
/* We must query the hardware to avoid printing stale information! */
@@ -148,7 +148,7 @@ COMMAND_HANDLER(handle_flash_info_command)
protect_state);
}

if (p->driver->info != NULL) {
if (p->driver->info) {
/* Let the flash driver print extra custom info */
retval = p->driver->info(p, CMD);
command_print_sameline(CMD, "\n");


+ 1
- 1
src/flash/nor/virtual.c View File

@@ -93,7 +93,7 @@ static int virtual_protect_check(struct flash_bank *bank)
if (!master_bank)
return ERROR_FLASH_OPERATION_FAILED;

if (master_bank->driver->protect_check == NULL)
if (!master_bank->driver->protect_check)
return ERROR_FLASH_OPER_UNSUPPORTED;

/* call master handler */


+ 1
- 1
src/flash/nor/xcf.c View File

@@ -602,7 +602,7 @@ static int xcf_probe(struct flash_bank *bank)
free(bank->sectors);
priv->probed = false;

if (bank->target->tap == NULL) {
if (!bank->target->tap) {
LOG_ERROR("Target has no JTAG tap");
return ERROR_FAIL;
}


+ 3
- 3
src/helper/command.c View File

@@ -221,7 +221,7 @@ static char **script_command_args_alloc(
int len;
const char *w = Jim_GetString(argv[i], &len);
words[i] = strdup(w);
if (words[i] == NULL) {
if (!words[i]) {
script_command_args_free(words, i);
return NULL;
}
@@ -501,7 +501,7 @@ void command_print_sameline(struct command_invocation *cmd, const char *format,
va_start(ap, format);

string = alloc_vprintf(format, ap);
if (string != NULL && cmd) {
if (string && cmd) {
/* we want this collected in the log + we also want to pick it up as a tcl return
* value.
*
@@ -524,7 +524,7 @@ void command_print(struct command_invocation *cmd, const char *format, ...)
va_start(ap, format);

string = alloc_vprintf(format, ap);
if (string != NULL && cmd) {
if (string && cmd) {
strcat(string, "\n"); /* alloc_vprintf guaranteed the buffer to be at least one
*char longer */
/* we want this collected in the log + we also want to pick it up as a tcl return


+ 2
- 2
src/helper/log.c View File

@@ -230,7 +230,7 @@ COMMAND_HANDLER(handle_debug_level_command)
COMMAND_HANDLER(handle_log_output_command)
{
if (CMD_ARGC == 0 || (CMD_ARGC == 1 && strcmp(CMD_ARGV[0], "default") == 0)) {
if (log_output != stderr && log_output != NULL) {
if (log_output != stderr && log_output) {
/* Close previous log file, if it was open and wasn't stderr. */
fclose(log_output);
}
@@ -244,7 +244,7 @@ COMMAND_HANDLER(handle_log_output_command)
LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]);
return ERROR_FAIL;
}
if (log_output != stderr && log_output != NULL) {
if (log_output != stderr && log_output) {
/* Close previous log file, if it was open and wasn't stderr. */
fclose(log_output);
}


+ 1
- 1
src/helper/replacements.c View File

@@ -145,7 +145,7 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time
struct timeval tvslice;
int retcode;

#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
#define SAFE_FD_ISSET(fd, set) (set && FD_ISSET(fd, set))

/* calculate how long we need to wait in milliseconds */
if (!tv)


+ 2
- 2
src/jtag/core.c View File

@@ -218,7 +218,7 @@ static void jtag_tap_add(struct jtag_tap *t)
unsigned jtag_num_taps = 0;

struct jtag_tap **tap = &__jtag_all_taps;
while (*tap != NULL) {
while (*tap) {
jtag_num_taps++;
tap = &(*tap)->next_tap;
}
@@ -429,7 +429,7 @@ static void jtag_add_scan_check(struct jtag_tap *active, void (*jtag_add_scan)(
jtag_add_scan(active, in_num_fields, in_fields, state);

for (int i = 0; i < in_num_fields; i++) {
if ((in_fields[i].check_value != NULL) && (in_fields[i].in_value != NULL)) {
if ((in_fields[i].check_value) && (in_fields[i].in_value)) {
jtag_add_callback4(jtag_check_value_mask_callback,
(jtag_callback_data_t)in_fields[i].in_value,
(jtag_callback_data_t)in_fields[i].check_value,


+ 1
- 1
src/jtag/drivers/at91rm9200.c View File

@@ -209,7 +209,7 @@ static int at91rm9200_init(void)

cur_device = devices;

if (at91rm9200_device == NULL || at91rm9200_device[0] == 0) {
if (!at91rm9200_device || at91rm9200_device[0] == 0) {
at91rm9200_device = "rea_ecr";
LOG_WARNING("No at91rm9200 device specified, using default 'rea_ecr'");
}


+ 2
- 2
src/jtag/drivers/cmsis_dap.c View File

@@ -1513,7 +1513,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
s_offset + offset,
tms,
tdo_buffer,
tdo_buffer == NULL ? 0 : (tdo_buffer_offset + offset)
!tdo_buffer ? 0 : (tdo_buffer_offset + offset)
);
}
LOG_DEBUG_IO("END JTAG SEQ SPLIT");
@@ -1530,7 +1530,7 @@ static void cmsis_dap_add_jtag_sequence(int s_len, const uint8_t *sequence, int
/* control byte */
queued_seq_buf[queued_seq_buf_end] =
(tms ? DAP_JTAG_SEQ_TMS : 0) |
(tdo_buffer != NULL ? DAP_JTAG_SEQ_TDO : 0) |
(tdo_buffer ? DAP_JTAG_SEQ_TDO : 0) |
(s_len == 64 ? 0 : s_len);

if (sequence)


+ 4
- 4
src/jtag/drivers/driver.c View File

@@ -82,7 +82,7 @@ int interface_jtag_add_ir_scan(struct jtag_tap *active,

/* loop over all enabled TAPs */

for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
/* search the input field list for fields for the current TAP */

if (tap == active) {
@@ -122,7 +122,7 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields,

size_t bypass_devices = 0;

for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
if (tap->bypass)
bypass_devices++;
}
@@ -145,7 +145,7 @@ int interface_jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields,

/* loop over all enabled TAPs */

for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL; tap = jtag_tap_next_enabled(tap)) {
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap; tap = jtag_tap_next_enabled(tap)) {
/* if TAP is not bypassed insert matching input fields */

if (!tap->bypass) {
@@ -369,7 +369,7 @@ int interface_jtag_execute_queue(void)
int retval = default_interface_jtag_execute_queue();
if (retval == ERROR_OK) {
struct jtag_callback_entry *entry;
for (entry = jtag_callback_queue_head; entry != NULL; entry = entry->next) {
for (entry = jtag_callback_queue_head; entry; entry = entry->next) {
retval = entry->callback(entry->data0, entry->data1, entry->data2, entry->data3);
if (retval != ERROR_OK)
break;


+ 4
- 4
src/jtag/drivers/ftdi.c View File

@@ -150,11 +150,11 @@ static struct signal *create_signal(const char *name)
psig = &(*psig)->next;

*psig = calloc(1, sizeof(**psig));
if (*psig == NULL)
if (!*psig)
return NULL;

(*psig)->name = strdup(name);
if ((*psig)->name == NULL) {
if (!(*psig)->name) {
free(*psig);
*psig = NULL;
}
@@ -1068,7 +1068,7 @@ static int ftdi_swd_init(void)
swd_cmd_queue_alloced = 10;
swd_cmd_queue = malloc(swd_cmd_queue_alloced * sizeof(*swd_cmd_queue));

return swd_cmd_queue != NULL ? ERROR_OK : ERROR_FAIL;
return swd_cmd_queue ? ERROR_OK : ERROR_FAIL;
}

static void ftdi_swd_swdio_en(bool enable)
@@ -1143,7 +1143,7 @@ static int ftdi_swd_run_queue(void)
goto skip;
}

if (swd_cmd_queue[i].dst != NULL)
if (swd_cmd_queue[i].dst)
*swd_cmd_queue[i].dst = data;
}
}


+ 1
- 1
src/jtag/drivers/jtag_dpi.c View File

@@ -238,7 +238,7 @@ static int jtag_dpi_execute_queue(void)
struct jtag_command *cmd;
int ret = ERROR_OK;

for (cmd = jtag_command_queue; ret == ERROR_OK && cmd != NULL;
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
cmd = cmd->next) {
switch (cmd->type) {
case JTAG_RUNTEST:


+ 1
- 1
src/jtag/drivers/jtag_vpi.c View File

@@ -496,7 +496,7 @@ static int jtag_vpi_execute_queue(void)
struct jtag_command *cmd;
int retval = ERROR_OK;

for (cmd = jtag_command_queue; retval == ERROR_OK && cmd != NULL;
for (cmd = jtag_command_queue; retval == ERROR_OK && cmd;
cmd = cmd->next) {
switch (cmd->type) {
case JTAG_RESET:


+ 2
- 2
src/jtag/drivers/libusb_helper.c View File

@@ -189,7 +189,7 @@ int jtag_libusb_open(const uint16_t vids[], const uint16_t pids[],
}

/* Device must be open to use libusb_get_string_descriptor_ascii. */
if (serial != NULL &&
if (serial &&
!jtag_libusb_match_serial(libusb_handle, &dev_desc, serial, adapter_get_alternate_serial)) {
serial_mismatch = true;
libusb_close(libusb_handle);
@@ -285,7 +285,7 @@ int jtag_libusb_set_configuration(struct libusb_device_handle *devh,
return retval;

retval = libusb_get_config_descriptor(udev, configuration, &config);
if (retval != 0 || config == NULL)
if (retval != 0 || !config)
return retval;

/* Only change the configuration if it is not already set to the


+ 1
- 1
src/jtag/drivers/remote_bitbang.c View File

@@ -250,7 +250,7 @@ static int remote_bitbang_init_tcp(void)
If socket(2) (or connect(2)) fails, we (close the socket
and) try the next address. */

for (rp = result; rp != NULL ; rp = rp->ai_next) {
for (rp = result; rp ; rp = rp->ai_next) {
fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (fd == -1)
continue;


+ 1
- 1
src/jtag/drivers/rlink.c View File

@@ -677,7 +677,7 @@ static int dtc_queue_run(void)

for (
rq_p = dtc_queue.rq_head;
rq_p != NULL;
rq_p;
rq_p = rq_next
) {
tdo_p = rq_p->scan.buffer + (rq_p->scan.offset / 8);


+ 3
- 3
src/jtag/drivers/stlink_usb.c View File

@@ -568,7 +568,7 @@ static int jtag_libusb_bulk_transfer_n(
transfers[i].transfer_size = 0;
transfers[i].transfer = libusb_alloc_transfer(0);

if (transfers[i].transfer == NULL) {
if (!transfers[i].transfer) {
for (size_t j = 0; j < i; ++j)
libusb_free_transfer(transfers[j].transfer);

@@ -3084,7 +3084,7 @@ static int stlink_usb_usb_open(void *handle, struct hl_interface_param_s *param)
h->cmdbuf = malloc(STLINK_SG_SIZE);
h->databuf = malloc(STLINK_DATA_SIZE);

if (h->cmdbuf == NULL || h->databuf == NULL)
if (!h->cmdbuf || !h->databuf)
return ERROR_FAIL;

/*
@@ -3198,7 +3198,7 @@ static int stlink_tcp_open(void *handle, struct hl_interface_param_s *param)
h->tcp_backend_priv.send_buf = malloc(STLINK_TCP_SEND_BUFFER_SIZE);
h->tcp_backend_priv.recv_buf = malloc(STLINK_TCP_RECV_BUFFER_SIZE);

if (h->tcp_backend_priv.send_buf == NULL || h->tcp_backend_priv.recv_buf == NULL)
if (!h->tcp_backend_priv.send_buf || !h->tcp_backend_priv.recv_buf)
return ERROR_FAIL;

h->cmdbuf = &h->tcp_backend_priv.send_buf[8];


+ 1
- 1
src/jtag/drivers/usb_blaster/usb_blaster.c View File

@@ -788,7 +788,7 @@ static int ublast_execute_queue(void)
ublast_initial_wipeout();
}

for (cmd = jtag_command_queue; ret == ERROR_OK && cmd != NULL;
for (cmd = jtag_command_queue; ret == ERROR_OK && cmd;
cmd = cmd->next) {
switch (cmd->type) {
case JTAG_RESET:


+ 4
- 4
src/jtag/drivers/versaloon/usbtoxxx/usbtoxxx.c View File

@@ -171,10 +171,10 @@ RESULT usbtoxxx_execute_command(void)
}

/* get result data */
if (versaloon_pending[i].pos != NULL) {
if (versaloon_pending[i].pos) {
uint8_t processed = 0;

if (versaloon_pending[i].callback != NULL) {
if (versaloon_pending[i].callback) {
versaloon_pending[i].callback(&versaloon_pending[i],
versaloon_buf + usbtoxxx_buffer_index, &processed);
}
@@ -197,10 +197,10 @@ RESULT usbtoxxx_execute_command(void)
versaloon_pending[i].pos = NULL;
}
} else if ((versaloon_pending[i].want_data_size > 0)
&& (versaloon_pending[i].data_buffer != NULL)) {
&& (versaloon_pending[i].data_buffer)) {
uint8_t processed = 0;

if (versaloon_pending[i].callback != NULL) {
if (versaloon_pending[i].callback) {
versaloon_pending[i].callback(&versaloon_pending[i],
versaloon_buf + usbtoxxx_buffer_index, &processed);
}


+ 2
- 2
src/jtag/hla/hla_interface.c View File

@@ -147,7 +147,7 @@ int hl_interface_init_reset(void)

static int hl_interface_khz(int khz, int *jtag_speed)
{
if (hl_if.layout->api->speed == NULL)
if (!hl_if.layout->api->speed)
return ERROR_OK;

*jtag_speed = hl_if.layout->api->speed(hl_if.handle, khz, true);
@@ -162,7 +162,7 @@ static int hl_interface_speed_div(int speed, int *khz)

static int hl_interface_speed(int speed)
{
if (hl_if.layout->api->speed == NULL)
if (!hl_if.layout->api->speed)
return ERROR_OK;

if (!hl_if.handle) {


+ 1
- 1
src/jtag/tcl.c View File

@@ -640,7 +640,7 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
struct jtag_tap_event_action *jteap;
int retval;

for (jteap = tap->event_action; jteap != NULL; jteap = jteap->next) {
for (jteap = tap->event_action; jteap; jteap = jteap->next) {
if (jteap->event != e)
continue;



+ 1
- 1
src/rtos/FreeRTOS.c View File

@@ -531,7 +531,7 @@ static int freertos_get_thread_ascii_info(struct rtos *rtos, threadid_t thread_i

static bool freertos_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
if ((target->rtos->symbols) &&
(target->rtos->symbols[FREERTOS_VAL_PX_READY_TASKS_LISTS].address != 0)) {
/* looks like FreeRTOS */
return true;


+ 1
- 1
src/rtos/ThreadX.c View File

@@ -491,7 +491,7 @@ static int threadx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li

static bool threadx_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
if ((target->rtos->symbols) &&
(target->rtos->symbols[THREADX_VAL_TX_THREAD_CREATED_PTR].address != 0)) {
/* looks like ThreadX */
return true;


+ 2
- 2
src/rtos/chibios.c View File

@@ -500,7 +500,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li
{
*symbol_list = malloc(sizeof(chibios_symbol_list));

if (*symbol_list == NULL)
if (!*symbol_list)
return ERROR_FAIL;

memcpy(*symbol_list, chibios_symbol_list, sizeof(chibios_symbol_list));
@@ -509,7 +509,7 @@ static int chibios_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_li

static bool chibios_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
if ((target->rtos->symbols) &&
((target->rtos->symbols[CHIBIOS_VAL_RLIST].address != 0) ||
(target->rtos->symbols[CHIBIOS_VAL_CH].address != 0))) {



+ 1
- 1
src/rtos/eCos.c View File

@@ -363,7 +363,7 @@ static int ecos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[

static bool ecos_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
if ((target->rtos->symbols) &&
(target->rtos->symbols[ECOS_VAL_THREAD_LIST].address != 0)) {
/* looks like eCos */
return true;


+ 1
- 1
src/rtos/embKernel.c View File

@@ -110,7 +110,7 @@ static const struct embkernel_params embkernel_params_list[] = {

static bool embkernel_detect_rtos(struct target *target)
{
if (target->rtos->symbols != NULL) {
if (target->rtos->symbols) {
if (target->rtos->symbols[SYMBOL_ID_S_CURRENT_TASK].address != 0)
return true;
}


+ 6
- 6
src/rtos/hwthread.c View File

@@ -107,7 +107,7 @@ static int hwthread_update_threads(struct rtos *rtos)

/* determine the number of "threads" */
if (target->smp) {
for (head = target->head; head != NULL; head = head->next) {
for (head = target->head; head; head = head->next) {
struct target *curr = head->target;

if (!target_was_examined(curr))
@@ -123,7 +123,7 @@ static int hwthread_update_threads(struct rtos *rtos)

if (target->smp) {
/* loop over all threads */
for (head = target->head; head != NULL; head = head->next) {
for (head = target->head; head; head = head->next) {
struct target *curr = head->target;

if (!target_was_examined(curr))
@@ -218,7 +218,7 @@ static struct target *hwthread_find_thread(struct target *target, int64_t thread
if (!target)
return NULL;
if (target->smp) {
for (struct target_list *head = target->head; head != NULL; head = head->next) {
for (struct target_list *head = target->head; head; head = head->next) {
if (thread_id == threadid_from_target(head->target))
return head->target;
}
@@ -252,20 +252,20 @@ static int hwthread_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,

int j = 0;
for (int i = 0; i < reg_list_size; i++) {
if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
j++;
}
*rtos_reg_list_size = j;
*rtos_reg_list = calloc(*rtos_reg_list_size, sizeof(struct rtos_reg));
if (*rtos_reg_list == NULL) {
if (!*rtos_reg_list) {
free(reg_list);
return ERROR_FAIL;
}

j = 0;
for (int i = 0; i < reg_list_size; i++) {
if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
(*rtos_reg_list)[j].number = (*reg_list)[i].number;
(*rtos_reg_list)[j].size = (*reg_list)[i].size;


+ 1
- 1
src/rtos/linux.c View File

@@ -639,7 +639,7 @@ static struct threads *liste_add_task(struct threads *task_list, struct threads
{
t->next = NULL;

if (*last == NULL)
if (!*last)
if (!task_list) {
task_list = t;
return task_list;


+ 1
- 1
src/rtos/mqx.c View File

@@ -243,7 +243,7 @@ static bool mqx_detect_rtos(
)
{
if (
(target->rtos->symbols != NULL) &&
(target->rtos->symbols) &&
(target->rtos->symbols[MQX_VAL_MQX_KERNEL_DATA].address != 0)
) {
return true;


+ 1
- 1
src/rtos/nuttx.c View File

@@ -233,7 +233,7 @@ retok:

static bool nuttx_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
if ((target->rtos->symbols) &&
(target->rtos->symbols[0].address != 0) &&
(target->rtos->symbols[1].address != 0)) {
return true;


+ 4
- 4
src/rtos/riot.c View File

@@ -255,7 +255,7 @@ static int riot_update_threads(struct rtos *rtos)
strdup(riot_thread_states[k].desc);
}

if (rtos->thread_details[tasks_found].extra_info_str == NULL) {
if (!rtos->thread_details[tasks_found].extra_info_str) {
LOG_ERROR("RIOT: out of memory");
retval = ERROR_FAIL;
goto error;
@@ -297,7 +297,7 @@ static int riot_update_threads(struct rtos *rtos)
strdup("Enable DEVELHELP to see task names");
}

if (rtos->thread_details[tasks_found].thread_name_str == NULL) {
if (!rtos->thread_details[tasks_found].thread_name_str) {
LOG_ERROR("RIOT: out of memory");
retval = ERROR_FAIL;
goto error;
@@ -364,7 +364,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
{
*symbol_list = calloc(ARRAY_SIZE(riot_symbol_list), sizeof(struct symbol_table_elem));

if (*symbol_list == NULL) {
if (!*symbol_list) {
LOG_ERROR("RIOT: out of memory");
return ERROR_FAIL;
}
@@ -387,7 +387,7 @@ static int riot_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[

static bool riot_detect_rtos(struct target *target)
{
if ((target->rtos->symbols != NULL) &&
if ((target->rtos->symbols) &&
(target->rtos->symbols[RIOT_THREADS_BASE].address != 0)) {
/* looks like RIOT */
return true;


+ 5
- 5
src/rtos/rtos.c View File

@@ -306,13 +306,13 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
struct target *target = get_target_from_connection(connection);

if (strncmp(packet, "qThreadExtraInfo,", 17) == 0) {
if ((target->rtos) && (target->rtos->thread_details != NULL) &&
if ((target->rtos) && (target->rtos->thread_details) &&
(target->rtos->thread_count != 0)) {
threadid_t threadid = 0;
int found = -1;
sscanf(packet, "qThreadExtraInfo,%" SCNx64, &threadid);

if ((target->rtos) && (target->rtos->thread_details != NULL)) {
if ((target->rtos) && (target->rtos->thread_details)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -416,7 +416,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
threadid_t threadid;
int found = -1;
sscanf(packet, "T%" SCNx64, &threadid);
if ((target->rtos) && (target->rtos->thread_details != NULL)) {
if ((target->rtos) && (target->rtos->thread_details)) {
int thread_num;
for (thread_num = 0; thread_num < target->rtos->thread_count; thread_num++) {
if (target->rtos->thread_details[thread_num].threadid == threadid) {
@@ -564,7 +564,7 @@ int rtos_set_reg(struct connection *connection, int reg_num,
struct target *target = get_target_from_connection(connection);
int64_t current_threadid = target->rtos->current_threadid;
if ((target->rtos) &&
(target->rtos->type->set_reg != NULL) &&
(target->rtos->type->set_reg) &&
(current_threadid != -1) &&
(current_threadid != 0)) {
return target->rtos->type->set_reg(target->rtos, reg_num, reg_value);
@@ -657,7 +657,7 @@ static int rtos_try_next(struct target *target)

int rtos_update_threads(struct target *target)
{
if ((target->rtos) && (target->rtos->type != NULL))
if ((target->rtos) && (target->rtos->type))
target->rtos->type->update_threads(target->rtos);
return ERROR_OK;
}


+ 2
- 2
src/rtos/uCOS-III.c View File

@@ -257,7 +257,7 @@ static int ucos_iii_update_thread_offsets(struct rtos *rtos)

static bool ucos_iii_detect_rtos(struct target *target)
{
return target->rtos->symbols != NULL &&
return target->rtos->symbols &&
target->rtos->symbols[UCOS_III_VAL_OS_RUNNING].address != 0;
}

@@ -511,7 +511,7 @@ static int ucos_iii_get_thread_reg_list(struct rtos *rtos, threadid_t threadid,
static int ucos_iii_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[])
{
*symbol_list = calloc(ARRAY_SIZE(ucos_iii_symbol_list), sizeof(struct symbol_table_elem));
if (*symbol_list == NULL) {
if (!*symbol_list) {
LOG_ERROR("uCOS-III: out of memory");
return ERROR_FAIL;
}


+ 1
- 1
src/rtos/zephyr.c View File

@@ -385,7 +385,7 @@ static const struct symbol_table_elem zephyr_symbol_list[] = {

static bool zephyr_detect_rtos(struct target *target)
{
if (target->rtos->symbols == NULL) {
if (!target->rtos->symbols) {
LOG_INFO("Zephyr: no symbols while detecting RTOS");
return false;
}


+ 16
- 16
src/server/gdb_server.c View File

@@ -1043,7 +1043,7 @@ static int gdb_new_connection(struct connection *connection)
}

gdb_actual_connections++;
log_printf_lf(all_targets->next != NULL ? LOG_LVL_INFO : LOG_LVL_DEBUG,
log_printf_lf(all_targets->next ? LOG_LVL_INFO : LOG_LVL_DEBUG,
__FILE__, __LINE__, __func__,
"New GDB Connection: %d, Target %s, state: %s",
gdb_actual_connections,
@@ -1221,7 +1221,7 @@ static int gdb_get_registers_packet(struct connection *connection,
return gdb_error(connection, retval);

for (i = 0; i < reg_list_size; i++) {
if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
reg_packet_size += DIV_ROUND_UP(reg_list[i]->size, 8) * 2;
}
@@ -1235,7 +1235,7 @@ static int gdb_get_registers_packet(struct connection *connection,
reg_packet_p = reg_packet;

for (i = 0; i < reg_list_size; i++) {
if (reg_list[i] == NULL || reg_list[i]->exist == false || reg_list[i]->hidden)
if (!reg_list[i] || reg_list[i]->exist == false || reg_list[i]->hidden)
continue;
if (!reg_list[i]->valid) {
retval = reg_list[i]->type->get(reg_list[i]);
@@ -1792,14 +1792,14 @@ static __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))) void xml_printf(
int first = 1;

for (;; ) {
if ((*xml == NULL) || (!first)) {
if ((!*xml) || (!first)) {
/* start by 0 to exercise all the code paths.
* Need minimum 2 bytes to fit 1 char and 0 terminator. */

*size = *size * 2 + 2;
char *t = *xml;
*xml = realloc(*xml, *size);
if (*xml == NULL) {
if (!*xml) {
free(t);
*retval = ERROR_SERVER_REMOTE_CLOSED;
return;
@@ -1840,7 +1840,7 @@ static int decode_xfer_read(char const *buf, char **annex, int *ofs, unsigned in
/* Extract the annex if needed */
if (annex) {
*annex = strndup(buf, annex_end - buf);
if (*annex == NULL)
if (!*annex)
return ERROR_FAIL;
}

@@ -2059,7 +2059,7 @@ static int lookup_add_arch_defined_types(char const **arch_defined_types_list[],
{
int tbl_sz = *num_arch_defined_types;

if (type_id != NULL && (strcmp(type_id, ""))) {
if (type_id && (strcmp(type_id, ""))) {
for (int j = 0; j < (tbl_sz + 1); j++) {
if (!((*arch_defined_types_list)[j])) {
(*arch_defined_types_list)[tbl_sz++] = type_id;
@@ -2224,8 +2224,8 @@ static int get_reg_features_list(struct target *target, char const **feature_lis
if (reg_list[i]->exist == false || reg_list[i]->hidden)
continue;

if (reg_list[i]->feature != NULL
&& reg_list[i]->feature->name != NULL
if (reg_list[i]->feature
&& reg_list[i]->feature->name
&& (strcmp(reg_list[i]->feature->name, ""))) {
/* We found a feature, check if the feature is already in the
* table. If not, allocate a new entry for the table and
@@ -2322,7 +2322,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
continue;

const char *type_str;
if (reg_list[i]->reg_data_type != NULL) {
if (reg_list[i]->reg_data_type) {
if (reg_list[i]->reg_data_type->type == REG_TYPE_ARCH_DEFINED) {
/* generate <type... first, if there are architecture-defined types. */
if (lookup_add_arch_defined_types(&arch_defined_types,
@@ -2360,7 +2360,7 @@ static int gdb_generate_target_description(struct target *target, char **tdesc_o
xml_printf(&retval, &tdesc, &pos, &size,
" type=\"%s\"", type_str);

if (reg_list[i]->group != NULL)
if (reg_list[i]->group)
xml_printf(&retval, &tdesc, &pos, &size,
" group=\"%s\"", reg_list[i]->group);

@@ -2420,7 +2420,7 @@ static int gdb_get_target_description_chunk(struct target *target, struct target
transfer_type = 'l';

*chunk = malloc(length + 2);
if (*chunk == NULL) {
if (!*chunk) {
LOG_ERROR("Unable to allocate memory");
return ERROR_FAIL;
}
@@ -2543,7 +2543,7 @@ static int gdb_generate_thread_list(struct target *target, char **thread_list_ou
static int gdb_get_thread_list_chunk(struct target *target, char **thread_list,
char **chunk, int32_t offset, uint32_t length)
{
if (*thread_list == NULL) {
if (!*thread_list) {
int retval = gdb_generate_thread_list(target, thread_list);
if (retval != ERROR_OK) {
LOG_ERROR("Unable to Generate Thread List");
@@ -2565,7 +2565,7 @@ static int gdb_get_thread_list_chunk(struct target *target, char **thread_list,
* of strlen(chunk) word access:
* Invalid read of size 4
* Address 0x4479934 is 44 bytes inside a block of size 45 alloc'd */
if (*chunk == NULL) {
if (!*chunk) {
LOG_ERROR("Unable to allocate memory");
return ERROR_FAIL;
}
@@ -2770,7 +2770,7 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p

/* query for vCont supported */
if (parse[0] == '?') {
if (target->type->step != NULL) {
if (target->type->step) {
/* gdb doesn't accept c without C and s without S */
gdb_put_packet(connection, "vCont;c;C;s;S", 13);
return true;
@@ -3007,7 +3007,7 @@ static bool gdb_handle_vrun_packet(struct connection *connection, const char *pa

char *cmdline = next_hex_encoded_field(&parse, ';');
char *arg;
while (cmdline != NULL && (arg = next_hex_encoded_field(&parse, ';')) != NULL) {
while (cmdline && (arg = next_hex_encoded_field(&parse, ';')) != NULL) {
char *new_cmdline = alloc_printf("%s %s", cmdline, arg);
free(cmdline);
free(arg);


+ 4
- 4
src/server/tcl_server.c View File

@@ -298,10 +298,10 @@ COMMAND_HANDLER(handle_tcl_notifications_command)
struct connection *connection = NULL;
struct tcl_connection *tclc = NULL;

if (CMD_CTX->output_handler_priv != NULL)
if (CMD_CTX->output_handler_priv)
connection = CMD_CTX->output_handler_priv;

if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
if (connection && !strcmp(connection->service->name, "tcl")) {
tclc = connection->priv;
return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_notify, "Target Notification output ");
} else {
@@ -315,10 +315,10 @@ COMMAND_HANDLER(handle_tcl_trace_command)
struct connection *connection = NULL;
struct tcl_connection *tclc = NULL;

if (CMD_CTX->output_handler_priv != NULL)
if (CMD_CTX->output_handler_priv)
connection = CMD_CTX->output_handler_priv;

if (connection != NULL && !strcmp(connection->service->name, "tcl")) {
if (connection && !strcmp(connection->service->name, "tcl")) {
tclc = connection->priv;
return CALL_COMMAND_HANDLER(handle_command_parse_bool, &tclc->tc_trace, "Target trace output ");
} else {


+ 2
- 2
src/server/telnet_server.c View File

@@ -199,7 +199,7 @@ static void telnet_save_history(struct telnet_connection *t_con)
i = t_con->current_history + 1;
i %= TELNET_LINE_HISTORY_SIZE;

while (t_con->history[i] == NULL && num > 0) {
while (!t_con->history[i] && num > 0) {
i++;
i %= TELNET_LINE_HISTORY_SIZE;
num--;
@@ -640,7 +640,7 @@ static int telnet_input(struct connection *connection)
/* save only non-blank not repeating lines in the history */
char *prev_line = t_con->history[(t_con->current_history > 0) ?
t_con->current_history - 1 : TELNET_LINE_HISTORY_SIZE-1];
if (*t_con->line && (prev_line == NULL ||
if (*t_con->line && (!prev_line ||
strcmp(t_con->line, prev_line))) {
/* if the history slot is already taken, free it */
free(t_con->history[t_con->next_history]);


+ 1
- 1
src/svf/svf.c View File

@@ -587,7 +587,7 @@ static int svf_getline(char **lineptr, size_t *n, FILE *stream)
#define MIN_CHUNK 16 /* Buffer is increased by this size each time as required */
size_t i = 0;

if (*lineptr == NULL) {
if (!*lineptr) {
*n = MIN_CHUNK;
*lineptr = malloc(*n);
if (!*lineptr)


+ 2
- 2
src/target/aarch64.c View File

@@ -501,7 +501,7 @@ static int update_halt_gdb(struct target *target, enum target_debug_reason debug
}

/* after all targets were updated, poll the gdb serving target */
if (gdb_target != NULL && gdb_target != target)
if (gdb_target && gdb_target != target)
aarch64_poll(gdb_target);

return ERROR_OK;
@@ -2855,7 +2855,7 @@ static int aarch64_jim_configure(struct target *target, struct jim_getopt_info *
return JIM_ERR;
}

if (pc == NULL || pc->cti == NULL) {
if (!pc || !pc->cti) {
Jim_SetResultString(goi->interp, "CTI not configured", -1);
return JIM_ERR;
}


+ 1
- 1
src/target/arc.c View File

@@ -1949,7 +1949,7 @@ static int arc_hit_watchpoint(struct target *target, struct watchpoint **hit_wat
LOG_WARNING("Target halted by breakpoint, but is treated as a watchpoint.");

for (struct watchpoint *watchpoint = target->watchpoints;
watchpoint != NULL;
watchpoint;
watchpoint = watchpoint->next) {
if (actionpoint->bp_value == watchpoint->address) {
*hit_watchpoint = watchpoint;


+ 1
- 1
src/target/arm_adi_v5.c View File

@@ -1028,7 +1028,7 @@ int dap_lookup_cs_component(struct adiv5_ap *ap,
static int dap_read_part_id(struct adiv5_ap *ap, target_addr_t component_base, uint32_t *cid, uint64_t *pid)
{
assert((component_base & 0xFFF) == 0);
assert(ap != NULL && cid != NULL && pid != NULL);
assert(ap && cid && pid);

uint32_t cid0, cid1, cid2, cid3;
uint32_t pid0, pid1, pid2, pid3, pid4;


+ 2
- 2
src/target/arm_adi_v5.h View File

@@ -446,7 +446,7 @@ static inline int dap_queue_dp_write(struct adiv5_dap *dap,
static inline int dap_queue_ap_read(struct adiv5_ap *ap,
unsigned reg, uint32_t *data)
{
assert(ap->dap->ops != NULL);
assert(ap->dap->ops);
return ap->dap->ops->queue_ap_read(ap, reg, data);
}

@@ -462,7 +462,7 @@ static inline int dap_queue_ap_read(struct adiv5_ap *ap,
static inline int dap_queue_ap_write(struct adiv5_ap *ap,
unsigned reg, uint32_t data)
{
assert(ap->dap->ops != NULL);
assert(ap->dap->ops);
return ap->dap->ops->queue_ap_write(ap, reg, data);
}



+ 1
- 1
src/target/armv7a.c View File

@@ -483,7 +483,7 @@ int armv7a_identify_cache(struct target *target)
goto done;

/* if no l2 cache initialize l1 data cache flush function function */
if (armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache == NULL) {
if (!armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache) {
armv7a->armv7a_mmu.armv7a_cache.flush_all_data_cache =
armv7a_cache_auto_flush_all_data;
}


+ 1
- 1
src/target/armv7m.c View File

@@ -474,7 +474,7 @@ int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[],
size = ARMV7M_NUM_CORE_REGS;

*reg_list = malloc(sizeof(struct reg *) * size);
if (*reg_list == NULL)
if (!*reg_list)
return ERROR_FAIL;

for (i = 0; i < size; i++)


+ 4
- 4
src/target/armv8.c View File

@@ -204,7 +204,7 @@ static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regv
break;
}

if (retval == ERROR_OK && regval != NULL)
if (retval == ERROR_OK && regval)
*regval = value_64;
else
retval = ERROR_FAIL;
@@ -430,7 +430,7 @@ static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *re
break;
}

if (retval == ERROR_OK && regval != NULL)
if (retval == ERROR_OK && regval)
*regval = value;

return retval;
@@ -1053,7 +1053,7 @@ COMMAND_HANDLER(armv8_handle_exception_catch_command)
if (n->name)
nsec = n->name;

if (sec == NULL || nsec == NULL) {
if (!sec || !nsec) {
LOG_WARNING("Exception Catch: unknown exception catch configuration: EDECCR = %02" PRIx32, edeccr & 0xff);
return ERROR_FAIL;
}
@@ -1644,7 +1644,7 @@ struct reg_cache *armv8_build_reg_cache(struct target *target)

reg_list[i].reg_data_type = calloc(1, sizeof(struct reg_data_type));
if (reg_list[i].reg_data_type) {
if (armv8_regs[i].data_type == NULL)
if (!armv8_regs[i].data_type)
reg_list[i].reg_data_type->type = armv8_regs[i].type;
else
*reg_list[i].reg_data_type = *armv8_regs[i].data_type;


+ 1
- 1
src/target/armv8_cache.c View File

@@ -417,7 +417,7 @@ int armv8_identify_cache(struct armv8_common *armv8)
armv8->armv8_mmu.armv8_cache.info = 1;

/* if no l2 cache initialize l1 data cache flush function function */
if (armv8->armv8_mmu.armv8_cache.flush_all_data_cache == NULL) {
if (!armv8->armv8_mmu.armv8_cache.flush_all_data_cache) {
armv8->armv8_mmu.armv8_cache.display_cache_info =
armv8_handle_inner_cache_info_command;
armv8->armv8_mmu.armv8_cache.flush_all_data_cache =


+ 2
- 2
src/target/cortex_a.c View File

@@ -704,7 +704,7 @@ static int update_halt_gdb(struct target *target)
}

/* after all targets were updated, poll the gdb serving target */
if (gdb_target != NULL && gdb_target != target)
if (gdb_target && gdb_target != target)
cortex_a_poll(gdb_target);
return retval;
}
@@ -726,7 +726,7 @@ static int cortex_a_poll(struct target *target)
/* the next polling trigger an halt event sent to gdb */
if ((target->state == TARGET_HALTED) && (target->smp) &&
(target->gdb_service) &&
(target->gdb_service->target == NULL)) {
(!target->gdb_service->target)) {
target->gdb_service->target =
get_cortex_a(target, target->gdb_service->core[1]);
target_call_event_callbacks(target, TARGET_EVENT_HALTED);


+ 4
- 4
src/target/esirisc.c View File

@@ -472,7 +472,7 @@ static int esirisc_next_breakpoint(struct target *target)
LOG_DEBUG("-");

for (int bp_index = 0; breakpoints_p < breakpoints_e; ++breakpoints_p, ++bp_index)
if (*breakpoints_p == NULL)
if (!*breakpoints_p)
return bp_index;

return -1;
@@ -608,7 +608,7 @@ static int esirisc_next_watchpoint(struct target *target)
LOG_DEBUG("-");

for (int wp_index = 0; watchpoints_p < watchpoints_e; ++watchpoints_p, ++wp_index)
if (*watchpoints_p == NULL)
if (!*watchpoints_p)
return wp_index;

return -1;
@@ -1267,7 +1267,7 @@ static const char *esirisc_get_gdb_arch(struct target *target)
* requires additional configuration to properly interact with these
* targets in GDB (also see: `esirisc cache_arch`).
*/
if (esirisc->gdb_arch == NULL && target_was_examined(target))
if (!esirisc->gdb_arch && target_was_examined(target))
esirisc->gdb_arch = alloc_printf("esirisc:%d_bit_%d_reg_%s",
esirisc->num_bits, esirisc->num_regs, esirisc_cache_arch_name(esirisc));

@@ -1284,7 +1284,7 @@ static int esirisc_get_gdb_reg_list(struct target *target, struct reg **reg_list
*reg_list_size = ESIRISC_NUM_REGS;

*reg_list = calloc(*reg_list_size, sizeof(struct reg *));
if (*reg_list == NULL)
if (!*reg_list)
return ERROR_FAIL;

if (reg_class == REG_CLASS_ALL)


+ 1
- 1
src/target/esirisc_jtag.c View File

@@ -57,7 +57,7 @@ static int esirisc_jtag_get_padding(void)
int padding = 0;
int bypass_devices = 0;

for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap != NULL;
for (struct jtag_tap *tap = jtag_tap_next_enabled(NULL); tap;
tap = jtag_tap_next_enabled(tap))
if (tap->bypass)
bypass_devices++;


+ 1
- 1
src/target/etm.c View File

@@ -298,7 +298,7 @@ struct reg_cache *etm_build_reg_cache(struct target *target,
reg_list = calloc(128, sizeof(struct reg));
arch_info = calloc(128, sizeof(struct etm_reg));

if (reg_cache == NULL || reg_list == NULL || arch_info == NULL) {
if (!reg_cache || !reg_list || !arch_info) {
LOG_ERROR("No memory");
goto fail;
}


+ 1
- 1
src/target/hla_target.c View File

@@ -202,7 +202,7 @@ static int adapter_target_create(struct target *target,
{
LOG_DEBUG("%s", __func__);
struct adiv5_private_config *pc = target->private_config;
if (pc != NULL && pc->ap_num > 0) {
if (pc && pc->ap_num > 0) {
LOG_ERROR("hla_target: invalid parameter -ap-num (> 0)");
return ERROR_COMMAND_SYNTAX_ERROR;
}


+ 7
- 7
src/target/lakemont.c View File

@@ -381,7 +381,7 @@ struct reg_cache *lakemont_build_reg_cache(struct target *t)
struct reg_feature *feature;
int i;

if (cache == NULL || reg_list == NULL || arch_info == NULL) {
if (!cache || !reg_list || !arch_info) {
free(cache);
free(reg_list);
free(arch_info);
@@ -1013,7 +1013,7 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,
/* running away for a software breakpoint needs some special handling */
uint32_t eip = buf_get_u32(x86_32->cache->reg_list[EIP].value, 0, 32);
bp = breakpoint_find(t, eip);
if (bp != NULL /*&& bp->type == BKPT_SOFT*/) {
if (bp /*&& bp->type == BKPT_SOFT*/) {
/* the step will step over the breakpoint */
if (lakemont_step(t, 0, 0, 1) != ERROR_OK) {
LOG_ERROR("%s stepping over a software breakpoint at 0x%08" PRIx32 " "
@@ -1024,12 +1024,12 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,

/* if breakpoints are enabled, we need to redirect these into probe mode */
struct breakpoint *activeswbp = t->breakpoints;
while (activeswbp != NULL && activeswbp->set == 0)
while (activeswbp && activeswbp->set == 0)
activeswbp = activeswbp->next;
struct watchpoint *activehwbp = t->watchpoints;
while (activehwbp != NULL && activehwbp->set == 0)
while (activehwbp && activehwbp->set == 0)
activehwbp = activehwbp->next;
if (activeswbp != NULL || activehwbp != NULL)
if (activeswbp || activehwbp)
buf_set_u32(x86_32->cache->reg_list[PMCR].value, 0, 32, 1);
if (do_resume(t) != ERROR_OK)
return ERROR_FAIL;
@@ -1054,7 +1054,7 @@ int lakemont_step(struct target *t, int current,
if (check_not_halted(t))
return ERROR_TARGET_NOT_HALTED;
bp = breakpoint_find(t, eip);
if (retval == ERROR_OK && bp != NULL/*&& bp->type == BKPT_SOFT*/) {
if (retval == ERROR_OK && bp/*&& bp->type == BKPT_SOFT*/) {
/* TODO: This should only be done for software breakpoints.
* Stepping from hardware breakpoints should be possible with the resume flag
* Needs testing.
@@ -1105,7 +1105,7 @@ int lakemont_step(struct target *t, int current,
/* try to re-apply the breakpoint, even of step failed
* TODO: When a bp was set, we should try to stop the target - fix the return above
*/
if (bp != NULL/*&& bp->type == BKPT_SOFT*/) {
if (bp/*&& bp->type == BKPT_SOFT*/) {
/* TODO: This should only be done for software breakpoints.
* Stepping from hardware breakpoints should be possible with the resume flag
* Needs testing.


+ 2
- 2
src/target/ls1_sap.c View File

@@ -184,7 +184,7 @@ static int ls1_sap_read_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Reading memory at physical address 0x%" TARGET_PRIxADDR
"; size %" PRIu32 "; count %" PRIu32, address, size, count);

if (count == 0 || buffer == NULL)
if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;

ls1_sap_set_addr_high(target->tap, 0);
@@ -207,7 +207,7 @@ static int ls1_sap_write_memory(struct target *target, target_addr_t address,
"; size %" PRIu32 "; count %" PRIu32, address, size, count);


if (count == 0 || buffer == NULL)
if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;

ls1_sap_set_addr_high(target->tap, 0);


+ 2
- 2
src/target/mem_ap.c View File

@@ -238,7 +238,7 @@ static int mem_ap_read_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Reading memory at physical address " TARGET_ADDR_FMT
"; size %" PRIu32 "; count %" PRIu32, address, size, count);

if (count == 0 || buffer == NULL)
if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;

return mem_ap_read_buf(mem_ap->ap, buffer, size, count, address);
@@ -253,7 +253,7 @@ static int mem_ap_write_memory(struct target *target, target_addr_t address,
LOG_DEBUG("Writing memory at physical address " TARGET_ADDR_FMT
"; size %" PRIu32 "; count %" PRIu32, address, size, count);

if (count == 0 || buffer == NULL)
if (count == 0 || !buffer)
return ERROR_COMMAND_SYNTAX_ERROR;

return mem_ap_write_buf(mem_ap->ap, buffer, size, count, address);


+ 1
- 1
src/target/mips_m4k.c View File

@@ -186,7 +186,7 @@ static int mips_m4k_poll(struct target *target)
/* the next polling trigger an halt event sent to gdb */
if ((target->state == TARGET_HALTED) && (target->smp) &&
(target->gdb_service) &&
(target->gdb_service->target == NULL)) {
(!target->gdb_service->target)) {
target->gdb_service->target =
get_mips_m4k(target, target->gdb_service->core[1]);
target_call_event_callbacks(target, TARGET_EVENT_HALTED);


+ 13
- 13
src/target/nds32_aice.c View File

@@ -24,7 +24,7 @@

int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
{
if (aice->port->api->read_reg_64 == NULL) {
if (!aice->port->api->read_reg_64) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -34,7 +34,7 @@ int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)

int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
{
if (aice->port->api->write_reg_64 == NULL) {
if (!aice->port->api->write_reg_64) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -45,7 +45,7 @@ int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,
target_addr_t *physical_address)
{
if (aice->port->api->read_tlb == NULL) {
if (!aice->port->api->read_tlb) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -55,7 +55,7 @@ int aice_read_tlb(struct aice_port_s *aice, target_addr_t virtual_address,

int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
{
if (aice->port->api->cache_ctl == NULL) {
if (!aice->port->api->cache_ctl) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -65,7 +65,7 @@ int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)

int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
{
if (aice->port->api->set_retry_times == NULL) {
if (!aice->port->api->set_retry_times) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -75,7 +75,7 @@ int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)

int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
{
if (aice->port->api->program_edm == NULL) {
if (!aice->port->api->program_edm) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -86,7 +86,7 @@ int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
int aice_set_command_mode(struct aice_port_s *aice,
enum aice_command_mode command_mode)
{
if (aice->port->api->set_command_mode == NULL) {
if (!aice->port->api->set_command_mode) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -97,7 +97,7 @@ int aice_set_command_mode(struct aice_port_s *aice,
int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
uint32_t instruction_num)
{
if (aice->port->api->execute == NULL) {
if (!aice->port->api->execute) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -107,7 +107,7 @@ int aice_execute(struct aice_port_s *aice, uint32_t *instructions,

int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
{
if (aice->port->api->set_custom_srst_script == NULL) {
if (!aice->port->api->set_custom_srst_script) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -117,7 +117,7 @@ int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)

int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
{
if (aice->port->api->set_custom_trst_script == NULL) {
if (!aice->port->api->set_custom_trst_script) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -127,7 +127,7 @@ int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)

int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
{
if (aice->port->api->set_custom_restart_script == NULL) {
if (!aice->port->api->set_custom_restart_script) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -137,7 +137,7 @@ int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)

int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
{
if (aice->port->api->set_count_to_check_dbger == NULL) {
if (!aice->port->api->set_count_to_check_dbger) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}
@@ -148,7 +148,7 @@ int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_ch
int aice_profiling(struct aice_port_s *aice, uint32_t interval, uint32_t iteration,
uint32_t reg_no, uint32_t *samples, uint32_t *num_samples)
{
if (aice->port->api->profiling == NULL) {
if (!aice->port->api->profiling) {
LOG_WARNING("Not implemented: %s", __func__);
return ERROR_FAIL;
}


+ 1
- 1
src/target/riscv/riscv-013.c View File

@@ -4409,7 +4409,7 @@ void riscv013_clear_abstract_error(struct target *target)
#define COMPLIANCE_TEST(b, message) \
{ \
const char *last_sep = strrchr(__FILE__, FILE_SEP); \
const char *fname = (last_sep == NULL ? __FILE__ : last_sep + 1); \
const char *fname = (!last_sep ? __FILE__ : last_sep + 1); \
LOG_INFO("Executing test %d (%s:%d): %s", total_tests, fname, __LINE__, message); \
int pass = 0; \
if (b) { \


+ 2
- 2
src/target/riscv/riscv.c View File

@@ -2053,7 +2053,7 @@ int riscv_openocd_poll(struct target *target)
unsigned should_remain_halted = 0;
unsigned should_resume = 0;
unsigned i = 0;
for (struct target_list *list = target->head; list != NULL;
for (struct target_list *list = target->head; list;
list = list->next, i++) {
total_targets++;
struct target *t = list->target;
@@ -3059,7 +3059,7 @@ int riscv_count_harts(struct target *target)
if (!target)
return 1;
RISCV_INFO(r);
if (r == NULL || r->hart_count == NULL)
if (!r || !r->hart_count)
return 1;
return r->hart_count(target);
}


+ 1
- 1
src/target/semihosting_common.c View File

@@ -516,7 +516,7 @@ int semihosting_common(struct target *target)
uint64_t addr = semihosting_get_field(target, 0, fields);
size_t size = semihosting_get_field(target, 1, fields);

char *arg = semihosting->cmdline != NULL ?
char *arg = semihosting->cmdline ?
semihosting->cmdline : "";
uint32_t len = strlen(arg) + 1;
if (len > size)


+ 15
- 15
src/target/target.c View File

@@ -1397,7 +1397,7 @@ int target_hit_watchpoint(struct target *target,
return ERROR_TARGET_NOT_HALTED;
}

if (target->type->hit_watchpoint == NULL) {
if (!target->type->hit_watchpoint) {
/* For backward compatible, if hit_watchpoint is not implemented,
* return ERROR_FAIL such that gdb_server will not take the nonsense
* information. */
@@ -1409,7 +1409,7 @@ int target_hit_watchpoint(struct target *target,

const char *target_get_gdb_arch(struct target *target)
{
if (target->type->get_gdb_arch == NULL)
if (!target->type->get_gdb_arch)
return NULL;
return target->type->get_gdb_arch(target);
}
@@ -1573,19 +1573,19 @@ static int target_init_one(struct command_context *cmd_ctx,
type->virt2phys = identity_virt2phys;
}

if (target->type->read_buffer == NULL)
if (!target->type->read_buffer)
target->type->read_buffer = target_read_buffer_default;

if (target->type->write_buffer == NULL)
if (!target->type->write_buffer)
target->type->write_buffer = target_write_buffer_default;

if (target->type->get_gdb_fileio_info == NULL)
if (!target->type->get_gdb_fileio_info)
target->type->get_gdb_fileio_info = target_get_gdb_fileio_info_default;

if (target->type->gdb_fileio_end == NULL)
if (!target->type->gdb_fileio_end)
target->type->gdb_fileio_end = target_gdb_fileio_end_default;

if (target->type->profiling == NULL)
if (!target->type->profiling)
target->type->profiling = target_profiling_default;

return ERROR_OK;
@@ -2120,7 +2120,7 @@ static int target_restore_working_area(struct target *target, struct working_are
{
int retval = ERROR_OK;

if (target->backup_working_area && area->backup != NULL) {
if (target->backup_working_area && area->backup) {
retval = target_write_memory(target, area->address, 4, area->size / 4, area->backup);
if (retval != ERROR_OK)
LOG_ERROR("failed to restore %" PRIu32 " bytes of working area at address " TARGET_ADDR_FMT,
@@ -2555,7 +2555,7 @@ int target_blank_check_memory(struct target *target,
return ERROR_FAIL;
}

if (target->type->blank_check_memory == NULL)
if (!target->type->blank_check_memory)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;

return target->type->blank_check_memory(target, blocks, num_blocks, erased_value);
@@ -3976,7 +3976,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
command_print(cmd, "breakpoint set at " TARGET_ADDR_FMT "", addr);

} else if (addr == 0) {
if (target->type->add_context_breakpoint == NULL) {
if (!target->type->add_context_breakpoint) {
LOG_ERROR("Context breakpoint not available");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
@@ -3986,7 +3986,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
command_print(cmd, "Context breakpoint set at 0x%8.8" PRIx32 "", asid);

} else {
if (target->type->add_hybrid_breakpoint == NULL) {
if (!target->type->add_hybrid_breakpoint) {
LOG_ERROR("Hybrid breakpoint not available");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
@@ -4791,7 +4791,7 @@ void target_handle_event(struct target *target, enum target_event e)
struct target_event_action *teap;
int retval;

for (teap = target->event_action; teap != NULL; teap = teap->next) {
for (teap = target->event_action; teap; teap = teap->next) {
if (teap->event == e) {
LOG_DEBUG("target(%d): %s (%s) event: %d (%s) action: %s",
target->target_number,
@@ -4839,7 +4839,7 @@ bool target_has_event_action(struct target *target, enum target_event event)
{
struct target_event_action *teap;

for (teap = target->event_action; teap != NULL; teap = teap->next) {
for (teap = target->event_action; teap; teap = teap->next) {
if (teap->event == event)
return true;
}
@@ -5729,7 +5729,7 @@ static int target_create(struct jim_getopt_info *goi)
break;
}
}
if (target_types[x] == NULL) {
if (!target_types[x]) {
Jim_SetResultFormatted(goi->interp, "Unknown target type %s, try one of ", cp);
for (x = 0 ; target_types[x] ; x++) {
if (target_types[x + 1]) {
@@ -6154,7 +6154,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)

fastload[i].address = image.sections[i].base_address + offset;
fastload[i].data = malloc(length);
if (fastload[i].data == NULL) {
if (!fastload[i].data) {
free(buffer);
command_print(CMD, "error allocating buffer for section (%" PRIu32 " bytes)",
length);


+ 2
- 2
src/target/target_request.c View File

@@ -234,7 +234,7 @@ int delete_debug_msg_receiver(struct command_context *cmd_ctx, struct target *ta
if (c->cmd_ctx == cmd_ctx) {
*p = next;
free(c);
if (*p == NULL) {
if (!*p) {
/* disable callback */
target->dbg_msg_enabled = 0;
}
@@ -256,7 +256,7 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command)

int receiving = 0;

if (target->type->target_request_data == NULL) {
if (!target->type->target_request_data) {
LOG_ERROR("Target %s does not support target requests", target_name(target));
return ERROR_OK;
}


+ 4
- 4
src/target/x86_32_common.c View File

@@ -75,7 +75,7 @@ int x86_32_get_gdb_reg_list(struct target *t,
*reg_list_size = x86_32->cache->num_regs;
LOG_DEBUG("num_regs=%d, reg_class=%d", (*reg_list_size), reg_class);
*reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
if (*reg_list == NULL) {
if (!*reg_list) {
LOG_ERROR("%s out of memory", __func__);
return ERROR_FAIL;
}
@@ -258,7 +258,7 @@ int x86_32_common_write_phys_mem(struct target *t, target_addr_t phys_address,

/* update the breakpoint */
struct breakpoint *pbiter = t->breakpoints;
while (pbiter != NULL && pbiter->unique_id != iter->swbp_unique_id)
while (pbiter && pbiter->unique_id != iter->swbp_unique_id)
pbiter = pbiter->next;
if (pbiter)
pbiter->orig_instr[0] = buffer[offset];
@@ -456,7 +456,7 @@ int calcaddr_physfromlin(struct target *t, target_addr_t addr, target_addr_t *ph
{
uint8_t entry_buffer[8];

if (physaddr == NULL || t == NULL)
if (!physaddr || !t)
return ERROR_FAIL;

struct x86_32_common *x86_32 = target_to_x86_32(t);
@@ -1113,7 +1113,7 @@ static int unset_swbp(struct target *t, struct breakpoint *bp)
x86_32->swbbp_mem_patch_list = iter->next;
free(iter);
} else {
while (iter->next != NULL && iter->next->swbp_unique_id != bp->unique_id)
while (iter->next && iter->next->swbp_unique_id != bp->unique_id)
iter = iter->next;
if (iter->next) {
/* it's the next one */


+ 1
- 1
src/transport/transport.c View File

@@ -106,7 +106,7 @@ int allow_transports(struct command_context *ctx, const char * const *vector)
* of one transport; C code should be definitive about what
* can be used when all goes well.
*/
if (allowed_transports != NULL || session) {
if (allowed_transports || session) {
LOG_ERROR("Can't modify the set of allowed transports.");