From 6d404244a0e22601ffa121ee5c1e337451339719 Mon Sep 17 00:00:00 2001 From: Lyude Paul Date: Tue, 23 Apr 2019 20:01:20 -0400 Subject: lib/aux: Typecast gettid() as pid_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Partly, for correctness. But mostly because not typecasting properly causes the gettid() macro provided by newer glibc to be typed as pid_t (aka int), while ours is typed as long. Causing annoying warnings: [158/846] Compiling C object 'tests/59830eb@@drm_import_export@exe/drm_import_export.c.o'. In file included from ../../mnt/vol/lib/drmtest.h:39, from ../../mnt/vol/lib/igt.h:27, from ../../mnt/vol/tests/drm_import_export.c:27: ../../mnt/vol/tests/drm_import_export.c: In function ‘test_thread’: ../../mnt/vol/tests/drm_import_export.c:123:12: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘__pid_t’ {aka ‘int’} [-Wformat=] 123 | igt_debug("start %ld\n", gettid()); | ^~~~~~~~~~~~~ ~~~~~~~~ | | | __pid_t {aka int} ../../mnt/vol/lib/igt_core.h:875:64: note: in definition of macro ‘igt_debug’ 875 | #define igt_debug(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_DEBUG, f) | ^ ../../mnt/vol/tests/drm_import_export.c:123:21: note: format string is defined here 123 | igt_debug("start %ld\n", gettid()); | ~~^ | | | long int | %d So, typecast gettid() as pid_t and update all of our callers accordingly Reviewed-by: Petri Latvala Signed-off-by: Lyude Paul --- lib/igt_aux.h | 3 ++- tests/drm_import_export.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/igt_aux.h b/lib/igt_aux.h index a6e3770e..24711aa2 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef __linux__ # include #endif @@ -40,7 +41,7 @@ /* signal interrupt helpers */ #ifdef __linux__ -# define gettid() syscall(__NR_gettid) +# define gettid() (pid_t)(syscall(__NR_gettid)) #endif #define sigev_notify_thread_id _sigev_un._tid diff --git a/tests/drm_import_export.c b/tests/drm_import_export.c index e1b0abae..f79c09db 100644 --- a/tests/drm_import_export.c +++ b/tests/drm_import_export.c @@ -120,7 +120,7 @@ static void start_test(void) static void * test_thread(void * par) { #ifdef __linux__ - igt_debug("start %ld\n", gettid()); + igt_debug("start %ld\n", (long) gettid()); #else igt_debug("start %ld\n", (long) pthread_self()); #endif -- cgit v1.2.3