Skip to content

Commit

Permalink
CppUTest: fix integer conversion warning in gettid()
Browse files Browse the repository at this point in the history
The cast is required since syscall() provides a generalized interface.

See, e.g. https://github.com/elogind/elogind/blob/06e702c9dafa3ea1dd6df8ee8cb4dcf417a0d442/src/basic/missing_syscall.h#L76-L87

[19/113] Building CXX object lib/CppUTest/CMakeFiles/CppUTest.dir/src/UtestPlatformGcc.cpp.o
../lib/CppUTest/src/UtestPlatformGcc.cpp: In function ‘pid_t gettid()’:
../lib/CppUTest/src/UtestPlatformGcc.cpp:59:50: warning: conversion to ‘pid_t {aka int}’ from ‘long int’ may alter its value [-Wconversion]
 static inline pid_t gettid(void) { return syscall( __NR_gettid ); }
                                           ~~~~~~~^~~~~~~~~~~~~~~
  • Loading branch information
pcolberg committed Feb 24, 2022
1 parent 2f00495 commit 1dd236b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/CppUTest/src/UtestPlatformGcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
// kernel 2.4.11. Library support was added in glibc 2.30. (Earlier
// glibc versions did not provide a wrapper for this system call,
// necessitating the use of syscall(2).)
static inline pid_t gettid(void) { return syscall( __NR_gettid ); }
static inline pid_t gettid(void) { return (pid_t)syscall(__NR_gettid); }
#endif

#include "CppUTest/PlatformSpecificFunctions.h"
Expand Down

0 comments on commit 1dd236b

Please sign in to comment.