diff options
author | Juergen Borleis <jbe@pengutronix.de> | 2019-05-23 11:37:57 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-05-27 12:30:17 +0200 |
commit | 26df5699924271a5571baf72009bd9c690287d70 (patch) | |
tree | 05be1b2fa7932681eacd31906afef48d6f118abb | |
parent | 580cd7bd352e6812c4494be1fb2ddb968430c00f (diff) | |
download | ptxdist-26df5699924271a5571baf72009bd9c690287d70.tar.gz ptxdist-26df5699924271a5571baf72009bd9c690287d70.tar.xz |
libfaketime: fix GCC8 compiler warnings
GCC8 outputs more warnings than its predecessor. This make the package
fail to build, due to its "-Werror" usage.
This change removes the "-Werror" (which should never be used in a release)
and fixes the new warnings.
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
4 files changed, 130 insertions, 0 deletions
diff --git a/patches/libfaketime-0.9.7/0001-buildsystem-avoid-Werror-on-release.patch b/patches/libfaketime-0.9.7/0001-buildsystem-avoid-Werror-on-release.patch new file mode 100644 index 000000000..af60f7bdb --- /dev/null +++ b/patches/libfaketime-0.9.7/0001-buildsystem-avoid-Werror-on-release.patch @@ -0,0 +1,39 @@ +From: Juergen Borleis <jbe@pengutronix.de> +Date: Thu, 23 May 2019 10:58:20 +0200 +Subject: [PATCH] buildsystem: avoid -Werror on release + +While "-Werror" is a really good idea for development, it is a really bad +idea for releases in conjunction with more recent compilers. + +With the GCC-8 compiler building fails due to a new warnings: + + 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=] + +and + + libfaketime.c:1986:24: error: cast between incompatible function types + from 'int (*)(pthread_mutex_t *)' {aka 'int (*)(union <anonymous> *)'} + to 'void (*)(void *)' [-Werror=cast-function-type] + +While the warnings are correct, the forced error is useless in this case. + +Signed-off-by: Juergen Borleis <jbe@pengutronix.de> +--- + src/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Makefile b/src/Makefile +index a557c3847341..27118abcf23d 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -62,7 +62,7 @@ PREFIX ?= /usr/local + LIBDIRNAME ?= /lib/faketime + PLATFORM ?=$(shell uname) + +-CFLAGS += -std=gnu99 -Wall -Wextra -Werror -Wno-nonnull-compare -DFAKE_STAT -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"' ++CFLAGS += -std=gnu99 -Wall -Wextra -Wno-nonnull-compare -DFAKE_STAT -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'$(PREFIX)'"' -DLIBDIRNAME='"'$(LIBDIRNAME)'"' + ifeq ($(PLATFORM),SunOS) + CFLAGS += -D__EXTENSIONS__ -D_XOPEN_SOURCE=600 + endif diff --git a/patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch b/patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch new file mode 100644 index 000000000..830c810f6 --- /dev/null +++ b/patches/libfaketime-0.9.7/0002-faketime-fix-format-truncation-warning.patch @@ -0,0 +1,41 @@ +From: Juergen Borleis <jbe@pengutronix.de> +Date: Thu, 23 May 2019 11:30:23 +0200 +Subject: [PATCH] faketime: fix format truncation warning. + +GCC8 states: + + 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=] + +Using snprintf() is a good idea to not write behind the end of an array, +but a truncation of the content is an ugly failure as well. + +Since both input buffers are 4096 bytes in size, the output buffer must be +at least twice in size. +--- + src/faketime.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/faketime.c b/src/faketime.c +index 138ebbd55388..647c0f0c318c 100644 +--- a/src/faketime.c ++++ b/src/faketime.c +@@ -209,7 +209,7 @@ int main (int argc, char **argv) + int shm_fd; + sem_t *sem; + struct ft_shared_s *ft_shared; +- char shared_objs[PATH_BUFSIZE]; ++ char shared_objs[PATH_BUFSIZE * 2]; + + /* + * Casting of getpid() return value to long needed to make GCC on SmartOS +@@ -286,7 +286,7 @@ int main (int argc, char **argv) + exit(EXIT_FAILURE); + } + +- snprintf(shared_objs, PATH_BUFSIZE, "%s %s", sem_name, shm_name); ++ snprintf(shared_objs, sizeof(shared_objs), "%s %s", sem_name, shm_name); + setenv("FAKETIME_SHARED", shared_objs, true); + sem_close(sem); + } diff --git a/patches/libfaketime-0.9.7/0003-libfaketime-fix-casting-hell-warning.patch b/patches/libfaketime-0.9.7/0003-libfaketime-fix-casting-hell-warning.patch new file mode 100644 index 000000000..7cb00af9e --- /dev/null +++ b/patches/libfaketime-0.9.7/0003-libfaketime-fix-casting-hell-warning.patch @@ -0,0 +1,44 @@ +From: Juergen Borleis <jbe@pengutronix.de> +Date: Thu, 23 May 2019 11:33:15 +0200 +Subject: [PATCH] libfaketime: fix casting hell warning + +GCC8 states: + + libfaketime.c:1986:24: error: cast between incompatible function types + from 'int (*)(pthread_mutex_t *)' {aka 'int (*)(union <anonymous> *)'} + to 'void (*)(void *)' [-Werror=cast-function-type] + +Let the compiler inline a new function instead, which correctly casts the +value. +--- + src/libfaketime.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/src/libfaketime.c b/src/libfaketime.c +index eb2d01bb6631..acf586223dec 100644 +--- a/src/libfaketime.c ++++ b/src/libfaketime.c +@@ -1953,6 +1953,14 @@ static void remove_trailing_eols(char *line) + } + } + ++#ifdef PTHREAD ++/* to avoid a cast() hell and compiler warnings */ ++static void thread_cleanup_locks(void *p) ++{ ++ pthread_mutex_t *time_mutex = (pthread_mutex_t*)p; ++ pthread_mutex_unlock(time_mutex); ++} ++#endif + + /* + * ======================================================================= +@@ -1983,7 +1991,7 @@ int fake_clock_gettime(clockid_t clk_id, struct timespec *tp) + #ifdef PTHREAD_SINGLETHREADED_TIME + static pthread_mutex_t time_mutex=PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_lock(&time_mutex); +- pthread_cleanup_push((void (*)(void *))pthread_mutex_unlock, (void *)&time_mutex); ++ pthread_cleanup_push(thread_cleanup_locks, (void *)&time_mutex); + #endif + + if ((limited_faking && diff --git a/patches/libfaketime-0.9.7/series b/patches/libfaketime-0.9.7/series new file mode 100644 index 000000000..5ed1cf68e --- /dev/null +++ b/patches/libfaketime-0.9.7/series @@ -0,0 +1,6 @@ +# generated by git-ptx-patches +#tag:base --start-number 1 +0001-buildsystem-avoid-Werror-on-release.patch +0002-faketime-fix-format-truncation-warning.patch +0003-libfaketime-fix-casting-hell-warning.patch +# 324f635631c9304e302c860942b23b40 - git-ptx-patches magic |