vanvught / rpidmx512

Orange Pi DMX512 / RDM / MIDI / OSC / Art-Net / WS28xx / L6470 / Stepper / TLC59711 / PCA9685 / Servo / PWM / TCNet / SMPTE / RDMNet / LLRP / GD32 / GigaDevice / Raspberry Pi
http://www.orangepi-dmx.org/
MIT License
386 stars 109 forks source link

cppcheck: (error) Shifting signed 32-bit value by 31 bits is undefined #70

Closed vanvught closed 4 years ago

vanvught commented 4 years ago

cppcheck --includes-file=cppcheck.includes-file --file-list=cppcheck.file-list -DDEBUG=1 -DH3=1 -DORANGE_PI=1 2> ./cpp_check.txt

[lib-display/include/displayset.h:39]: (error) Code 'classDisplaySet{' is invalid C code. Use --std or --language to configure the language.
[lib-debug/src/debug_print_bits.c:32]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-dmx/src/rpi/dmx.c:49]: (error) #error 
[lib-h3/include/h3_gpio.h:35]: (error) syntax error
[lib-esp8266/src/h3/esp8266.c:66]: (error) #error PORT_CIN not defined
[lib-h3/src/h3_codec.c:251]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_codec.c:266]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_codec.c:276]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:170]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:260]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:268]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:306]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:320]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:400]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:444]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:487]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_spi.c:512]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_thermal.c:114]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/src/h3_timer.c:42]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-hal/src/h3/hardware.c:158]: (error) #error Not a recognized/ tested FatFs version
[lib-hal/src/rpi/hardware.c:100]: (error) #error Not a recognized/ tested FatFs version
[lib-hal/src/rpi/hardware_rtc.c:55]: (error) Uninitialized struct member: tm_rtc.tm_wday
[lib-network/src/circle/networkcircle.cpp:100]: (error) #error CIRCLE_MAJOR_VERSION not defined
[lib-nextion/src/._handlerawdata.cpp:1]: (error) The code contains unhandled character(s) (character code=176). Neither unicode nor extended ascii is supported.
[lib-nextion/src/._sc16is740.cpp:1]: (error) The code contains unhandled character(s) (character code=176). Neither unicode nor extended ascii is supported.
[lib-spiflash/src/h3/spi_flash.c:82]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
vanvught commented 4 years ago

The gcc compiler does generate the correct output. This is mostly a cleanup action. It would make the code easier to maintain not having unneeded error's generated by cppcheck

