openocd: fix simple cases of Yoda condition
[openocd.git] / src / target / target.c
index 3772f8e3ec3bdbc6147845c86d2b294d97b51715..7dbcadba617af0343bf15396e451602da0f5b154 100644 (file)
@@ -1546,7 +1546,7 @@ static int target_init_one(struct command_context *cmd_ctx,
        assert(type->init_target != NULL);
 
        int retval = type->init_target(cmd_ctx, target);
-       if (ERROR_OK != retval) {
+       if (retval != ERROR_OK) {
                LOG_ERROR("target '%s' init failed", target_name(target));
                return retval;
        }
@@ -1598,7 +1598,7 @@ static int target_init(struct command_context *cmd_ctx)
 
        for (target = all_targets; target; target = target->next) {
                retval = target_init_one(cmd_ctx, target);
-               if (ERROR_OK != retval)
+               if (retval != ERROR_OK)
                        return retval;
        }
 
@@ -1606,12 +1606,12 @@ static int target_init(struct command_context *cmd_ctx)
                return ERROR_OK;
 
        retval = target_register_user_commands(cmd_ctx);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        retval = target_register_timer_callback(&handle_target,
                        polling_interval, TARGET_TIMER_TYPE_PERIODIC, cmd_ctx->interp);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        return ERROR_OK;
@@ -1632,15 +1632,15 @@ COMMAND_HANDLER(handle_target_init_command)
        target_initialized = true;
 
        retval = command_run_line(CMD_CTX, "init_targets");
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        retval = command_run_line(CMD_CTX, "init_target_events");
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        retval = command_run_line(CMD_CTX, "init_board");
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        LOG_DEBUG("Initializing targets...");
@@ -3225,7 +3225,7 @@ COMMAND_HANDLER(handle_wait_halt_command)
        unsigned ms = DEFAULT_HALT_TIMEOUT;
        if (1 == CMD_ARGC) {
                int retval = parse_uint(CMD_ARGV[0], &ms);
-               if (ERROR_OK != retval)
+               if (retval != ERROR_OK)
                        return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
@@ -3281,13 +3281,13 @@ COMMAND_HANDLER(handle_halt_command)
        target->verbose_halt_msg = true;
 
        int retval = target_halt(target);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        if (CMD_ARGC == 1) {
                unsigned wait_local;
                retval = parse_uint(CMD_ARGV[0], &wait_local);
-               if (ERROR_OK != retval)
+               if (retval != ERROR_OK)
                        return ERROR_COMMAND_SYNTAX_ERROR;
                if (!wait_local)
                        return ERROR_OK;
@@ -3482,7 +3482,7 @@ COMMAND_HANDLER(handle_md_command)
 
        struct target *target = get_current_target(CMD_CTX);
        int retval = fn(target, address, size, count, buffer);
-       if (ERROR_OK == retval)
+       if (retval == ERROR_OK)
                target_handle_md_output(CMD, target, address, size, count, buffer);
 
        free(buffer);
@@ -3639,7 +3639,7 @@ COMMAND_HANDLER(handle_load_image_command)
 
        int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV,
                        &image, &min_address, &max_address);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        struct target *target = get_current_target(CMD_CTX);
@@ -3700,7 +3700,7 @@ COMMAND_HANDLER(handle_load_image_command)
                free(buffer);
        }
 
-       if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
+       if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) {
                command_print(CMD, "downloaded %" PRIu32 " bytes "
                                "in %fs (%0.3f KiB/s)", image_size,
                                duration_elapsed(&bench), duration_kbps(&bench, image_size));
@@ -3757,7 +3757,7 @@ COMMAND_HANDLER(handle_dump_image_command)
 
        free(buffer);
 
-       if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
+       if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) {
                size_t filesize;
                retval = fileio_size(fileio, &filesize);
                if (retval != ERROR_OK)
@@ -3902,7 +3902,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, enum verify_mode ver
 done:
        if (diffs > 0)
                retval = ERROR_FAIL;
-       if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
+       if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) {
                command_print(CMD, "verified %" PRIu32 " bytes "
                                "in %fs (%0.3f KiB/s)", image_size,
                                duration_elapsed(&bench), duration_kbps(&bench, image_size));
@@ -3972,7 +3972,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
        if (asid == 0) {
                retval = breakpoint_add(target, addr, length, hw);
                /* error is always logged in breakpoint_add(), do not print it again */
-               if (ERROR_OK == retval)
+               if (retval == ERROR_OK)
                        command_print(cmd, "breakpoint set at " TARGET_ADDR_FMT "", addr);
 
        } else if (addr == 0) {
@@ -3982,7 +3982,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
                }
                retval = context_breakpoint_add(target, asid, length, hw);
                /* error is always logged in context_breakpoint_add(), do not print it again */
-               if (ERROR_OK == retval)
+               if (retval == ERROR_OK)
                        command_print(cmd, "Context breakpoint set at 0x%8.8" PRIx32 "", asid);
 
        } else {
@@ -3992,7 +3992,7 @@ static int handle_bp_command_set(struct command_invocation *cmd,
                }
                retval = hybrid_breakpoint_add(target, addr, asid, length, hw);
                /* error is always logged in hybrid_breakpoint_add(), do not print it again */
-               if (ERROR_OK == retval)
+               if (retval == ERROR_OK)
                        command_print(cmd, "Hybrid breakpoint set at 0x%8.8" PRIx32 "", asid);
        }
        return retval;
@@ -4123,7 +4123,7 @@ COMMAND_HANDLER(handle_wp_command)
 
        int retval = watchpoint_add(target, addr, length, type,
                        data_value, data_mask);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                LOG_ERROR("Failure setting watchpoints");
 
        return retval;
@@ -5871,7 +5871,7 @@ static int target_create(struct jim_getopt_info *goi)
        /* create the target specific commands */
        if (target->type->commands) {
                e = register_commands(cmd_ctx, NULL, target->type->commands);
-               if (ERROR_OK != e)
+               if (e != ERROR_OK)
                        LOG_ERROR("unable to register '%s' commands", cp);
        }
 
@@ -6101,7 +6101,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
 
        int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV,
                        &image, &min_address, &max_address);
-       if (ERROR_OK != retval)
+       if (retval != ERROR_OK)
                return retval;
 
        struct duration bench;
@@ -6173,7 +6173,7 @@ COMMAND_HANDLER(handle_fast_load_image_command)
                free(buffer);
        }
 
-       if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) {
+       if ((retval == ERROR_OK) && (duration_measure(&bench) == ERROR_OK)) {
                command_print(CMD, "Loaded %" PRIu32 " bytes "
                                "in %fs (%0.3f KiB/s)", image_size,
                                duration_elapsed(&bench), duration_kbps(&bench, image_size));

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)