summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLyude Paul <lyude@redhat.com>2019-04-23 20:01:20 -0400
committerLyude Paul <lyude@redhat.com>2019-05-07 17:37:59 -0400
commit6d404244a0e22601ffa121ee5c1e337451339719 (patch)
tree2bab15512cd9cf332a2538e251769263239a6c1b
parent998288337d87b9fac8ae3a2f06ee97bfa9bfdfa3 (diff)
lib/aux: Typecast gettid() as pid_t
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 <petri.latvala@intel.com> Signed-off-by: Lyude Paul <lyude@redhat.com>
-rw-r--r--lib/igt_aux.h3
-rw-r--r--tests/drm_import_export.c2
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 <stdbool.h>
#include <stddef.h>
#include <sys/time.h>
+#include <sys/types.h>
#ifdef __linux__
# include <sys/syscall.h>
#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