openocd: fix simple cases of NULL comparison
[openocd.git] / src / jtag / tcl.c
index b765305e521edcdad6e2467376ee84939ca32b63..af2f149b09d9627453a01adf5a8b01039817a4e8 100644 (file)
@@ -62,9 +62,9 @@ struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
 {
        const char *cp = Jim_GetString(o, NULL);
        struct jtag_tap *t = cp ? jtag_tap_by_string(cp) : NULL;
-       if (NULL == cp)
+       if (!cp)
                cp = "(unknown)";
-       if (NULL == t)
+       if (!t)
                Jim_SetResultFormatted(interp, "Tap '%s' could not be found", cp);
        return t;
 }
@@ -133,7 +133,7 @@ static int jim_command_drscan(Jim_Interp *interp, int argc, Jim_Obj * const *arg
                /* get arg as a string. */
                cp = Jim_GetString(args[i], NULL);
                /* is it the magic? */
-               if (0 == strcmp("-endstate", cp)) {
+               if (strcmp("-endstate", cp) == 0) {
                        /* is the statename valid? */
                        cp = Jim_GetString(args[i + 1], NULL);
 
@@ -162,7 +162,7 @@ static int jim_command_drscan(Jim_Interp *interp, int argc, Jim_Obj * const *arg
        assert(e == JIM_OK);
 
        tap = jtag_tap_by_jim_obj(interp, args[1]);
-       if (tap == NULL)
+       if (!tap)
                return JIM_ERR;
 
        num_fields = (argc-2)/2;
@@ -362,7 +362,7 @@ static int jtag_tap_configure_event(struct jim_getopt_info *goi, struct jtag_tap
        if (goi->isconfigure) {
                if (!found)
                        jteap = calloc(1, sizeof(*jteap));
-               else if (NULL != jteap->body)
+               else if (jteap->body)
                        Jim_DecrRefCount(goi->interp, jteap->body);
 
                jteap->interp = goi->interp;
@@ -597,7 +597,7 @@ static int jim_newtap_cmd(struct jim_getopt_info *goi)
                            break;
                    case NTAP_OPT_EXPECTED_ID:
                            e = jim_newtap_expected_id(n, goi, tap);
-                           if (JIM_OK != e) {
+                           if (e != JIM_OK) {
                                    free(cp);
                                    free(tap);
                                    return e;
@@ -607,7 +607,7 @@ static int jim_newtap_cmd(struct jim_getopt_info *goi)
                    case NTAP_OPT_IRMASK:
                    case NTAP_OPT_IRCAPTURE:
                            e = jim_newtap_ir_param(n, goi, tap);
-                           if (JIM_OK != e) {
+                           if (e != JIM_OK) {
                                    free(cp);
                                    free(tap);
                                    return e;
@@ -769,7 +769,7 @@ int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        struct jtag_tap *t;
 
        t = jtag_tap_by_jim_obj(goi.interp, goi.argv[0]);
-       if (t == NULL)
+       if (!t)
                return JIM_ERR;
 
        if (strcasecmp(cmd_name, "tapisenabled") == 0) {
@@ -811,7 +811,7 @@ int jim_jtag_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        Jim_Obj *o;
        jim_getopt_obj(&goi, &o);
        t = jtag_tap_by_jim_obj(goi.interp, o);
-       if (t == NULL)
+       if (!t)
                return JIM_ERR;
 
        return jtag_tap_configure_cmd(&goi, t);
@@ -1041,13 +1041,13 @@ COMMAND_HANDLER(handle_jtag_rclk_command)
                COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz);
 
                retval = jtag_config_rclk(khz);
-               if (ERROR_OK != retval)
+               if (retval != ERROR_OK)
                        return retval;
        }
 
        int cur_khz = jtag_get_speed_khz();
        retval = jtag_get_speed_readable(&cur_khz);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        if (cur_khz)
@@ -1122,7 +1122,7 @@ COMMAND_HANDLER(handle_irscan_command)
        int retval;
        for (i = 0; i < num_fields; i++) {
                tap = jtag_tap_by_string(CMD_ARGV[i*2]);
-               if (tap == NULL) {
+               if (!tap) {
                        free(fields);
                        command_print(CMD, "Tap: %s unknown", CMD_ARGV[i*2]);
 
@@ -1130,7 +1130,7 @@ COMMAND_HANDLER(handle_irscan_command)
                }
                uint64_t value;
                retval = parse_u64(CMD_ARGV[i * 2 + 1], &value);
-               if (ERROR_OK != retval)
+               if (retval != ERROR_OK)
                        goto error_return;
 
                int field_size = tap->ir_length;

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)