summaryrefslogtreecommitdiff
path: root/absl/synchronization/internal
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-09-01 09:19:13 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-01 09:19:53 -0700
commit847fa56a5422c20a6f471e67ac0bca004ff5eac5 (patch)
treeca3c7f6dc33390e9e752932e3540404c743ca9b6 /absl/synchronization/internal
parentb308bc06514600e9dedc16442fa5099050090d94 (diff)
Fix "unsafe narrowing" warnings in absl, 8/n.
Addresses failures with the following, in some files: -Wshorten-64-to-32 -Wimplicit-int-conversion -Wsign-compare -Wsign-conversion -Wtautological-unsigned-zero-compare (This specific CL focuses on .cc files in */internal/.) Bug: chromium:1292951 PiperOrigin-RevId: 471549854 Change-Id: Id685d0e4666212926f4e001b8ef4930b6a33a4cc
Diffstat (limited to 'absl/synchronization/internal')
-rw-r--r--absl/synchronization/internal/futex.h37
1 files changed, 20 insertions, 17 deletions
diff --git a/absl/synchronization/internal/futex.h b/absl/synchronization/internal/futex.h
index 06fbd6d0..cb97da09 100644
--- a/absl/synchronization/internal/futex.h
+++ b/absl/synchronization/internal/futex.h
@@ -87,7 +87,7 @@ class FutexImpl {
public:
static int WaitUntil(std::atomic<int32_t> *v, int32_t val,
KernelTimeout t) {
- int err = 0;
+ long err = 0; // NOLINT(runtime/int)
if (t.has_timeout()) {
// https://locklessinc.com/articles/futex_cheat_sheet/
// Unlike FUTEX_WAIT, FUTEX_WAIT_BITSET uses absolute time.
@@ -105,41 +105,44 @@ class FutexImpl {
FUTEX_WAIT | FUTEX_PRIVATE_FLAG, val, nullptr);
}
if (ABSL_PREDICT_FALSE(err != 0)) {
- err = -errno;
+ return -errno;
}
- return err;
+ return 0;
}
static int WaitBitsetAbsoluteTimeout(std::atomic<int32_t> *v, int32_t val,
int32_t bits,
const struct timespec *abstime) {
- int err = syscall(SYS_futex, reinterpret_cast<int32_t *>(v),
- FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG, val, abstime,
- nullptr, bits);
+ // NOLINTNEXTLINE(runtime/int)
+ long err = syscall(SYS_futex, reinterpret_cast<int32_t*>(v),
+ FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG, val, abstime,
+ nullptr, bits);
if (ABSL_PREDICT_FALSE(err != 0)) {
- err = -errno;
+ return -errno;
}
- return err;
+ return 0;
}
static int Wake(std::atomic<int32_t> *v, int32_t count) {
- int err = syscall(SYS_futex, reinterpret_cast<int32_t *>(v),
- FUTEX_WAKE | FUTEX_PRIVATE_FLAG, count);
+ // NOLINTNEXTLINE(runtime/int)
+ long err = syscall(SYS_futex, reinterpret_cast<int32_t*>(v),
+ FUTEX_WAKE | FUTEX_PRIVATE_FLAG, count);
if (ABSL_PREDICT_FALSE(err < 0)) {
- err = -errno;
+ return -errno;
}
- return err;
+ return 0;
}
// FUTEX_WAKE_BITSET
static int WakeBitset(std::atomic<int32_t> *v, int32_t count, int32_t bits) {
- int err = syscall(SYS_futex, reinterpret_cast<int32_t *>(v),
- FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG, count, nullptr,
- nullptr, bits);
+ // NOLINTNEXTLINE(runtime/int)
+ long err = syscall(SYS_futex, reinterpret_cast<int32_t*>(v),
+ FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG, count, nullptr,
+ nullptr, bits);
if (ABSL_PREDICT_FALSE(err < 0)) {
- err = -errno;
+ return -errno;
}
- return err;
+ return 0;
}
};