target: use boolean values for 'valid' and 'dirty' flags 61/7961/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 5 Nov 2023 11:55:27 +0000 (12:55 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 18 Nov 2023 11:16:06 +0000 (11:16 +0000)
Convert to boolean the remaining numeric assignment and comparison

Change-Id: Idc25221d93e85236185aab9ee36f0a379939c89c
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7961
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
src/target/arc.c
src/target/etm.c
src/target/mips64.c
src/target/mips_mips64.c

index 45005b29b674deb1f11623adb3d8be975b02f752..0f7b11025d09418b9744aecc0bf4f4caed2a65b7 100644 (file)
@@ -1265,8 +1265,8 @@ static int arc_resume(struct target *target, int current, target_addr_t address,
        /* current = 1: continue on current PC, otherwise continue at <address> */
        if (!current) {
                target_buffer_set_u32(target, pc->value, address);
-               pc->dirty = 1;
-               pc->valid = 1;
+               pc->dirty = true;
+               pc->valid = true;
                LOG_DEBUG("Changing the value of current PC to 0x%08" TARGET_PRIxADDR, address);
        }
 
@@ -1281,7 +1281,7 @@ static int arc_resume(struct target *target, int current, target_addr_t address,
                resume_pc, pc->dirty, pc->valid);
 
        /* check if GDB tells to set our PC where to continue from */
-       if ((pc->valid == 1) && (resume_pc == target_buffer_get_u32(target, pc->value))) {
+       if (pc->valid && resume_pc == target_buffer_get_u32(target, pc->value)) {
                value = target_buffer_get_u32(target, pc->value);
                LOG_DEBUG("resume Core (when start-core) with PC @:0x%08" PRIx32, value);
                CHECK_RETVAL(arc_jtag_write_aux_reg_one(&arc->jtag_info, AUX_PC_REG, value));
@@ -2007,8 +2007,8 @@ static int arc_step(struct target *target, int current, target_addr_t address,
        /* current = 1: continue on current pc, otherwise continue at <address> */
        if (!current) {
                buf_set_u32(pc->value, 0, 32, address);
-               pc->dirty = 1;
-               pc->valid = 1;
+               pc->dirty = true;
+               pc->valid = true;
        }
 
        LOG_DEBUG("Target steps one instruction from PC=0x%" PRIx32,
index 6718875ee98e8c212d2999303bbbe75198ef032f..d083017f71308d43292300d64275bb4a7cdd800d 100644 (file)
@@ -552,8 +552,8 @@ static int etm_set_reg(struct reg *reg, uint32_t value)
        }
 
        buf_set_u32(reg->value, 0, reg->size, value);
-       reg->valid = 1;
-       reg->dirty = 0;
+       reg->valid = true;
+       reg->dirty = false;
 
        return ERROR_OK;
 }
index 37f36855cb6416d2992423f95c9ebb2313be7c24..48f4563dc608340180eba42a14996dfca5357362 100644 (file)
@@ -247,8 +247,8 @@ static int mips64_set_core_reg(struct reg *reg, uint8_t *buf)
                return ERROR_TARGET_NOT_HALTED;
 
        buf_set_u64(reg->value, 0, 64, value);
-       reg->dirty = 1;
-       reg->valid = 1;
+       reg->dirty = true;
+       reg->valid = true;
 
        return ERROR_OK;
 }
@@ -265,8 +265,8 @@ static int mips64_read_core_reg(struct target *target, int num)
 
        reg_value = mips64->core_regs[num];
        buf_set_u64(mips64->core_cache->reg_list[num].value, 0, 64, reg_value);
-       mips64->core_cache->reg_list[num].valid = 1;
-       mips64->core_cache->reg_list[num].dirty = 0;
+       mips64->core_cache->reg_list[num].valid = true;
+       mips64->core_cache->reg_list[num].dirty = false;
 
        return ERROR_OK;
 }
@@ -284,8 +284,8 @@ static int mips64_write_core_reg(struct target *target, int num)
        reg_value = buf_get_u64(mips64->core_cache->reg_list[num].value, 0, 64);
        mips64->core_regs[num] = reg_value;
        LOG_DEBUG("write core reg %i value 0x%" PRIx64 "", num, reg_value);
-       mips64->core_cache->reg_list[num].valid = 1;
-       mips64->core_cache->reg_list[num].dirty = 0;
+       mips64->core_cache->reg_list[num].valid = true;
+       mips64->core_cache->reg_list[num].dirty = false;
 
        return ERROR_OK;
 }
@@ -297,8 +297,8 @@ int mips64_invalidate_core_regs(struct target *target)
        unsigned int i;
 
        for (i = 0; i < mips64->core_cache->num_regs; i++) {
-               mips64->core_cache->reg_list[i].valid = 0;
-               mips64->core_cache->reg_list[i].dirty = 0;
+               mips64->core_cache->reg_list[i].valid = false;
+               mips64->core_cache->reg_list[i].dirty = false;
        }
 
        return ERROR_OK;
index bf6095358faeb457c183f5e6567b14923ab5425f..9921e93807f1512fd2a2ec78d9f00bb71a4c5867 100644 (file)
@@ -625,8 +625,8 @@ static int mips_mips64_resume(struct target *target, int current,
        /* current = 1: continue on current pc, otherwise continue at <address> */
        if (!current) {
                buf_set_u64(pc->value, 0, 64, address);
-               pc->dirty = 1;
-               pc->valid = 1;
+               pc->dirty = true;
+               pc->valid = true;
        }
 
        resume_pc = buf_get_u64(pc->value, 0, 64);
@@ -717,8 +717,8 @@ static int mips_mips64_step(struct target *target, int current,
         * <address> */
        if (!current) {
                buf_set_u64(pc->value, 0, 64, address);
-               pc->dirty = 1;
-               pc->valid = 1;
+               pc->dirty = true;
+               pc->valid = true;
        }
 
        /* the front-end may request us not to handle breakpoints */

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)