-
Notifications
You must be signed in to change notification settings - Fork 319
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
Gcc8 fixes #161
Merged
Merged
Gcc8 fixes #161
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc 8.x introduced stricter checking on strncpy(), and causes the following build failures: libfaketime.c: In function 'fake_clock_gettime.part.4': libfaketime.c:2134:7: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time, tmp_env, BUFFERLEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c:2134:7: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time, tmp_env, BUFFERLEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c: In function 'ftpl_init': libfaketime.c:1884:12: error: 'strncpy' specified bound 1024 equals destination size [-Werror=stringop-truncation] (void) strncpy(ft_spawn_target, getenv("FAKETIME_SPAWN_TARGET"), 1024); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c:1945:5: error: 'strncpy' specified bound 8192 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time_fmt, tmp_env, BUFSIZ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c: In function 'ftpl_init': libfaketime.c:1884:12: error: 'strncpy' specified bound 1024 equals destination size [-Werror=stringop-truncation] (void) strncpy(ft_spawn_target, getenv("FAKETIME_SPAWN_TARGET"), 1024); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libfaketime.c:1945:5: error: 'strncpy' specified bound 8192 equals destination size [-Werror=stringop-truncation] strncpy(user_faked_time_fmt, tmp_env, BUFSIZ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This commit fixes that by making sure we keep one final byte for the nul terminator, as suggested by wolfcw#150. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
gcc 8.x introduced stricter checking on types, and the trick to cast pthread_mutex_unlock() into a function acceptable for pthread_cleanup_push() no longer builds: libfaketime.c: In function 'fake_clock_gettime': libfaketime.c:2039:24: error: cast between incompatible function types from 'int (*)(pthread_mutex_t *)' {aka 'int (*)(union <anonymous> *)'} to 'void (*)(void *)' [-Werror=cast-function-type] pthread_cleanup_push((void (*)(void *))pthread_mutex_unlock, (void *)&time_mutex); ^ Rather than continuing to hack around, introduce an auxilliary function with the type expected by pthread_cleanup_push(). Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
The pthread_cond_timedwait_common() function declares a 'result' variable, but in some code paths, it may be returned without being initialized. This commit fixes that by initializing the variable. Fixes: libfaketime.c: In function 'pthread_cond_timedwait_common': libfaketime.c:2534:7: error: 'result' may be used uninitialized in this function [-Werror=maybe-uninitialized] int result; ^~~~~~ Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
shared_objs[] will contain the concatenation of sem_name and shm_name, which are both 4096 bytes long, and shared_objs[] itself is only 4096 bytes long. This causes a build failure with gcc 8.x: faketime.c: In function 'main': faketime.c:289:45: error: '%s' directive output may be truncated writing up to 4095 bytes into a region of size between 0 and 4095 [-Werror=format-truncation=] snprintf(shared_objs, PATH_BUFSIZE, "%s %s", sem_name, shm_name); ^~ ~~~~~~~~ faketime.c:289:5: note: 'snprintf' output between 2 and 8192 bytes into a destination of size 4096 snprintf(shared_objs, PATH_BUFSIZE, "%s %s", sem_name, shm_name); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This commit fixes that by enlarging the shared_objs[] array to twice the of PATH_BUFSIZE, plus one byte for the space. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
buildroot-auto-update
pushed a commit
to buildroot/buildroot
that referenced
this pull request
May 19, 2018
faketime currently doesn't build on host machines that use gcc 8.x due to stricter checks done by gcc, and the fact that it is built with -Werror. As a simple stop-gap measure, this commit patches the faketime Makefile to not use -Werror anymore. The actual fixes for the gcc 8.x issues have been submitted upstream at wolfcw/libfaketime#161, but disabling -Werror is a much smaller fix. Also, it is worth mentioning that removing -Werror makes the existing patch 0001-Disable-the-non-null-compare-warning-error.patch (which was just disabling one specific warning). We nonetheless keep this patch around as it is a backport from upstream. Fixes: http://autobuild.buildroot.net/results/bd223dfa1c4baa68e427d4941bd2e9917e22da84/ Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
simon-weber
added a commit
to simon-weber/libfaketime
that referenced
this pull request
May 19, 2018
buildroot-auto-update
pushed a commit
to buildroot/buildroot
that referenced
this pull request
Jun 11, 2018
faketime currently doesn't build on host machines that use gcc 8.x due to stricter checks done by gcc, and the fact that it is built with -Werror. As a simple stop-gap measure, this commit patches the faketime Makefile to not use -Werror anymore. The actual fixes for the gcc 8.x issues have been submitted upstream at wolfcw/libfaketime#161, but disabling -Werror is a much smaller fix. Also, it is worth mentioning that removing -Werror makes the existing patch 0001-Disable-the-non-null-compare-warning-error.patch (which was just disabling one specific warning). We nonetheless keep this patch around as it is a backport from upstream. Fixes: http://autobuild.buildroot.net/results/bd223dfa1c4baa68e427d4941bd2e9917e22da84/ Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> (cherry picked from commit 968f2fb) Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
ananos
pushed a commit
to ananos/buildroot
that referenced
this pull request
Jun 15, 2018
faketime currently doesn't build on host machines that use gcc 8.x due to stricter checks done by gcc, and the fact that it is built with -Werror. As a simple stop-gap measure, this commit patches the faketime Makefile to not use -Werror anymore. The actual fixes for the gcc 8.x issues have been submitted upstream at wolfcw/libfaketime#161, but disabling -Werror is a much smaller fix. Also, it is worth mentioning that removing -Werror makes the existing patch 0001-Disable-the-non-null-compare-warning-error.patch (which was just disabling one specific warning). We nonetheless keep this patch around as it is a backport from upstream. Fixes: http://autobuild.buildroot.net/results/bd223dfa1c4baa68e427d4941bd2e9917e22da84/ Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
buildroot-auto-update
pushed a commit
to buildroot/buildroot
that referenced
this pull request
Aug 28, 2019
- Remove first patch (already in version) - Remove second patch (not needed since merge of wolfcw/libfaketime#161) - Add hash for license file Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
This set of patches fix a number of build issues that occur with gcc 8.x. Note that they have only been compiled tested, not runtime tested. But all patches are pretty straightforward.
Thanks,
Thomas