Skip to content

Commit fad2ad7

Browse files
[libc][fcntl] fix -Wshorten-64-to-32 for 32b ARM (#95945)
Fixes: llvm-project/libc/src/__support/OSUtil/linux/fcntl.cpp:63:26: error: implicit conversion loses integer precision: '__off64_t' (aka 'long long') to '__off_t' (aka 'long') [-Werror,-Wshorten-64-to-32] flk->l_start = flk64.l_start; ~ ~~~~~~^~~~~~~ llvm-project/libc/src/__support/OSUtil/linux/fcntl.cpp:64:24: error: implicit conversion loses integer precision: '__off64_t' (aka 'long long') to '__off_t' (aka 'long') [-Werror,-Wshorten-64-to-32] flk->l_len = flk64.l_len; ~ ~~~~~~^~~~~ We already have an overflow check, just need the cast to be explicit. This warning was observed on the 32b ARM build in overlay mode.
1 parent a03d06a commit fad2ad7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libc/src/__support/OSUtil/linux/fcntl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ int fcntl(int fd, int cmd, void *arg) {
6060
// Now copy back into flk, in case flk64 got modified
6161
flk->l_type = flk64.l_type;
6262
flk->l_whence = flk64.l_whence;
63-
flk->l_start = flk64.l_start;
64-
flk->l_len = flk64.l_len;
63+
flk->l_start = static_cast<decltype(flk->l_start)>(flk64.l_start);
64+
flk->l_len = static_cast<decltype(flk->l_len)>(flk64.l_len);
6565
flk->l_pid = flk64.l_pid;
6666
return retVal;
6767
}

0 commit comments

Comments
 (0)