openocd: fix simple cases of NULL comparison
[openocd.git] / src / helper / log.c
index b39cb9136ae70de8ea5c608c33e053dcaf66f1c4..a1b46efd0ee9ec2f0a797cd84864da3663c1bb49 100644 (file)
@@ -108,7 +108,7 @@ static void log_puts(enum log_levels level,
        }
 
        f = strrchr(file, '/');
-       if (f != NULL)
+       if (f)
                file = f + 1;
 
        if (strlen(string) > 0) {
@@ -163,7 +163,7 @@ void log_printf(enum log_levels level,
        va_start(ap, format);
 
        string = alloc_vprintf(format, ap);
-       if (string != NULL) {
+       if (string) {
                log_puts(level, file, line, function, string);
                free(string);
        }
@@ -240,7 +240,7 @@ COMMAND_HANDLER(handle_log_output_command)
        }
        if (CMD_ARGC == 1) {
                FILE *file = fopen(CMD_ARGV[0], "w");
-               if (file == NULL) {
+               if (!file) {
                        LOG_ERROR("failed to open output log '%s'", CMD_ARGV[0]);
                        return ERROR_FAIL;
                }
@@ -287,7 +287,7 @@ void log_init(void)
        /* set defaults for daemon configuration,
         * if not set by cmdline or cfgfile */
        char *debug_env = getenv("OPENOCD_DEBUG_LEVEL");
-       if (NULL != debug_env) {
+       if (debug_env) {
                int value;
                int retval = parse_int(debug_env, &value);
                if (retval == ERROR_OK &&
@@ -296,7 +296,7 @@ void log_init(void)
                                debug_level = value;
        }
 
-       if (log_output == NULL)
+       if (!log_output)
                log_output = stderr;
 
        start = last_time = timeval_ms();
@@ -322,7 +322,7 @@ int log_add_callback(log_callback_fn fn, void *priv)
        /* alloc memory, it is safe just to return in case of an error, no need for the caller to
         *check this */
        cb = malloc(sizeof(struct log_callback));
-       if (cb == NULL)
+       if (!cb)
                return ERROR_BUF_TOO_SMALL;
 
        /* add item to the beginning of the linked list */
@@ -367,7 +367,7 @@ char *alloc_vprintf(const char *fmt, va_list ap)
         * other code depend on that. They should be probably be fixed, but for
         * now reserve the extra byte. */
        string = malloc(len + 2);
-       if (string == NULL)
+       if (!string)
                return NULL;
 
        /* do the real work */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)