openocd: fix simple cases of NULL comparison

There are more than 1000 NULL comparisons to be aligned to the
coding style.
For recurrent NULL comparison it's preferable using trivial
scripts in order to minimize the review effort.

Patch generated automatically with the command:
	sed -i PATTERN $(find src/ -type f)
where PATTERN is in the list:
	's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
	's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
	's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'

	's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g'
	's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g'
	's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g'

	's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g'
	's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g'
	's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g'

	's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g'
	's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g'
	's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g'

Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6350
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2021-07-03 18:51:20 +02:00
parent b159f5cded
commit 08ee7bb982
166 changed files with 856 additions and 856 deletions

View File

@@ -43,7 +43,7 @@ static int jim_newtap_expected_id(struct jim_nvp *n, struct jim_getopt_info *goi
unsigned expected_len = sizeof(uint32_t) * tap->expected_ids_cnt;
uint32_t *new_expected_ids = malloc(expected_len + sizeof(uint32_t));
if (new_expected_ids == NULL) {
if (!new_expected_ids) {
Jim_SetResultFormatted(goi->interp, "no memory");
return JIM_ERR;
}

View File

@@ -2215,24 +2215,24 @@ static int aice_execute_custom_script(const char *script)
bool set_op;
script_fd = fopen(script, "r");
if (script_fd == NULL) {
if (!script_fd) {
return ERROR_FAIL;
} else {
while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd) != NULL) {
/* execute operations */
set_op = false;
op_str = strstr(line_buffer, "set");
if (op_str != NULL) {
if (op_str) {
set_op = true;
goto get_reset_type;
}
op_str = strstr(line_buffer, "clear");
if (op_str == NULL)
if (!op_str)
continue;
get_reset_type:
reset_str = strstr(op_str, "srst");
if (reset_str != NULL) {
if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_SRST;
else
@@ -2240,7 +2240,7 @@ get_reset_type:
goto get_delay;
}
reset_str = strstr(op_str, "dbgi");
if (reset_str != NULL) {
if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_DBGI;
else
@@ -2248,7 +2248,7 @@ get_reset_type:
goto get_delay;
}
reset_str = strstr(op_str, "trst");
if (reset_str != NULL) {
if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_TRST;
else
@@ -2732,7 +2732,7 @@ static int aice_usb_reset(void)
return ERROR_FAIL;
/* issue TRST */
if (custom_trst_script == NULL) {
if (!custom_trst_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK)
return ERROR_FAIL;
@@ -2755,7 +2755,7 @@ static int aice_issue_srst(uint32_t coreid)
/* After issuing srst, target will be running. So we need to restore EDM_CTL. */
aice_restore_edm_registers(coreid);
if (custom_srst_script == NULL) {
if (!custom_srst_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_SRST) != ERROR_OK)
return ERROR_FAIL;
@@ -2799,7 +2799,7 @@ static int aice_issue_reset_hold(uint32_t coreid)
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4));
/* issue restart */
if (custom_restart_script == NULL) {
if (!custom_restart_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
return ERROR_FAIL;
@@ -2819,7 +2819,7 @@ static int aice_issue_reset_hold(uint32_t coreid)
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status | 0x4);
/* issue restart again */
if (custom_restart_script == NULL) {
if (!custom_restart_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
return ERROR_FAIL;
@@ -3721,7 +3721,7 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence)
/* init strtok() */
command_str = strtok(command_sequence, ";");
if (command_str == NULL)
if (!command_str)
return ERROR_OK;
do {
@@ -3740,14 +3740,14 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence)
reg_name_0 = strstr(command_str, "gen_port0");
reg_name_1 = strstr(command_str, "gen_port1");
if (reg_name_0 != NULL) {
if (reg_name_0) {
data_value = strtoul(reg_name_0 + 9, NULL, 0);
if (aice_write_misc(coreid,
NDS_EDM_MISC_GEN_PORT0, data_value) != ERROR_OK)
return ERROR_FAIL;
} else if (reg_name_1 != NULL) {
} else if (reg_name_1) {
data_value = strtoul(reg_name_1 + 9, NULL, 0);
if (aice_write_misc(coreid,
@@ -3763,7 +3763,7 @@ static int aice_usb_program_edm(uint32_t coreid, char *command_sequence)
/* update command_str */
command_str = strtok(NULL, ";");
} while (command_str != NULL);
} while (command_str);
return ERROR_OK;
}