pi@nuc-i5:~/workspace$ find . -name *.h | xargs grep '<< 31'
./lib-h3/src/h3_spi_internal.h:#define GC_SRST                  (1 << 31)       ///< Soft Reset
./lib-h3/src/h3_spi_internal.h:#define TC_XCH                   (1 << 31)       ///< Initiate transfer
./lib-h3/src/h3_spi_internal.h:#define FC_TX_RST                (1 << 31)       ///< TX FIFO Reset
./lib-h3/src/h3_spi_internal.h:#define FS_TB_WR         (1 << 31)       ///< TX FIFO Write Buffer Write Enable
./lib-h3/include/h3_ccu.h:#define CCU_THS_CLK_SCLK_GATING               (1 << 31)
pi@nuc-i5:/development/workspace$ find . -name *.c | xargs grep '<< 31)'
./lib-spiflash/src/h3/spi_flash.c:      H3_CCU->SPI0_CLK = (1 << 31) | (0x01 << 24); // Clock is ON, P0
./lib-h3/device/emac/emac.c:#define TX_CTL0_TX_EN                               (1 << 31)
./lib-h3/device/emac/emac.c:#define RX_CTL0_RX_EN                               (1 << 31)
./lib-h3/device/emac/emac.c:            desc_p->status = (1 << 31);
./lib-h3/device/emac/emac.c:            desc_p->status = (1 << 31);
./lib-h3/device/emac/emac.c:    if (!(status & (1 << 31))) {
./lib-h3/device/emac/emac.c:    desc_p->st |= (1 << 31);
./lib-h3/device/emac/emac.c:    desc_p->status = (1 << 31);
./lib-h3/device/emac/emac.c:    value |= (1 << 31);/* mandatory */
./lib-h3/device/emac/emac.c:    desc_p->status |= (1 << 31);
./lib-h3/device/mmc/mmc.c:      cmd.cmdarg = (mode << 31) | 0xffffff;
./lib-h3/device/mmc/mmc_bsp.c:#define SDMMC_CLK_SCLK_GATING             (1 << 31)       ///< 1 = Clock is ON. SCLK = Clock source/Divider N/ Divider M
./lib-h3/device/mmc/mmc_bsp.c:#define GCTL_FIFO_AC_MODE_AHB     (1 << 31)       ///< FIFO Access Mode AHB bus
./lib-h3/device/mmc/mmc_bsp.c:#define CKC_CCLK_MASK_DATA0               (1 << 31)       ///< Mask Data0 when update clock
./lib-h3/device/mmc/mmc_bsp.c:#define CMD_CMD_LOAD                      (1 << 31)       ///< Start Command
./lib-h3/src/h3_spi.c:  H3_CCU->SPI0_CLK = (1 << 31) | (0x01 << 24); // Clock is ON, P0
./lib-h3/src/h3_spi.c:  H3_CCU->SPI1_CLK = (1 << 31) | (0x01 << 24); // Clock is ON, P0
./lib-h3/src/h3_spi.c:  H3_CCU->SPI0_CLK &= ~(1 << 31); // Clock is OFF
./lib-h3/src/h3_spi.c:  H3_CCU->SPI1_CLK &= ~(1 << 31); // Clock is OFF
./lib-h3/src/h3_cpu.c:#define PLL_ENABLE                                        (1 << 31)
./lib-h3/src/h3_codec.c:#define SCLK_1X_GATING          (1 << 31)
./lib-h3/src/h3_codec.c:#define PLL_ENABLE                      (1 << 31)
./lib-h3/src/h3_timer.c:#define SCLK_GATING             (1 << 31)
./lib-h3/src/h3_ccu.c:#define PLL_ENABLE                        (1 << 31)       ///< The PLL output is (24MHz*N*K)/M
vanvught commented 4 years ago

Missing directory: lib-h3/device

[lib-display/include/displayset.h:39]: (error) Code 'classDisplaySet{' is invalid C code. Use --std or --language to configure the languag              e.
[lib-dmx/src/rpi/dmx.c:49]: (error) #error
[lib-h3/include/h3_gpio.h:35]: (error) syntax error
[lib-esp8266/src/h3/esp8266.c:66]: (error) #error PORT_CIN not defined
[lib-h3/device/mmc/mmc.c:543]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/device/mmc/mmc_bsp.c:157]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/device/mmc/mmc_bsp.c:168]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/device/mmc/mmc_bsp.c:170]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/device/mmc/mmc_bsp.c:217]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/device/mmc/mmc_bsp.c:328]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-h3/device/mmc/mmc_bsp.c:395]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[lib-hal/src/h3/hardware.c:158]: (error) #error Not a recognized/ tested FatFs version
[lib-hal/src/rpi/hardware.c:100]: (error) #error Not a recognized/ tested FatFs version
[lib-hal/src/rpi/hardware_rtc.c:55]: (error) Uninitialized struct member: tm_rtc.tm_wday
[lib-network/src/circle/networkcircle.cpp:100]: (error) #error CIRCLE_MAJOR_VERSION not defined
vanvught commented 4 years ago
cppcheck --includes-file=cppcheck.includes-file --file-list=cppcheck.file-list -DDEBUG=1 -DH3=1 -DORANGE_PI=1

[lib-display/include/displayset.h:39]: (error) Code 'classDisplaySet{' is invalid C code. Use --std or --language to configure the language.
[lib-dmx/src/rpi/dmx.c:49]: (error) #error
[lib-h3/include/h3_gpio.h:35]: (error) syntax error
[lib-esp8266/src/h3/esp8266.c:66]: (error) #error PORT_CIN not defined
[lib-hal/src/h3/hardware.c:158]: (error) #error Not a recognized/ tested FatFs version
[lib-hal/src/rpi/hardware.c:100]: (error) #error Not a recognized/ tested FatFs version
[lib-hal/src/rpi/hardware_rtc.c:55]: (error) Uninitialized struct member: tm_rtc.tm_wday
[lib-network/src/circle/networkcircle.cpp:100]: (error) #error CIRCLE_MAJOR_VERSION not defined