From 08ee7bb982b16742f52cfdc6c649d82ffa2eb177 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Sat, 3 Jul 2021 18:51:20 +0200 Subject: 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 Reviewed-on: http://openocd.zylin.com/6350 Tested-by: jenkins --- src/svf/svf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/svf') diff --git a/src/svf/svf.c b/src/svf/svf.c index 10ad7e7..e12fbce 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -302,7 +302,7 @@ static int svf_realloc_buffers(size_t len) static void svf_free_xxd_para(struct svf_xxr_para *para) { - if (NULL != para) { + if (para) { free(para->tdi); para->tdi = NULL; @@ -395,7 +395,7 @@ COMMAND_HANDLER(handle_svf_command) svf_ignore_error = 1; else { svf_fd = fopen(CMD_ARGV[i], "r"); - if (svf_fd == NULL) { + if (!svf_fd) { int err = errno; command_print(CMD, "open(\"%s\"): %s", CMD_ARGV[i], strerror(err)); /* no need to free anything now */ @@ -405,7 +405,7 @@ COMMAND_HANDLER(handle_svf_command) } } - if (svf_fd == NULL) + if (!svf_fd) return ERROR_COMMAND_SYNTAX_ERROR; /* get time */ @@ -417,7 +417,7 @@ COMMAND_HANDLER(handle_svf_command) svf_check_tdo_para_index = 0; svf_check_tdo_para = malloc(sizeof(struct svf_check_tdo_para) * SVF_CHECK_TDO_PARA_SIZE); - if (NULL == svf_check_tdo_para) { + if (!svf_check_tdo_para) { LOG_ERROR("not enough memory"); ret = ERROR_FAIL; goto free_all; @@ -675,7 +675,7 @@ static int svf_read_command_from_file(FILE *fd) if (cmd_pos + 3 > svf_command_buffer_size) { svf_command_buffer = realloc(svf_command_buffer, cmd_pos + 3); svf_command_buffer_size = cmd_pos + 3; - if (svf_command_buffer == NULL) { + if (!svf_command_buffer) { LOG_ERROR("not enough memory"); return ERROR_FAIL; } @@ -1091,7 +1091,7 @@ xxr_common: } /* If TDO is absent, no comparison is needed, set the mask to 0 */ if (!(xxr_para_tmp->data_mask & XXR_TDO)) { - if (NULL == xxr_para_tmp->tdo) { + if (!xxr_para_tmp->tdo) { if (ERROR_OK != svf_adjust_array_length(&xxr_para_tmp->tdo, i_tmp, xxr_para_tmp->len)) { @@ -1099,7 +1099,7 @@ xxr_common: return ERROR_FAIL; } } - if (NULL == xxr_para_tmp->mask) { + if (!xxr_para_tmp->mask) { if (ERROR_OK != svf_adjust_array_length(&xxr_para_tmp->mask, i_tmp, xxr_para_tmp->len)) { @@ -1420,7 +1420,7 @@ xxr_common: if (num_of_argu > 2) { /* STATE pathstate1 ... stable_state */ path = malloc((num_of_argu - 1) * sizeof(tap_state_t)); - if (NULL == path) { + if (!path) { LOG_ERROR("not enough memory"); return ERROR_FAIL; } -- cgit v1.1