openocd: manually fix Yoda conditions
[openocd.git] / src / target / riscv / riscv-013.c
index 8558ba8915c61b99eb556014c3b42a18b9d3ca3b..b93e5494a859e5b9d7ce17af1b43b211c13123a2 100644 (file)
@@ -86,8 +86,6 @@ static int    riscv013_test_compliance(struct target *target);
 #define get_field(reg, mask) (((reg) & (mask)) / ((mask) & ~((mask) << 1)))
 #define set_field(reg, mask, val) (((reg) & ~(mask)) | (((val) * ((mask) & ~((mask) << 1))) & (mask)))
 
-#define DIM(x)         (sizeof(x)/sizeof(*x))
-
 #define CSR_DCSR_CAUSE_SWBP            1
 #define CSR_DCSR_CAUSE_TRIGGER 2
 #define CSR_DCSR_CAUSE_DEBUGINT        3
@@ -358,7 +356,7 @@ static void decode_dmi(char *text, unsigned address, unsigned data)
        };
 
        text[0] = 0;
-       for (unsigned i = 0; i < DIM(description); i++) {
+       for (unsigned i = 0; i < ARRAY_SIZE(description); i++) {
                if (description[i].address == address) {
                        uint64_t mask = description[i].mask;
                        unsigned value = get_field(data, mask);
@@ -547,13 +545,15 @@ static dmi_status_t dmi_scan(struct target *target, uint32_t *address_in,
 }
 
 /**
+ * @param target
  * @param data_in  The data we received from the target.
- * @param dmi_op   The operation to perform (read/write/nop).
  * @param dmi_busy_encountered
  *                 If non-NULL, will be updated to reflect whether DMI busy was
  *                 encountered while executing this operation or not.
+ * @param dmi_op   The operation to perform (read/write/nop).
  * @param address  The address argument to that operation.
  * @param data_out The data to send to the target.
+ * @param timeout_sec
  * @param exec     When true, this scan will execute something, so extra RTI
  *                 cycles may be added.
  * @param ensure_success
@@ -4653,10 +4653,10 @@ int riscv013_test_compliance(struct target *target)
        for (unsigned int i = 1; i < 32; i = i << 1) {
                riscv_reg_t testval =   i | ((i + 1ULL) << 32);
                riscv_reg_t testval_read;
-               COMPLIANCE_TEST(ERROR_OK == register_write_direct(target, GDB_REGNO_ZERO + i, testval),
+               COMPLIANCE_TEST(register_write_direct(target, GDB_REGNO_ZERO + i, testval) == ERROR_OK,
                                "GPR Writes should be supported.");
                COMPLIANCE_MUST_PASS(write_abstract_arg(target, 0, 0xDEADBEEFDEADBEEF, 64));
-               COMPLIANCE_TEST(ERROR_OK == register_read_direct(target, &testval_read, GDB_REGNO_ZERO + i),
+               COMPLIANCE_TEST(register_read_direct(target, &testval_read, GDB_REGNO_ZERO + i) == ERROR_OK,
                                "GPR Reads should be supported.");
                if (riscv_xlen(target) > 32) {
                        /* Dummy comment to satisfy linter, since removing the branches here doesn't actually compile. */
@@ -4680,7 +4680,7 @@ int riscv013_test_compliance(struct target *target)
                if (info->progbufsize >= 3) {
 
                        testvar = 0;
-                       COMPLIANCE_TEST(ERROR_OK == register_write_direct(target, GDB_REGNO_S0, 0),
+                       COMPLIANCE_TEST(register_write_direct(target, GDB_REGNO_S0, 0) == ERROR_OK,
                                        "Need to be able to write S0 to test ABSTRACTAUTO");
                        struct riscv_program program;
                        COMPLIANCE_MUST_PASS(riscv_program_init(&program, target));
@@ -4721,7 +4721,7 @@ int riscv013_test_compliance(struct target *target)
                        }
 
                        COMPLIANCE_WRITE(target, DM_ABSTRACTAUTO, 0);
-                       COMPLIANCE_TEST(ERROR_OK == register_read_direct(target, &value, GDB_REGNO_S0),
+                       COMPLIANCE_TEST(register_read_direct(target, &value, GDB_REGNO_S0) == ERROR_OK,
                                        "Need to be able to read S0 to test ABSTRACTAUTO");
 
                        COMPLIANCE_TEST(testvar == value,
@@ -4797,8 +4797,8 @@ int riscv013_test_compliance(struct target *target)
        /* Pulse reset. */
        target->reset_halt = true;
        COMPLIANCE_MUST_PASS(riscv_set_current_hartid(target, 0));
-       COMPLIANCE_TEST(ERROR_OK == assert_reset(target), "Must be able to assert NDMRESET");
-       COMPLIANCE_TEST(ERROR_OK == deassert_reset(target), "Must be able to deassert NDMRESET");
+       COMPLIANCE_TEST(assert_reset(target) == ERROR_OK, "Must be able to assert NDMRESET");
+       COMPLIANCE_TEST(deassert_reset(target) == ERROR_OK, "Must be able to deassert NDMRESET");
 
        /* Verify that most stuff is not affected by ndmreset. */
        COMPLIANCE_READ(target, &testvar_read, DM_ABSTRACTCS);

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)