Skip to content

Commit

Permalink
arch/risc-v: rename local variable name to avoid shadowed declaration
Browse files Browse the repository at this point in the history
In file included from common/addrenv.h:33,
                 from common/riscv_initialstate.c:36:
common/riscv_initialstate.c: In function 'up_initial_state':
common/riscv_internal.h:136:16: warning: declaration of 'regval' shadows a previous local [-Wshadow]
  136 |      uintptr_t regval; \
      |                ^~~~~~
common/riscv_initialstate.c:74:12: note: in expansion of macro 'READ_CSR'
   74 |   regval = READ_CSR(CSR_VLENB);
      |            ^~~~~~~~
common/riscv_initialstate.c:63:13: note: shadowed declaration is here
   63 |   uintptr_t regval;
      |             ^~~~~~

Signed-off-by: chao an <anchao@lixiang.com>
  • Loading branch information
anchao authored and xiaoxiang781216 committed Apr 22, 2024
1 parent 41803a0 commit 4b086f5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arch/risc-v/src/common/riscv_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@

#define READ_CSR(reg) \
({ \
uintptr_t regval; \
__asm__ __volatile__("csrr %0, " __STR(reg) : "=r"(regval)); \
regval; \
uintptr_t __regval; \
__asm__ __volatile__("csrr %0, " __STR(reg) : "=r"(__regval)); \
__regval; \
})

#define READ_AND_SET_CSR(reg, bits) \
({ \
uintptr_t regval; \
__asm__ __volatile__("csrrs %0, " __STR(reg) ", %1": "=r"(regval) : "rK"(bits)); \
regval; \
uintptr_t __regval; \
__asm__ __volatile__("csrrs %0, " __STR(reg) ", %1": "=r"(__regval) : "rK"(bits)); \
__regval; \
})

#define WRITE_CSR(reg, val) \
Expand Down

0 comments on commit 4b086f5

Please sign in to comment.