Skip to contentSkip to conversation

libsupport: change get_thread_id return type to unsigned long long

PATCH Applied Darrick J. Wong 2 participants 2 messages Apr 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsupport: change get_thread_id return type to unsigned long long

From: Darrick J. Wong <[email protected]>

With -Wformat enabled, the e2fsprogs build spews out a lot of warnings for fuse2fs:

../../misc/fuse2fs.c: In function ‘__fuse2fs_finish’:
../../misc/fuse2fs.c:152:24: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]

   152 |                 printf("FUSE2FS (%s): tid=%llu " format, (fuse2fs)->shortdev, get_thread_id(), ##__VA_ARGS__); \
       |                        ^~~~~~~~~~~~~~~~~~~~~~~~~                              ~~~~~~~~~~~~~~~
       |                                                                               |
       |                                                                               uint64_t {aka long unsigned int}
 ../../misc/fuse2fs.c:556:17: note: in expansion of macro ‘dbg_printf’
   556 |                 dbg_printf(ff, "%s: libfuse ret=%d\n", func, ret);
       |                 ^~~~~~~~~~

Because the linter doesn't like mixing %llu with a uint64_t type. On some platforms, uint64_t is merely "unsigned long" and whiiiiine.

Since this is a new wrapper function, let's change the return type.

---
 lib/support/thread.h |    2 +-
 lib/support/thread.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
lib/support/thread.h +1 -1
index 9a7f5c9db1b7a2..efba1c3b1eec0b 100644
@@ -2,4 +2,4 @@
  * thread.h -- header file for thread utilities
  */
 
-uint64_t get_thread_id(void);
+unsigned long long get_thread_id(void);
lib/support/thread.c +2 -2
index a9a10940c0fd3e..651be1cf833860 100644
@@ -12,7 +12,7 @@
 
 #include "support/thread.h"
 
-uint64_t get_thread_id(void)
+unsigned long long get_thread_id(void)
 {
 #if defined(HAVE_GETTID)
 	return gettid();
@@ -22,7 +22,7 @@ uint64_t get_thread_id(void)
 	if (pthread_threadid_np(NULL, &tid))
 		return tid;
 #elif defined(HAVE_PTHREAD)
-	return (__u64)(uintptr_t) pthread_self();
+	return (unsigned long long)(uintptr_t) pthread_self();
 #endif
 	return getpid();
 }
#1 lore raw
Quoted 13 lines · Darrick J. Wong

With -Wformat enabled, the e2fsprogs build spews out a lot of warnings for fuse2fs:

../../misc/fuse2fs.c: In function ‘__fuse2fs_finish’:
../../misc/fuse2fs.c:152:24: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]

   152 |                 printf("FUSE2FS (%s): tid=%llu " format, (fuse2fs)->shortdev, get_thread_id(), ##__VA_ARGS__); \
       |                        ^~~~~~~~~~~~~~~~~~~~~~~~~                              ~~~~~~~~~~~~~~~
       |                                                                               |
       |                                                                               uint64_t {aka long unsigned int}
 ../../misc/fuse2fs.c:556:17: note: in expansion of macro ‘dbg_printf’
   556 |                 dbg_printf(ff, "%s: libfuse ret=%d\n", func, ret);
       |                 ^~~~~~~~~~
Quoted 1 line

[...]

Applied, thanks!

[1/1] libsupport: change get_thread_id return type to unsigned long long

      commit: 582a5ff290423e6fc11e91ba0534e422c026f018

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>