Skip to content

Commit 2247281

Browse files
committed
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
1 parent 83ccc85 commit 2247281

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/include/c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,9 +1278,9 @@ extern int fdatasync(int fildes);
12781278
* Similarly, wrappers around labs()/llabs() matching our int64.
12791279
*/
12801280
#if SIZEOF_LONG == 8
1281-
#define i64abs(i) labs(i)
1281+
#define i64abs(i) ((int64) labs(i))
12821282
#elif SIZEOF_LONG_LONG == 8
1283-
#define i64abs(i) llabs(i)
1283+
#define i64abs(i) ((int64) llabs(i))
12841284
#else
12851285
#error "cannot find integer type of the same size as int64_t"
12861286
#endif

0 commit comments

Comments
 (0)