Skip to content
  • Lyude Paul's avatar
    lib/aux: Typecast gettid() as pid_t · 6d404244
    Lyude Paul authored
    
    
    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: default avatarPetri Latvala <petri.latvala@intel.com>
    Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
    6d404244