Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOG_WARNING: directive argument is null #3233

Open
Chemin1 opened this issue Nov 17, 2019 · 2 comments
Labels

Comments

@Chemin1
Copy link
Contributor

@Chemin1 Chemin1 commented Nov 17, 2019

Compilation with enabled logger gives warnings (or errors).

Steps to Reproduce the Problem

Similar to run_all_tests_with_docker.md

docker build -t buildelektra-sid \
	--build-arg JENKINS_USERID=$(id -u) \
	--build-arg JENKINS_GROUPID=$(id -g) \
	-f scripts/docker/debian/sid/Dockerfile \
	scripts/docker/debian/sid/

docker run -it --rm \
-v "$PWD:/home/jenkins/workspace" \
-w /home/jenkins/workspace \
buildelektra-sid

then in the container

cmake /home/jenkins/workspace \
-DBINDINGS="ALL;-DEPRECATED" \
-DPLUGINS="ALL;-DEPRECATED" \
-DTOOLS="ALL" \
-DENABLE_DEBUG="ON" \
-DKDB_DB_HOME="/home/jenkins/workspace/elektra-build-docker/.config/kdb/home" \
-DKDB_DB_SYSTEM="/home/jenkins/workspace/elektra-build-docker/.config/kdb/system" \
-DKDB_DB_SPEC="/home/jenkins/workspace/elektra-build-docker/.config/kdb/spec" \
-DBUILD_DOCUMENTATION="OFF" \
-DCMAKE_RULE_MESSAGES="OFF" \
-DCMAKE_INSTALL_PREFIX="/home/jenkins/workspace/elektra-install" \
-DCOMMON_FLAGS="-Werror"

make -j 7

it works so far, but then

cmake -DENABLE_LOGGER=ON ..
make -j 7

Expected Result

Successful compilation.

Actual Result


In file included from /home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:15:
In function ‘checkKeyIsSame’,
    inlined from ‘checkKeyIsBelowOrSame’ at /home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:124:12:
/home/jenkins/workspace/src/include/kdblogger.h:111:34: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  111 | #define ELEKTRA_LOG_WARNING(...) elektraLog (ELEKTRA_LOG_LEVEL_WARNING, __func__, __FILE__, __LINE__, __VA_ARGS__)
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:91:5: note: in expansion of macro ‘ELEKTRA_LOG_WARNING’
   91 |     ELEKTRA_LOG_WARNING ("invalid key given: '%s' is not a valid key", cascadingCheck);
      |     ^~~~~~~~~~~~~~~~~~~
/home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c: In function ‘checkKeyIsBelowOrSame’:
/home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:91:47: note: format string is defined here
   91 |     ELEKTRA_LOG_WARNING ("invalid key given: '%s' is not a valid key", cascadingCheck);
      |                                               ^~
In file included from /home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:15:
In function ‘checkKeyIsSame’,
    inlined from ‘checkKeyIsBelowOrSame’ at /home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:124:12:
/home/jenkins/workspace/src/include/kdblogger.h:111:34: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  111 | #define ELEKTRA_LOG_WARNING(...) elektraLog (ELEKTRA_LOG_LEVEL_WARNING, __func__, __FILE__, __LINE__, __VA_ARGS__)
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:95:5: note: in expansion of macro ‘ELEKTRA_LOG_WARNING’
   95 |     ELEKTRA_LOG_WARNING ("invalid key given: '%s' is not a valid key", cascadingKey);
      |     ^~~~~~~~~~~~~~~~~~~
/home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c: In function ‘checkKeyIsBelowOrSame’:
/home/jenkins/workspace/src/plugins/internalnotification/internalnotification.c:95:47: note: format string is defined here
   95 |     ELEKTRA_LOG_WARNING ("invalid key given: '%s' is not a valid key", cascadingKey);

...

cc1: all warnings being treated as errors
make[2]: *** [src/plugins/internalnotification/CMakeFiles/elektra-internalnotification-objects.dir/build.make:59: src/plugins/internalnotification/CMakeFiles/elektra-internalnotification-objects.dir/internalnotification.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:4411: src/plugins/internalnotification/CMakeFiles/elektra-internalnotification-objects.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

...
make: *** [Makefile:163: all] Error 2

System Information

@markus2330

This comment has been minimized.

Copy link
Contributor

@markus2330 markus2330 commented Nov 17, 2019

Thank you for reporting this problem!

I wonder why the build server does not catch this, I thought we had a build job that builds with logging enabled. Maybe you use a newer compiler as we have on our build server.

The code src/plugins/internalnotification/internalnotification.c is already quite old but the problem is obvious. A valid fix is to remove lines 87-97 as all the code is only about logging.

@Chemin1

This comment has been minimized.

Copy link
Contributor Author

@Chemin1 Chemin1 commented Nov 17, 2019

Maybe you use a newer compiler as we have on our build server.

Could well be. The Docker image that I tested with has gcc version 9.2.1 20191109 (Debian 9.2.1-19). Without Docker this error did not appear gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.