From d3c9871db7f234bd097f43c11700d260b933816b Mon Sep 17 00:00:00 2001 From: Peter Colberg Date: Wed, 23 Feb 2022 19:19:45 -0500 Subject: [PATCH] CppUTest: fix integer conversion warning in gettid() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ); } ~~~~~~~^~~~~~~~~~~~~~~ --- lib/CppUTest/src/UtestPlatformGcc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CppUTest/src/UtestPlatformGcc.cpp b/lib/CppUTest/src/UtestPlatformGcc.cpp index 22416d0d..bd7975fb 100644 --- a/lib/CppUTest/src/UtestPlatformGcc.cpp +++ b/lib/CppUTest/src/UtestPlatformGcc.cpp @@ -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"