tuxedocomputers / tuxedo-keyboard

This repository will no longer get any updates as the code here is now part of tuxedo-drivers https://gitlab.com/tuxedocomputers/development/packages/tuxedo-drivers.
https://gitlab.com/tuxedocomputers/development/packages/tuxedo-drivers
GNU General Public License v3.0
299 stars 93 forks source link

Clang support, missing prototype, unititialized var #175

Closed vincentdephily closed 1 year ago

vincentdephily commented 1 year ago

My kernel is built with Clang, and therefore I need to build this module with Clang as well, but I get these errors (using 2f4364968aa56b7aad4830c11cbcb85f78d6eac4):

$ LLVM=1 make
make -C /lib/modules/6.2.10-gentoo-molto/build M=/home/work/c/tuxedo-keyboard modules
make[1]: Entering directory '/usr/src/linux-6.2.10-gentoo'
  CC [M]  /home/work/c/tuxedo-keyboard/./src/tuxedo_keyboard.o
In file included from /home/work/c/tuxedo-keyboard/./src/tuxedo_keyboard.c:22:
In file included from /home/work/c/tuxedo-keyboard/./src/clevo_keyboard.h:24:
/home/work/c/tuxedo-keyboard/./src/clevo_leds.h:379:60: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
enum clevo_kb_backlight_types clevo_leds_get_backlight_type() {
                                                           ^
                                                            void
In file included from /home/work/c/tuxedo-keyboard/./src/tuxedo_keyboard.c:23:
In file included from /home/work/c/tuxedo-keyboard/./src/uniwill_keyboard.h:34:
/home/work/c/tuxedo-keyboard/./src/uniwill_leds.h:257:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
        if (uw_leds_initialized) {
            ^~~~~~~~~~~~~~~~~~~
/home/work/c/tuxedo-keyboard/./src/uniwill_leds.h:274:9: note: uninitialized use occurs here
        return ret;
               ^~~
/home/work/c/tuxedo-keyboard/./src/uniwill_leds.h:257:2: note: remove the 'if' if its condition is always true
        if (uw_leds_initialized) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/work/c/tuxedo-keyboard/./src/uniwill_leds.h:255:9: note: initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0
/home/work/c/tuxedo-keyboard/./src/uniwill_leds.h:278:64: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
enum uniwill_kb_backlight_types uniwill_leds_get_backlight_type() {
                                                               ^
                                                                void
1 warning and 2 errors generated.
make[2]: *** [scripts/Makefile.build:252: /home/work/c/tuxedo-keyboard/./src/tuxedo_keyboard.o] Error 1
make[1]: *** [Makefile:2021: /home/work/c/tuxedo-keyboard] Error 2
make[1]: Leaving directory '/usr/src/linux-6.2.10-gentoo'
make: *** [Makefile:29: all] Error 2

Both the missing prototype and the uninitialized ret seem to point to real issues that need fixing regardless of Clang support.

For what it's worth, I'm not getting very far with gcc:

$ make
make -C /lib/modules/6.2.10-gentoo-molto/build M=/home/work/c/tuxedo-keyboard modules
make[1]: Entering directory '/usr/src/linux-6.2.10-gentoo'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: clang version 16.0.1
  You are using:           gcc (Gentoo 12.2.1_p20230121-r1 p10) 12.2.1 20230121
  CC [M]  /home/work/c/tuxedo-keyboard/./src/tuxedo_keyboard.o
gcc: error: unrecognized command-line option ‘-Qunused-arguments’
make[2]: *** [scripts/Makefile.build:252: /home/work/c/tuxedo-keyboard/./src/tuxedo_keyboard.o] Error 1
make[1]: *** [Makefile:2021: /home/work/c/tuxedo-keyboard] Error 2
make[1]: Leaving directory '/usr/src/linux-6.2.10-gentoo'
make: *** [Makefile:29: all] Error 2