Skip to content

Commit 03e0113

Browse files
committed
Replace "else if" with "if" in clint.c
Enhance coding style by replacing "else if" with "if". Since it will return true if it fulfills the condition of the "if" statement.
1 parent d3c57d5 commit 03e0113

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

clint.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ static bool clint_reg_read(clint_state_t *clint, uint32_t addr, uint32_t *value)
2121
if (addr < 0x4000) {
2222
*value = clint->msip[addr >> 2];
2323
return true;
24-
} else if (addr < 0xBFF8) {
24+
}
25+
26+
if (addr < 0xBFF8) {
2527
addr -= 0x4000;
2628
*value =
2729
(uint32_t) (clint->mtimecmp[addr >> 3] >> (32 & -!!(addr & 0b100)));
2830
return true;
29-
} else if (addr < 0xBFFF) {
31+
}
32+
33+
if (addr < 0xBFFF) {
3034
*value = clint->mtime >> (32 & -!!(addr & 0b100));
3135
return true;
3236
}
@@ -38,7 +42,9 @@ static bool clint_reg_write(clint_state_t *clint, uint32_t addr, uint32_t value)
3842
if (addr < 0x4000) {
3943
clint->msip[addr >> 2] = value;
4044
return true;
41-
} else if (addr < 0xBFF8) {
45+
}
46+
47+
if (addr < 0xBFF8) {
4248
addr -= 0x4000;
4349
int32_t upper = clint->mtimecmp[addr >> 3] >> 32;
4450
int32_t lowwer = clint->mtimecmp[addr >> 3];
@@ -49,7 +55,9 @@ static bool clint_reg_write(clint_state_t *clint, uint32_t addr, uint32_t value)
4955

5056
clint->mtimecmp[addr >> 3] = (uint64_t) upper << 32 | lowwer;
5157
return true;
52-
} else if (addr < 0xBFFF) {
58+
}
59+
60+
if (addr < 0xBFFF) {
5361
int32_t upper = clint->mtime >> 32;
5462
int32_t lowwer = clint->mtime;
5563
if (addr & 0b100)

0 commit comments

Comments
 (0)