Skip to content

Commit 25ec6a3

Browse files
authored
chore: some warning worth fixing (#276)
Meson build has warning_level=2, which enables -Wall -Wextra compiler flags. Some of the warning seems worth fixing. This commit resolves some of the following warnings: -Wredundant-move -Wimplicit-fallthrough -Wreorder -Wsign-compare
1 parent 18d2e9a commit 25ec6a3

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

src/iceberg/manifest_adapter.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Status ManifestEntryAdapter::AppendPartitionValues(
167167
}
168168
auto fields = partition_type->fields();
169169

170-
for (int32_t i = 0; i < fields.size(); i++) {
170+
for (size_t i = 0; i < fields.size(); i++) {
171171
const auto& partition_value = partition_values[i];
172172
const auto& partition_field = fields[i];
173173
auto child_array = array->children[i];
@@ -243,7 +243,7 @@ Status ManifestEntryAdapter::AppendDataFile(
243243
ArrowArray* array, const std::shared_ptr<StructType>& data_file_type,
244244
const DataFile& file) {
245245
auto fields = data_file_type->fields();
246-
for (int32_t i = 0; i < fields.size(); i++) {
246+
for (size_t i = 0; i < fields.size(); i++) {
247247
const auto& field = fields[i];
248248
auto child_array = array->children[i];
249249

@@ -382,7 +382,7 @@ Result<std::optional<int64_t>> ManifestEntryAdapter::GetContentSizeInBytes(
382382

383383
Status ManifestEntryAdapter::AppendInternal(const ManifestEntry& entry) {
384384
const auto& fields = manifest_schema_->fields();
385-
for (int32_t i = 0; i < fields.size(); i++) {
385+
for (size_t i = 0; i < fields.size(); i++) {
386386
const auto& field = fields[i];
387387
auto array = array_.children[i];
388388

@@ -555,7 +555,7 @@ Result<std::optional<int64_t>> ManifestFileAdapter::GetFirstRowId(
555555

556556
Status ManifestFileAdapter::AppendInternal(const ManifestFile& file) {
557557
const auto& fields = manifest_list_schema_->fields();
558-
for (int32_t i = 0; i < fields.size(); i++) {
558+
for (size_t i = 0; i < fields.size(); i++) {
559559
const auto& field = fields[i];
560560
auto array = array_.children[i];
561561
switch (field.field_id()) {

src/iceberg/manifest_reader_internal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ Result<std::vector<ManifestEntry>> ParseManifestEntry(ArrowSchema* schema,
476476

477477
std::vector<ManifestEntry> manifest_entries;
478478
manifest_entries.resize(array_in->length);
479-
for (size_t i = 0; i < array_in->length; i++) {
479+
for (int64_t i = 0; i < array_in->length; i++) {
480480
manifest_entries[i].data_file = std::make_shared<DataFile>();
481481
}
482482

src/iceberg/schema.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ Status IdToFieldVisitor::Visit(const NestedType& type) {
166166
NameToIdVisitor::NameToIdVisitor(
167167
std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>>& name_to_id,
168168
bool case_sensitive, std::function<std::string(std::string_view)> quoting_func)
169-
: name_to_id_(name_to_id),
170-
case_sensitive_(case_sensitive),
169+
: case_sensitive_(case_sensitive),
170+
name_to_id_(name_to_id),
171171
quoting_func_(std::move(quoting_func)) {}
172172

173173
Status NameToIdVisitor::Visit(const ListType& type, const std::string& path,

src/iceberg/util/murmurhash3_internal.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ void MurmurHash3_x86_32(const void* key, int len, uint32_t seed, void* out) {
120120
switch (len & 3) {
121121
case 3:
122122
k1 ^= tail[2] << 16;
123+
[[fallthrough]];
123124
case 2:
124125
k1 ^= tail[1] << 8;
126+
[[fallthrough]];
125127
case 1:
126128
k1 ^= tail[0];
127129
k1 *= c1;
@@ -217,47 +219,61 @@ void MurmurHash3_x86_128(const void* key, const int len, uint32_t seed, void* ou
217219
switch (len & 15) {
218220
case 15:
219221
k4 ^= tail[14] << 16;
222+
[[fallthrough]];
220223
case 14:
221224
k4 ^= tail[13] << 8;
225+
[[fallthrough]];
222226
case 13:
223227
k4 ^= tail[12] << 0;
224228
k4 *= c4;
225229
k4 = ROTL32(k4, 18);
226230
k4 *= c1;
227231
h4 ^= k4;
232+
[[fallthrough]];
228233

229234
case 12:
230235
k3 ^= tail[11] << 24;
236+
[[fallthrough]];
231237
case 11:
232238
k3 ^= tail[10] << 16;
239+
[[fallthrough]];
233240
case 10:
234241
k3 ^= tail[9] << 8;
242+
[[fallthrough]];
235243
case 9:
236244
k3 ^= tail[8] << 0;
237245
k3 *= c3;
238246
k3 = ROTL32(k3, 17);
239247
k3 *= c4;
240248
h3 ^= k3;
249+
[[fallthrough]];
241250

242251
case 8:
243252
k2 ^= tail[7] << 24;
253+
[[fallthrough]];
244254
case 7:
245255
k2 ^= tail[6] << 16;
256+
[[fallthrough]];
246257
case 6:
247258
k2 ^= tail[5] << 8;
259+
[[fallthrough]];
248260
case 5:
249261
k2 ^= tail[4] << 0;
250262
k2 *= c2;
251263
k2 = ROTL32(k2, 16);
252264
k2 *= c3;
253265
h2 ^= k2;
266+
[[fallthrough]];
254267

255268
case 4:
256269
k1 ^= tail[3] << 24;
270+
[[fallthrough]];
257271
case 3:
258272
k1 ^= tail[2] << 16;
273+
[[fallthrough]];
259274
case 2:
260275
k1 ^= tail[1] << 8;
276+
[[fallthrough]];
261277
case 1:
262278
k1 ^= tail[0] << 0;
263279
k1 *= c1;
@@ -350,37 +366,51 @@ void MurmurHash3_x64_128(const void* key, const int len, const uint32_t seed, vo
350366
switch (len & 15) {
351367
case 15:
352368
k2 ^= ((uint64_t)tail[14]) << 48;
369+
[[fallthrough]];
353370
case 14:
354371
k2 ^= ((uint64_t)tail[13]) << 40;
372+
[[fallthrough]];
355373
case 13:
356374
k2 ^= ((uint64_t)tail[12]) << 32;
375+
[[fallthrough]];
357376
case 12:
358377
k2 ^= ((uint64_t)tail[11]) << 24;
378+
[[fallthrough]];
359379
case 11:
360380
k2 ^= ((uint64_t)tail[10]) << 16;
381+
[[fallthrough]];
361382
case 10:
362383
k2 ^= ((uint64_t)tail[9]) << 8;
384+
[[fallthrough]];
363385
case 9:
364386
k2 ^= ((uint64_t)tail[8]) << 0;
365387
k2 *= c2;
366388
k2 = ROTL64(k2, 33);
367389
k2 *= c1;
368390
h2 ^= k2;
391+
[[fallthrough]];
369392

370393
case 8:
371394
k1 ^= ((uint64_t)tail[7]) << 56;
395+
[[fallthrough]];
372396
case 7:
373397
k1 ^= ((uint64_t)tail[6]) << 48;
398+
[[fallthrough]];
374399
case 6:
375400
k1 ^= ((uint64_t)tail[5]) << 40;
401+
[[fallthrough]];
376402
case 5:
377403
k1 ^= ((uint64_t)tail[4]) << 32;
404+
[[fallthrough]];
378405
case 4:
379406
k1 ^= ((uint64_t)tail[3]) << 24;
407+
[[fallthrough]];
380408
case 3:
381409
k1 ^= ((uint64_t)tail[2]) << 16;
410+
[[fallthrough]];
382411
case 2:
383412
k1 ^= ((uint64_t)tail[1]) << 8;
413+
[[fallthrough]];
384414
case 1:
385415
k1 ^= ((uint64_t)tail[0]) << 0;
386416
k1 *= c1;

src/iceberg/util/truncate_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ICEBERG_EXPORT TruncateUtils {
5858
source.resize(safe_point);
5959
}
6060

61-
return std::move(source);
61+
return source;
6262
}
6363

6464
/// \brief Truncate an integer v, either int32_t or int64_t, to v - (v % W).

0 commit comments

Comments
 (0)