target/lakemont: fix dead assignment
[openocd.git] / src / target / lakemont.c
index e3f331d13ad950ee03c46214312ff4a4e3e5a914..e46ee5cf83f09d29cd9170835e6c4212d2b336d2 100644 (file)
@@ -381,7 +381,7 @@ struct reg_cache *lakemont_build_reg_cache(struct target *t)
        struct reg_feature *feature;
        int i;
 
-       if (cache == NULL || reg_list == NULL || arch_info == NULL) {
+       if (!cache || !reg_list || !arch_info) {
                free(cache);
                free(reg_list);
                free(arch_info);
@@ -611,7 +611,7 @@ static int read_all_core_hw_regs(struct target *t)
        unsigned i;
        struct x86_32_common *x86_32 = target_to_x86_32(t);
        for (i = 0; i < (x86_32->cache->num_regs); i++) {
-               if (NOT_AVAIL_REG == regs[i].pm_idx)
+               if (regs[i].pm_idx == NOT_AVAIL_REG)
                        continue;
                err = read_hw_reg(t, regs[i].id, &regval, 1);
                if (err != ERROR_OK) {
@@ -630,7 +630,7 @@ static int write_all_core_hw_regs(struct target *t)
        unsigned i;
        struct x86_32_common *x86_32 = target_to_x86_32(t);
        for (i = 0; i < (x86_32->cache->num_regs); i++) {
-               if (NOT_AVAIL_REG == regs[i].pm_idx)
+               if (regs[i].pm_idx == NOT_AVAIL_REG)
                        continue;
                err = write_hw_reg(t, i, 0, 1);
                if (err != ERROR_OK) {
@@ -1013,7 +1013,7 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,
                /* running away for a software breakpoint needs some special handling */
                uint32_t eip = buf_get_u32(x86_32->cache->reg_list[EIP].value, 0, 32);
                bp = breakpoint_find(t, eip);
-               if (bp != NULL /*&& bp->type == BKPT_SOFT*/) {
+               if (bp /*&& bp->type == BKPT_SOFT*/) {
                        /* the step will step over the breakpoint */
                        if (lakemont_step(t, 0, 0, 1) != ERROR_OK) {
                                LOG_ERROR("%s stepping over a software breakpoint at 0x%08" PRIx32 " "
@@ -1024,12 +1024,12 @@ int lakemont_resume(struct target *t, int current, target_addr_t address,
 
                /* if breakpoints are enabled, we need to redirect these into probe mode */
                struct breakpoint *activeswbp = t->breakpoints;
-               while (activeswbp != NULL && activeswbp->set == 0)
+               while (activeswbp && activeswbp->set == 0)
                        activeswbp = activeswbp->next;
                struct watchpoint *activehwbp = t->watchpoints;
-               while (activehwbp != NULL && activehwbp->set == 0)
+               while (activehwbp && activehwbp->set == 0)
                        activehwbp = activehwbp->next;
-               if (activeswbp != NULL || activehwbp != NULL)
+               if (activeswbp || activehwbp)
                        buf_set_u32(x86_32->cache->reg_list[PMCR].value, 0, 32, 1);
                if (do_resume(t) != ERROR_OK)
                        return ERROR_FAIL;
@@ -1054,7 +1054,7 @@ int lakemont_step(struct target *t, int current,
        if (check_not_halted(t))
                return ERROR_TARGET_NOT_HALTED;
        bp = breakpoint_find(t, eip);
-       if (retval == ERROR_OK && bp != NULL/*&& bp->type == BKPT_SOFT*/) {
+       if (retval == ERROR_OK && bp/*&& bp->type == BKPT_SOFT*/) {
                /* TODO: This should only be done for software breakpoints.
                 * Stepping from hardware breakpoints should be possible with the resume flag
                 * Needs testing.
@@ -1070,7 +1070,8 @@ int lakemont_step(struct target *t, int current,
        LOG_DEBUG("EFLAGS [TF] [RF] bits set=0x%08" PRIx32 ", PMCR=0x%08" PRIx32 ", EIP=0x%08" PRIx32,
                        eflags, pmcr, eip);
 
-       tapstatus = get_tapstatus(t);
+       /* Returned value unused. Can this line be removed? */
+       get_tapstatus(t);
 
        t->debug_reason = DBG_REASON_SINGLESTEP;
        t->state = TARGET_DEBUG_RUNNING;
@@ -1105,7 +1106,7 @@ int lakemont_step(struct target *t, int current,
        /* try to re-apply the breakpoint, even of step failed
         * TODO: When a bp was set, we should try to stop the target - fix the return above
         */
-       if (bp != NULL/*&& bp->type == BKPT_SOFT*/) {
+       if (bp/*&& bp->type == BKPT_SOFT*/) {
                /* TODO: This should only be done for software breakpoints.
                 * Stepping from hardware breakpoints should be possible with the resume flag
                 * Needs testing.

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)