Skip to content

Commit 583de9b

Browse files
authored
32bit conversion warning fix for abseil cpp (#12)
1 parent d302de6 commit 583de9b

File tree

12 files changed

+20
-20
lines changed

12 files changed

+20
-20
lines changed

absl/base/internal/sysinfo.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static constexpr int kBitsPerWord = 32; // tid_array is uint32_t.
430430
// Returns the TID to tid_array.
431431
static void FreeTID(void *v) {
432432
intptr_t tid = reinterpret_cast<intptr_t>(v);
433-
int word = tid / kBitsPerWord;
433+
int word = (int)(tid / kBitsPerWord);
434434
uint32_t mask = ~(1u << (tid % kBitsPerWord));
435435
absl::base_internal::SpinLockHolder lock(&tid_lock);
436436
assert(0 <= word && static_cast<size_t>(word) < tid_array->size());
@@ -456,7 +456,7 @@ pid_t GetTID() {
456456

457457
intptr_t tid = reinterpret_cast<intptr_t>(pthread_getspecific(tid_key));
458458
if (tid != 0) {
459-
return tid;
459+
return (pid_t)tid;
460460
}
461461

462462
int bit; // tid_array[word] = 1u << bit;

absl/debugging/failure_signal_handler.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static void AbslFailureSignalHandler(int signo, siginfo_t*, void* ucontext) {
326326
const GetTidType this_tid = absl::base_internal::GetTID();
327327
GetTidType previous_failed_tid = 0;
328328
if (!failed_tid.compare_exchange_strong(
329-
previous_failed_tid, static_cast<intptr_t>(this_tid),
329+
previous_failed_tid, static_cast<int>(this_tid),
330330
std::memory_order_acq_rel, std::memory_order_relaxed)) {
331331
ABSL_RAW_LOG(
332332
ERROR,

absl/debugging/internal/demangle.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static bool MaybeAppendDecimal(State *state, unsigned int val) {
456456
} while (p > buf && val != 0);
457457

458458
// 'p' landed on the last character we set. How convenient.
459-
Append(state, p, kMaxLength - (p - buf));
459+
Append(state, p, (int)(kMaxLength - (p - buf)));
460460
}
461461

462462
return true;
@@ -466,7 +466,7 @@ static bool MaybeAppendDecimal(State *state, unsigned int val) {
466466
// Returns true so that it can be placed in "if" conditions.
467467
static bool MaybeAppend(State *state, const char *const str) {
468468
if (state->parse_state.append) {
469-
int length = StrLen(str);
469+
int length = (int)StrLen(str);
470470
MaybeAppendWithLength(state, str, length);
471471
}
472472
return true;
@@ -853,7 +853,7 @@ static bool ParseNumber(State *state, int *number_out) {
853853
state->parse_state.mangled_idx += p - RemainingInput(state);
854854
if (number_out != nullptr) {
855855
// Note: possibly truncate "number".
856-
*number_out = number;
856+
*number_out = (int)number;
857857
}
858858
return true;
859859
}

absl/flags/internal/flag.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ bool FlagImpl::ReadOneBool() const {
483483
}
484484

485485
void FlagImpl::ReadSequenceLockedData(void* dst) const {
486-
int size = Sizeof(op_);
486+
int size = (int)Sizeof(op_);
487487
// Attempt to read using the sequence lock.
488488
if (ABSL_PREDICT_TRUE(seq_lock_.TryRead(dst, AtomicBufferValue(), size))) {
489489
return;

absl/flags/parse.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ArgsList {
159159
// Returns success status: true if parsing successful, false otherwise.
160160
bool ReadFromFlagfile(const std::string& flag_file_name);
161161

162-
int Size() const { return args_.size() - next_arg_; }
162+
int Size() const { return (int)(args_.size() - next_arg_); }
163163
int FrontIndex() const { return next_arg_; }
164164
absl::string_view Front() const { return args_[next_arg_]; }
165165
void PopFront() { next_arg_++; }

absl/hash/internal/city.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static uint32_t Hash32Len13to24(const char *s, size_t len) {
9797
uint32_t d = Fetch32(s + (len >> 1));
9898
uint32_t e = Fetch32(s);
9999
uint32_t f = Fetch32(s + len - 4);
100-
uint32_t h = len;
100+
uint32_t h = (uint32_t)len;
101101

102102
return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
103103
}
@@ -110,11 +110,11 @@ static uint32_t Hash32Len0to4(const char *s, size_t len) {
110110
b = b * c1 + v;
111111
c ^= b;
112112
}
113-
return fmix(Mur(b, Mur(len, c)));
113+
return fmix(Mur(b, Mur((uint32_t)len, c)));
114114
}
115115

116116
static uint32_t Hash32Len5to12(const char *s, size_t len) {
117-
uint32_t a = len, b = len * 5, c = 9, d = b;
117+
uint32_t a = (uint32_t)len, b = (uint32_t)(len * 5), c = 9, d = b;
118118
a += Fetch32(s);
119119
b += Fetch32(s + len - 4);
120120
c += Fetch32(s + ((len >> 1) & 4));
@@ -129,7 +129,7 @@ uint32_t CityHash32(const char *s, size_t len) {
129129
}
130130

131131
// len > 24
132-
uint32_t h = len, g = c1 * len, f = g;
132+
uint32_t h = (uint32_t)len, g = (uint32_t)(c1 * len), f = g;
133133

134134
uint32_t a0 = Rotate32(Fetch32(s + len - 4) * c1, 17) * c2;
135135
uint32_t a1 = Rotate32(Fetch32(s + len - 8) * c1, 17) * c2;
@@ -234,7 +234,7 @@ static uint64_t HashLen0to16(const char *s, size_t len) {
234234
uint8_t b = s[len >> 1];
235235
uint8_t c = s[len - 1];
236236
uint32_t y = static_cast<uint32_t>(a) + (static_cast<uint32_t>(b) << 8);
237-
uint32_t z = len + (static_cast<uint32_t>(c) << 2);
237+
uint32_t z = (uint32_t)(len + (static_cast<uint32_t>(c) << 2));
238238
return ShiftMix(y * k2 ^ z * k0) * k2;
239239
}
240240
return k2;

absl/random/internal/pcg_engine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ struct pcg_xsl_rr_128_64 {
262262
uint64_t rotate = h >> 58u;
263263
uint64_t s = Uint128Low64(state) ^ h;
264264
#endif
265-
return rotr(s, rotate);
265+
return rotr(s, (int)rotate);
266266
}
267267
};
268268

absl/random/internal/seed_material.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool ReadSeedMaterialFromDevURandom(absl::Span<uint32_t> values) {
173173
}
174174

175175
while (success && buffer_size > 0) {
176-
int bytes_read = read(dev_urandom, buffer, buffer_size);
176+
int bytes_read = (int)read(dev_urandom, buffer, buffer_size);
177177
int read_error = errno;
178178
success = (bytes_read > 0);
179179
if (success) {

absl/status/status.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static int FindPayloadIndexByUrl(const Payloads* payloads,
7979
if (payloads == nullptr) return -1;
8080

8181
for (size_t i = 0; i < payloads->size(); ++i) {
82-
if ((*payloads)[i].type_url == type_url) return i;
82+
if ((*payloads)[i].type_url == type_url) return (int)i;
8383
}
8484

8585
return -1;

absl/strings/charconv.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void EncodeResult(const CalculatedFloat& calculated, bool negative,
337337
*value = negative ? -0.0 : 0.0;
338338
return;
339339
}
340-
*value = FloatTraits<FloatType>::Make(calculated.mantissa,
340+
*value = FloatTraits<FloatType>::Make((uint32_t)(calculated.mantissa),
341341
calculated.exponent, negative);
342342
}
343343

absl/strings/internal/str_format/float_conversion.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ Padding ExtraWidthToPadding(size_t total_size, const FormatState &state) {
465465
static_cast<size_t>(state.conv.width()) <= total_size) {
466466
return {0, 0, 0};
467467
}
468-
int missing_chars = state.conv.width() - total_size;
468+
int missing_chars = (int)(state.conv.width() - total_size);
469469
if (state.conv.has_left_flag()) {
470470
return {0, 0, missing_chars};
471471
} else if (state.conv.has_zero_flag()) {
@@ -1263,7 +1263,7 @@ bool FloatToBuffer(Decomposed<Float> decomposed, int precision, Buffer *out,
12631263
if (CanFitMantissa<Float, std::uint64_t>() &&
12641264
FloatToBufferImpl<std::uint64_t, Float, mode>(
12651265
static_cast<std::uint64_t>(decomposed.mantissa),
1266-
static_cast<std::uint64_t>(decomposed.exponent), precision, out, exp))
1266+
static_cast<int>(decomposed.exponent), precision, out, exp))
12671267
return true;
12681268

12691269
#if defined(ABSL_HAVE_INTRINSIC_INT128)

absl/time/format.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ cctz_parts Split(absl::Time t) {
6464
// details about rep_hi and rep_lo.
6565
absl::Time Join(const cctz_parts& parts) {
6666
const int64_t rep_hi = (parts.sec - unix_epoch()).count();
67-
const uint32_t rep_lo = parts.fem.count() / (1000 * 1000 / 4);
67+
const uint32_t rep_lo = (uint32_t)(parts.fem.count() / (1000 * 1000 / 4));
6868
const auto d = time_internal::MakeDuration(rep_hi, rep_lo);
6969
return time_internal::FromUnixDuration(d);
7070
}

0 commit comments

Comments
 (0)