Turanic / usbwall

Control ldap users access to usb devices
MIT License
1 stars 5 forks source link

Compile warning because of unused PAM_SM_SESSION Macro #1

Closed Oline closed 8 years ago

Oline commented 8 years ago

The Macro PAM_SM_SESSION is defined in the file src/pam/pam_usbwall.c and it generates a warning when compiling with clang because this macro is never used.

It seems that it needs to be defined from the PAM documentation, but the reality is that the file /usr/include/security/pam_modules.h only use this macro if the macro PAM_SM_STATIC is also defined. Since the macro PAM_SM_STATIC is not defined, the other macro is never tested and then clang warns about it not being used.

Maybe we don't need to define it?

Oline commented 8 years ago

By the way, even if we solve that problem, we'll get an "unused function" warning because some function from the included PAM headers are also not used... Maybe we will need to remove this warning flag because of the PAM code quality not respecting the flag.

Turanic commented 8 years ago

The Linux-PAM documentation say :

To be correctly initialized, PAM_SM_SESSION must be #define'd prior to including <security/pam_modules.h>. This will ensure that the prototypes for static modules are properly declared.

Handling static PAM is not one of our target at the moment. So you're right, the macro seems to be unnecessary. It will be deleted in my next commit.

However, I don't get any warning with clang -Weverything flag about unused functions.

Oline commented 8 years ago

I got this warning with clang on OpenSuse 42.1:

> clang -v
clang version 3.7.0 (tags/RELEASE_370/final 246586)
Target: x86_64-suse-linux
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-suse-linux/4.8
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-suse-linux/4.8
Candidate multilib: .;@m64
Selected multilib: .;@m64

Compile log is :

> `/tmp/usbwall> CC=clang ./bootstrap DEBUG && make
launching cmake in /tmp/usbwall/_build mode=DEBUG
-- The C compiler identification is Clang 3.7.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test HAS_WEVERYTHING_CFLAG
-- Performing Test HAS_WEVERYTHING_CFLAG - Success
-- Performing Test HAS_STDC99_CFLAG
-- Performing Test HAS_STDC99_CFLAG - Success
-- Performing Test HAS_WALL_CFLAG
-- Performing Test HAS_WALL_CFLAG - Success
-- Performing Test HAS_WEXTRA_CFLAG
-- Performing Test HAS_WEXTRA_CFLAG - Success
-- Performing Test HAS_WERROR_CFLAG
-- Performing Test HAS_WERROR_CFLAG - Success
-- Performing Test HAS_PEDANTIC_CFLAG
-- Performing Test HAS_PEDANTIC_CFLAG - Success
-- Performing Test HAS_FORMAT_0_CFLAG
-- Performing Test HAS_FORMAT_0_CFLAG - Success
-- Performing Test HAS_UNUSED_MACROS_CFLAG
-- Performing Test HAS_UNUSED_MACROS_CFLAG - Success
-- Performing Test HAS_SAN_ADDR_CFLAG
-- Performing Test HAS_SAN_ADDR_CFLAG - Failed
-- Performing Test HAS_SAN_UNDEF_CFLAG
-- Performing Test HAS_SAN_UNDEF_CFLAG - Success
-- Found PAM: /usr/lib64/libpam.so  
-- Found USB1: /usr/lib64/libusb-1.0.so  
-- Found LDAP: /usr/lib64/libldap.so  
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6") 
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/usbwall/_build
make -C _build
make[1]: Entering directory '/tmp/usbwall/_build'
make[2]: Entering directory '/tmp/usbwall/_build'
make[3]: Entering directory '/tmp/usbwall/_build'
Scanning dependencies of target pam_usbwall
make[3]: Leaving directory '/tmp/usbwall/_build'
make[3]: Entering directory '/tmp/usbwall/_build'
[ 14%] Building C object src/pam/CMakeFiles/pam_usbwall.dir/pam_usbwall.c.o
/tmp/usbwall/src/pam/pam_usbwall.c:1:9: error: macro is not used [-Werror,-Wunused-macros]
#define PAM_SM_SESSION
        ^
1 error generated.