Skip to content

Commit

Permalink
refactor: fix bugprone-branch-clone lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 17, 2024
1 parent a60c09f commit cbc8631
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 25 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Checks: >-
boost*,
bugprone*,
-bugprone-branch-clone,
-bugprone-easily-swappable-parameters,
cert*,
clang-analyzer*,
Expand Down
6 changes: 5 additions & 1 deletion src/interpret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3235,9 +3235,10 @@ static FORCE_INLINE execute_status execute_SFENCE_VMA(STATE_ACCESS &a, uint64_t
return raise_illegal_insn_exception(a, pc, insn);
}
const uint32_t rs1 = insn_get_rs1(insn);
const uint32_t rs2 = insn_get_rs2(insn);
[[maybe_unused]] const uint32_t rs2 = insn_get_rs2(insn);
if (rs1 == 0) {
a.flush_all_tlb();
#ifdef DUMP_COUNTERS
INC_COUNTER(a.get_statistics(), tlb_flush_all);
if (rs2 == 0) {
// Invalidates all address-translation cache entries, for all address spaces
Expand All @@ -3248,9 +3249,11 @@ static FORCE_INLINE execute_status execute_SFENCE_VMA(STATE_ACCESS &a, uint64_t
// except for entries containing global mappings.
INC_COUNTER(a.get_statistics(), tlb_flush_fence_vma_asid);
}
#endif
} else {
const uint64_t vaddr = a.read_x(rs1);
a.flush_tlb_vaddr(vaddr);
#ifdef DUMP_COUNTERS
INC_COUNTER(a.get_statistics(), tlb_flush_vaddr);
if (rs2 == 0) {
// Invalidates all address-translation cache entries that contain leaf page table entries
Expand All @@ -3263,6 +3266,7 @@ static FORCE_INLINE execute_status execute_SFENCE_VMA(STATE_ACCESS &a, uint64_t
// except for entries containing global mappings.
INC_COUNTER(a.get_statistics(), tlb_flush_fence_vma_asid_vaddr);
}
#endif
}
return advance_to_next_insn(a, pc, execute_status::success_and_flush_fetch);
}
Expand Down
11 changes: 4 additions & 7 deletions src/jsonrpc-remote-machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,15 +1601,12 @@ int main(int argc, char *argv[]) try {
}

for (int i = 1; i < argc; i++) {
if (stringval("--server-address=", argv[i], &server_address)) {
;
if (int end = 0; stringval("--server-address=", argv[i], &server_address) ||
stringval("--log-level=", argv[i], &log_level) ||
// NOLINTNEXTLINE(cert-err34-c)
} else if (int end = 0; sscanf(argv[i], "--server-fd=%d%n", &server_fd, &end) == 1 && argv[i][end] == 0) {
;
} else if (stringval("--log-level=", argv[i], &log_level)) {
;
(sscanf(argv[i], "--server-fd=%d%n", &server_fd, &end) == 1 && argv[i][end] == 0) ||
// NOLINTNEXTLINE(cert-err34-c)
} else if (int end = 0; sscanf(argv[i], "--sigusr1=%d%n", &sigusr1, &end) == 1 && argv[i][end] == 0) {
(sscanf(argv[i], "--sigusr1=%d%n", &sigusr1, &end) == 1 && argv[i][end] == 0)) {
;
} else if (strcmp(argv[i], "--help") == 0) {
help(program_name);
Expand Down
2 changes: 0 additions & 2 deletions src/machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ pma_entry &machine::register_pma_entry(pma_entry &&pma) {
static bool DID_is_protected(PMA_ISTART_DID DID) {
switch (DID) {
case PMA_ISTART_DID::flash_drive:
return false;
case PMA_ISTART_DID::cmio_rx_buffer:
return false;
case PMA_ISTART_DID::cmio_tx_buffer:
return false;
default:
Expand Down
11 changes: 4 additions & 7 deletions src/merkle-tree-hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,10 @@ int main(int argc, char *argv[]) {
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--help") == 0) {
help(argv[0]);
} else if (stringval("--input=", argv[i], &input_name)) {
;
} else if (intval("--log2-word-size=", argv[i], &log2_word_size)) {
;
} else if (intval("--log2-leaf-size=", argv[i], &log2_leaf_size)) {
;
} else if (intval("--log2-root-size=", argv[i], &log2_root_size)) {
} else if (stringval("--input=", argv[i], &input_name) ||
intval("--log2-word-size=", argv[i], &log2_word_size) ||
intval("--log2-leaf-size=", argv[i], &log2_leaf_size) ||
intval("--log2-root-size=", argv[i], &log2_root_size)) {
;
} else if (intval("--page-log2-size=", argv[i], &log2_leaf_size)) {
std::cerr << "--page-log2-size is deprecated. "
Expand Down
10 changes: 3 additions & 7 deletions tests/misc/test-merkle-tree-hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,9 @@ int main(int argc, char *argv[]) try {
help(argv[0]);
return 1;
}
if (stringval("--input=", argv[i], &input_name)) {
;
} else if (intval("--log2-word-size=", argv[i], &log2_word_size)) {
;
} else if (intval("--log2-leaf-size=", argv[i], &log2_leaf_size)) {
;
} else if (intval("--log2-root-size=", argv[i], &log2_root_size)) {
if (stringval("--input=", argv[i], &input_name) || intval("--log2-word-size=", argv[i], &log2_word_size) ||
intval("--log2-leaf-size=", argv[i], &log2_leaf_size) ||
intval("--log2-root-size=", argv[i], &log2_root_size)) {
;
} else {
error("unrecognized option '%s'\n", argv[i]);
Expand Down

0 comments on commit cbc8631

Please sign in to comment.