From b7708c84e67c6b710cea75e75f5c3994aebe357d Mon Sep 17 00:00:00 2001 From: Mark Zhuang Date: Mon, 28 Oct 2024 22:48:25 +0800 Subject: [PATCH] [NFC] target/riscv: simplify code with MAX macros slightly improves readability --- src/target/riscv/riscv-013.c | 2 +- src/target/riscv/riscv.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 6003064e4..74ce1fceb 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -3566,7 +3566,7 @@ read_memory_abstract(struct target *target, target_addr_t address, uint8_t *p = buffer; int result = ERROR_OK; bool updateaddr = true; - unsigned int width32 = (width < 32) ? 32 : width; + unsigned int width32 = MAX(width, 32); for (uint32_t c = 0; c < count; c++) { /* Update the address if it is the first time or aampostincrement is not supported by the target. */ if (updateaddr) { diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index aa4bc6757..9aa9b4678 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -4086,7 +4086,7 @@ static int parse_ranges(struct list_head *ranges, const char *tcl_arg, const cha return ERROR_COMMAND_SYNTAX_ERROR; } - high = high > low ? high : low; + high = MAX(high, low); if (high > max_val) { LOG_ERROR("Cannot expose %s register number %u, maximum allowed value is %u.", reg_type, high, max_val);