capstone icon indicating copy to clipboard operation
capstone copied to clipboard

Warn of unused const variables.

Open Rot127 opened this issue 8 months ago • 2 comments

Your checklist for this pull request

  • [ ] I've documented or updated the documentation of every API function and struct this PR changes.
  • [ ] I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

This might indicate a table in the inc files is not in use. And could prevent fixes like https://github.com/capstone-engine/capstone/pull/2665

Test plan

All green

Closing issues

...

Rot127 avatar Mar 29 '25 13:03 Rot127

Quite a lot errors generated in *.inc:

[17/212] Building C object CMakeFiles/cap.../AArch64/AArch64DisassemblerExtension.c.o
FAILED: CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o 
/usr/bin/cc -DCAPSTONE_AARCH64_SUPPORT -DCAPSTONE_ALPHA_SUPPORT -DCAPSTONE_ARC_SUPPORT -DCAPSTONE_ARM_SUPPORT -DCAPSTONE_BPF_SUPPORT -DCAPSTONE_DEBUG -DCAPSTONE_EVM_SUPPORT -DCAPSTONE_HAS_AARCH64 -DCAPSTONE_HAS_ALPHA -DCAPSTONE_HAS_ARC -DCAPSTONE_HAS_ARM -DCAPSTONE_HAS_BPF -DCAPSTONE_HAS_EVM -DCAPSTONE_HAS_HPPA -DCAPSTONE_HAS_LOONGARCH -DCAPSTONE_HAS_M680X -DCAPSTONE_HAS_M68K -DCAPSTONE_HAS_MIPS -DCAPSTONE_HAS_MOS65XX -DCAPSTONE_HAS_POWERPC -DCAPSTONE_HAS_RISCV -DCAPSTONE_HAS_SH -DCAPSTONE_HAS_SPARC -DCAPSTONE_HAS_SYSTEMZ -DCAPSTONE_HAS_TMS320C64X -DCAPSTONE_HAS_TRICORE -DCAPSTONE_HAS_WASM -DCAPSTONE_HAS_X86 -DCAPSTONE_HAS_XCORE -DCAPSTONE_HAS_XTENSA -DCAPSTONE_HPPA_SUPPORT -DCAPSTONE_LOONGARCH_SUPPORT -DCAPSTONE_M680X_SUPPORT -DCAPSTONE_M68K_SUPPORT -DCAPSTONE_MIPS_SUPPORT -DCAPSTONE_MOS65XX_SUPPORT -DCAPSTONE_PPC_SUPPORT -DCAPSTONE_RISCV_SUPPORT -DCAPSTONE_SH_SUPPORT -DCAPSTONE_SPARC_SUPPORT -DCAPSTONE_SYSTEMZ_SUPPORT -DCAPSTONE_TMS320C64X_SUPPORT -DCAPSTONE_TRICORE_SUPPORT -DCAPSTONE_USE_SYS_DYN_MEM -DCAPSTONE_WASM_SUPPORT -DCAPSTONE_X86_SUPPORT -DCAPSTONE_XCORE_SUPPORT -DCAPSTONE_XTENSA_SUPPORT -I/home/jiegec/capstone/include -g -Werror -Wall -Warray-bounds -Wshift-negative-value -Wreturn-type -Wformat -Wmissing-braces -Wunused-function -Wunused-variable -Wparentheses -Wint-in-bool-context -Wmisleading-indentation -Wunused-const-variable -Wno-maybe-uninitialized -Wshadow=local -std=gnu99 -MD -MT CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o -MF CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o.d -o CMakeFiles/capstone.dir/arch/AArch64/AArch64DisassemblerExtension.c.o -c /home/jiegec/capstone/arch/AArch64/AArch64DisassemblerExtension.c
In file included from /home/jiegec/capstone/arch/AArch64/AArch64DisassemblerExtension.c:6:
/home/jiegec/capstone/arch/AArch64/AArch64BaseInfo.h:979:23: error: ‘SVEMaxBitsPerVector’ defined but not used [-Werror=unused-const-variable=]
  979 | static const unsigned SVEMaxBitsPerVector = 2048;
      |                       ^~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64BaseInfo.h:977:23: error: ‘SVEBitsPerBlock’ defined but not used [-Werror=unused-const-variable=]
  977 | static const unsigned SVEBitsPerBlock = 128;
      |                       ^~~~~~~~~~~~~~~
