diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-03 21:29:32 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-07-24 10:38:00 +0100 |
commit | 391782318723915bd259eadf9469251c13c8fa9c (patch) | |
tree | df5fe28d94e46fd98bf54f47152034db5696f5da /src/helper | |
parent | 08ee7bb982b16742f52cfdc6c649d82ffa2eb177 (diff) | |
download | riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.zip riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.tar.gz riscv-openocd-391782318723915bd259eadf9469251c13c8fa9c.tar.bz2 |
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
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/command.c | 6 | ||||
-rw-r--r-- | src/helper/log.c | 4 | ||||
-rw-r--r-- | src/helper/replacements.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/src/helper/command.c b/src/helper/command.c index b3b53ae..681e870 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -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 diff --git a/src/helper/log.c b/src/helper/log.c index a1b46ef..caa0a66 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -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); } diff --git a/src/helper/replacements.c b/src/helper/replacements.c index 68032b7..86ddd80 100644 --- a/src/helper/replacements.c +++ b/src/helper/replacements.c @@ -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) |