diff options
author | Derek Mauro <dmauro@google.com> | 2022-09-01 10:08:26 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-09-01 10:09:08 -0700 |
commit | fa108c444f18f6345b78090af47ec5fb4a7c2c36 (patch) | |
tree | b85fec244098d41964f1d2b5709c45bbd5638a2b /absl/base/internal/sysinfo.cc | |
parent | 847fa56a5422c20a6f471e67ac0bca004ff5eac5 (diff) | |
download | abseil-fa108c444f18f6345b78090af47ec5fb4a7c2c36.tar.gz abseil-fa108c444f18f6345b78090af47ec5fb4a7c2c36.tar.bz2 abseil-fa108c444f18f6345b78090af47ec5fb4a7c2c36.zip |
Rollback of 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: 471561809
Change-Id: I7abd6d83706f5ca135f1ce3458192a498a6280b9
Diffstat (limited to 'absl/base/internal/sysinfo.cc')
-rw-r--r-- | absl/base/internal/sysinfo.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc index d820ce38..a3e08b93 100644 --- a/absl/base/internal/sysinfo.cc +++ b/absl/base/internal/sysinfo.cc @@ -136,7 +136,7 @@ static int GetNumCPUs() { // Other possibilities: // - Read /sys/devices/system/cpu/online and use cpumask_parse() // - sysconf(_SC_NPROCESSORS_ONLN) - return static_cast<int>(std::thread::hardware_concurrency()); + return std::thread::hardware_concurrency(); #endif } @@ -194,7 +194,7 @@ static bool ReadLongFromFile(const char *file, long *value) { char line[1024]; char *err; memset(line, '\0', sizeof(line)); - ssize_t len = read(fd, line, sizeof(line) - 1); + int len = read(fd, line, sizeof(line) - 1); if (len <= 0) { ret = false; } else { @@ -376,7 +376,7 @@ pid_t GetTID() { #endif pid_t GetTID() { - return static_cast<pid_t>(syscall(SYS_gettid)); + return syscall(SYS_gettid); } #elif defined(__akaros__) @@ -429,11 +429,11 @@ static constexpr int kBitsPerWord = 32; // tid_array is uint32_t. // Returns the TID to tid_array. static void FreeTID(void *v) { intptr_t tid = reinterpret_cast<intptr_t>(v); - intptr_t word = tid / kBitsPerWord; + int word = tid / kBitsPerWord; uint32_t mask = ~(1u << (tid % kBitsPerWord)); absl::base_internal::SpinLockHolder lock(&tid_lock); assert(0 <= word && static_cast<size_t>(word) < tid_array->size()); - (*tid_array)[static_cast<size_t>(word)] &= mask; + (*tid_array)[word] &= mask; } static void InitGetTID() { @@ -455,7 +455,7 @@ pid_t GetTID() { intptr_t tid = reinterpret_cast<intptr_t>(pthread_getspecific(tid_key)); if (tid != 0) { - return static_cast<pid_t>(tid); + return tid; } int bit; // tid_array[word] = 1u << bit; @@ -476,8 +476,7 @@ pid_t GetTID() { while (bit < kBitsPerWord && (((*tid_array)[word] >> bit) & 1) != 0) { ++bit; } - tid = - static_cast<intptr_t>((word * kBitsPerWord) + static_cast<size_t>(bit)); + tid = (word * kBitsPerWord) + bit; (*tid_array)[word] |= 1u << bit; // Mark the TID as allocated. } |