sim/erc32: fix -Wunused-but-set-global errors
Removes unused variables and marks others as unused in the erc32 simulator to fix compiler warnings.
This patch addresses compiler warnings (-Wunused-but-set-global) in the ERC32 simulator. It removes two variables, mec_icr and posted_irq, as they are always initialized to zero and never used. Additionally, uarta_data and uartb_data are only read when FAST_UART is not defined, but the simulator is typically built with FAST_UART enabled. These variables are marked with ATTRIBUTE_UNUSED to suppress warnings, similar to other unused functions in the same situation. This cleans up the codebase and resolves compiler warnings.
- proposer
Submits a patch to fix unused variable warnings in the erc32 simulator by removing unused variables and marking others as unused.
“Building the erc32 simulator with a recent clang fails with: /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:159:19: error: variable 'mec_icr' set but not used [-Werror,-Wunused-but-set-global] /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:165:19: error: variable 'posted_irq' set but not used [-Werror,-Wunused-but-set-global] /home/smarchi/src/binutils-gdb/sim/erc32/erc32.c:247:1…”
In Details
This patch modifies the ERC32 simulator code (sim/erc32/erc32.c) to resolve compiler warnings related to unused variables. The variables mec_icr and posted_irq were found to be always initialized to zero in mec_reset and never subsequently used, so they are removed. The UART data variables (uarta_data, uartb_data) are only accessed when the FAST_UART macro is not defined. Since the simulator is usually built with FAST_UART enabled, these variables are effectively unused in the common build configuration. They are therefore marked with ATTRIBUTE_UNUSED to suppress compiler wa…
- simulator
- A program that mimics the behavior of a hardware device or system. In this context, it simulates the execution of instructions for a specific processor.
- ERC32
- A SPARC-based System-on-Chip (SoC) processor often used in space applications. Binutils includes a simulator for it.
- FAST_UART
- A preprocessor macro that likely enables a faster, possibly simplified, implementation of UART (Universal Asynchronous Receiver/Transmitter) simulation in the ERC32 simulator.
- ATTRIBUTE_UNUSED
- A compiler attribute used to indicate that a function or variable may be intentionally unused. This suppresses compiler warnings about such symbols.
- UART
- Universal Asynchronous Receiver/Transmitter, a hardware component that handles serial communication between devices.