1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-20 00:42:27 +03:00

Cast result of i64abs() back to int64

Without the cast, the return type could be long or long long,
depending on what int64 is underneath.  This doesn't affect code
correctness, but it could result in format-mismatch warnings when
attempting to printf such values using PRId64.

Reported-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CA+hUKGJc4s+Wyb3EFOQNN9VVK+Qv40r2LK41o9PkS9ThxviTvQ@mail.gmail.com
This commit is contained in:
Peter Eisentraut 2025-03-28 14:05:45 +01:00
parent 83ccc85859
commit 2247281c47

View File

@ -1278,9 +1278,9 @@ extern int fdatasync(int fildes);
* Similarly, wrappers around labs()/llabs() matching our int64. * Similarly, wrappers around labs()/llabs() matching our int64.
*/ */
#if SIZEOF_LONG == 8 #if SIZEOF_LONG == 8
#define i64abs(i) labs(i) #define i64abs(i) ((int64) labs(i))
#elif SIZEOF_LONG_LONG == 8 #elif SIZEOF_LONG_LONG == 8
#define i64abs(i) llabs(i) #define i64abs(i) ((int64) llabs(i))
#else #else
#error "cannot find integer type of the same size as int64_t" #error "cannot find integer type of the same size as int64_t"
#endif #endif