In file included from /home/jiegec/capstone/arch/AArch64/AArch64BaseInfo.h:50:
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:5461:23: error: ‘AArch64RegEncodingTable’ defined but not used [-Werror=unused-const-variable=]
 5461 | static const uint16_t AArch64RegEncodingTable[] = {
      |                       ^~~~~~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:5156:30: error: ‘AArch64MCRegisterClasses’ defined but not used [-Werror=unused-const-variable=]
 5156 | static const MCRegisterClass AArch64MCRegisterClasses[] = {
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:1430:29: error: ‘AArch64RegDesc’ defined but not used [-Werror=unused-const-variable=]
 1430 | static const MCRegisterDesc AArch64RegDesc[] = { // Descriptors
      |                             ^~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:1405:23: error: ‘AArch64SubRegIdxLists’ defined but not used [-Werror=unused-const-variable=]
 1405 | static const uint16_t AArch64SubRegIdxLists[] = {
      |                       ^~~~~~~~~~~~~~~~~~~~~
/home/jiegec/capstone/arch/AArch64/AArch64GenRegisterInfo.inc:1205:24: error: ‘AArch64RegDiffLists’ defined but not used [-Werror=unused-const-variable=]
 1205 | static const MCPhysReg AArch64RegDiffLists[] = {
      |                        ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
[18/212] Building C object CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o
FAILED: CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o 
/usr/bin/cc -DCAPSTONE_AARCH64_SUPPORT -DCAPSTONE_ALPHA_SUPPORT -DCAPSTONE_ARC_SUPPORT -DCAPSTONE_ARM_SUPPORT -DCAPSTONE_BPF_SUPPORT -DCAPSTONE_DEBUG -DCAPSTONE_EVM_SUPPORT -DCAPSTONE_HAS_AARCH64 -DCAPSTONE_HAS_ALPHA -DCAPSTONE_HAS_ARC -DCAPSTONE_HAS_ARM -DCAPSTONE_HAS_BPF -DCAPSTONE_HAS_EVM -DCAPSTONE_HAS_HPPA -DCAPSTONE_HAS_LOONGARCH -DCAPSTONE_HAS_M680X -DCAPSTONE_HAS_M68K -DCAPSTONE_HAS_MIPS -DCAPSTONE_HAS_MOS65XX -DCAPSTONE_HAS_POWERPC -DCAPSTONE_HAS_RISCV -DCAPSTONE_HAS_SH -DCAPSTONE_HAS_SPARC -DCAPSTONE_HAS_SYSTEMZ -DCAPSTONE_HAS_TMS320C64X -DCAPSTONE_HAS_TRICORE -DCAPSTONE_HAS_WASM -DCAPSTONE_HAS_X86 -DCAPSTONE_HAS_XCORE -DCAPSTONE_HAS_XTENSA -DCAPSTONE_HPPA_SUPPORT -DCAPSTONE_LOONGARCH_SUPPORT -DCAPSTONE_M680X_SUPPORT -DCAPSTONE_M68K_SUPPORT -DCAPSTONE_MIPS_SUPPORT -DCAPSTONE_MOS65XX_SUPPORT -DCAPSTONE_PPC_SUPPORT -DCAPSTONE_RISCV_SUPPORT -DCAPSTONE_SH_SUPPORT -DCAPSTONE_SPARC_SUPPORT -DCAPSTONE_SYSTEMZ_SUPPORT -DCAPSTONE_TMS320C64X_SUPPORT -DCAPSTONE_TRICORE_SUPPORT -DCAPSTONE_USE_SYS_DYN_MEM -DCAPSTONE_WASM_SUPPORT -DCAPSTONE_X86_SUPPORT -DCAPSTONE_XCORE_SUPPORT -DCAPSTONE_XTENSA_SUPPORT -I/home/jiegec/capstone/include -g -Werror -Wall -Warray-bounds -Wshift-negative-value -Wreturn-type -Wformat -Wmissing-braces -Wunused-function -Wunused-variable -Wparentheses -Wint-in-bool-context -Wmisleading-indentation -Wunused-const-variable -Wno-maybe-uninitialized -Wshadow=local -std=gnu99 -MD -MT CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o -MF CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o.d -o CMakeFiles/capstone.dir/arch/PowerPC/PPCInstPrinter.c.o -c /home/jiegec/capstone/arch/PowerPC/PPCInstPrinter.c
In file included from /home/jiegec/capstone/arch/PowerPC/PPCInstrInfo.h:7,
                 from /home/jiegec/capstone/arch/PowerPC/PPCInstPrinter.c:39:
/home/jiegec/capstone/arch/PowerPC/PPCMCTargetDesc.h:203:24: error: ‘QFRegs’ defined but not used [-Werror=unused-const-variable=]
  203 | static const MCPhysReg QFRegs[] = {
      |                        ^~~~~~
In file included from /home/jiegec/capstone/arch/PowerPC/PPCMCTargetDesc.h:120:
/home/jiegec/capstone/arch/PowerPC/PPCGenInstrInfo.inc:3059:23: error: ‘PPCImpOpBase’ defined but not used [-Werror=unused-const-variable=]
 3059 | static const unsigned PPCImpOpBase = sizeof(MCOperandInfo) / (sizeof(MCPhysReg));
      |                       ^~~~~~~~~~~~
cc1: all warnings being treated as errors

jiegec avatar Jun 15 '25 02:06 jiegec

Yeah, these clean up tasks have to be done before the Beta as well.

Rot127 avatar Jun 15 '25 11:06 Rot127