This is an automated email from the ASF dual-hosted git repository.
willayd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new b8eae609a3 GH-41891: [C++] Clean up implicit fallthrough warnings
(#41892)
b8eae609a3 is described below
commit b8eae609a3e27ee6a1748183d7cf4785dae55b40
Author: William Ayd <[email protected]>
AuthorDate: Wed Oct 2 14:29:35 2024 -0400
GH-41891: [C++] Clean up implicit fallthrough warnings (#41892)
### Rationale for this change
Helps clean up warnings, and at least one of these looks like a subtle bug
that may confuse developers
### What changes are included in this PR?
Added break statements where case statements were previously falling through
### Are these changes tested?
Builds cleanly
### Are there any user-facing changes?
No
* GitHub Issue: #41891
Authored-by: Will Ayd <[email protected]>
Signed-off-by: Will Ayd <[email protected]>
---
cpp/cmake_modules/SetupCxxFlags.cmake | 1 +
cpp/src/arrow/c/bridge.cc | 1 +
cpp/src/arrow/util/utf8_internal.h | 7 +++++++
cpp/src/gandiva/precompiled/hash.cc | 16 ++++++++++++++++
python/pyarrow/tests/test_cffi.py | 2 +-
5 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake
b/cpp/cmake_modules/SetupCxxFlags.cmake
index e2e1c4412a..fd26dc7dd9 100644
--- a/cpp/cmake_modules/SetupCxxFlags.cmake
+++ b/cpp/cmake_modules/SetupCxxFlags.cmake
@@ -331,6 +331,7 @@ if("${BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-conversion")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-sign-conversion")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wdate-time")
+ set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wimplicit-fallthrough")
string(APPEND CXX_ONLY_FLAGS " -Wredundant-move")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wunused-result")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER_ID
STREQUAL
diff --git a/cpp/src/arrow/c/bridge.cc b/cpp/src/arrow/c/bridge.cc
index 4f9095182f..0976a5cb61 100644
--- a/cpp/src/arrow/c/bridge.cc
+++ b/cpp/src/arrow/c/bridge.cc
@@ -2333,6 +2333,7 @@ class ArrayStreamReader {
break;
case ENOSYS:
code = StatusCode::NotImplemented;
+ break;
default:
code = StatusCode::IOError;
break;
diff --git a/cpp/src/arrow/util/utf8_internal.h
b/cpp/src/arrow/util/utf8_internal.h
index 335e875f7a..eb62f349ac 100644
--- a/cpp/src/arrow/util/utf8_internal.h
+++ b/cpp/src/arrow/util/utf8_internal.h
@@ -183,18 +183,25 @@ static inline bool ValidateUTF8Inline(const uint8_t*
data, int64_t size) {
switch (size) {
case 7:
state = internal::ValidateOneUTF8Byte(data[size - 7], state);
+ [[fallthrough]];
case 6:
state = internal::ValidateOneUTF8Byte(data[size - 6], state);
+ [[fallthrough]];
case 5:
state = internal::ValidateOneUTF8Byte(data[size - 5], state);
+ [[fallthrough]];
case 4:
state = internal::ValidateOneUTF8Byte(data[size - 4], state);
+ [[fallthrough]];
case 3:
state = internal::ValidateOneUTF8Byte(data[size - 3], state);
+ [[fallthrough]];
case 2:
state = internal::ValidateOneUTF8Byte(data[size - 2], state);
+ [[fallthrough]];
case 1:
state = internal::ValidateOneUTF8Byte(data[size - 1], state);
+ [[fallthrough]];
default:
break;
}
diff --git a/cpp/src/gandiva/precompiled/hash.cc
b/cpp/src/gandiva/precompiled/hash.cc
index eacf362308..e312c9e634 100644
--- a/cpp/src/gandiva/precompiled/hash.cc
+++ b/cpp/src/gandiva/precompiled/hash.cc
@@ -223,36 +223,50 @@ static inline gdv_uint64 murmur3_64_buf(const gdv_uint8*
key, gdv_int32 len,
switch (len & 15) {
case 15:
k2 = static_cast<gdv_uint64>(tail[14]) << 48;
+ [[fallthrough]];
case 14:
k2 ^= static_cast<gdv_uint64>(tail[13]) << 40;
+ [[fallthrough]];
case 13:
k2 ^= static_cast<gdv_uint64>(tail[12]) << 32;
+ [[fallthrough]];
case 12:
k2 ^= static_cast<gdv_uint64>(tail[11]) << 24;
+ [[fallthrough]];
case 11:
k2 ^= static_cast<gdv_uint64>(tail[10]) << 16;
+ [[fallthrough]];
case 10:
k2 ^= static_cast<gdv_uint64>(tail[9]) << 8;
+ [[fallthrough]];
case 9:
k2 ^= static_cast<gdv_uint64>(tail[8]);
k2 *= c2;
k2 = rotate_left(k2, 33);
k2 *= c1;
h2 ^= k2;
+ [[fallthrough]];
case 8:
k1 ^= static_cast<gdv_uint64>(tail[7]) << 56;
+ [[fallthrough]];
case 7:
k1 ^= static_cast<gdv_uint64>(tail[6]) << 48;
+ [[fallthrough]];
case 6:
k1 ^= static_cast<gdv_uint64>(tail[5]) << 40;
+ [[fallthrough]];
case 5:
k1 ^= static_cast<gdv_uint64>(tail[4]) << 32;
+ [[fallthrough]];
case 4:
k1 ^= static_cast<gdv_uint64>(tail[3]) << 24;
+ [[fallthrough]];
case 3:
k1 ^= static_cast<gdv_uint64>(tail[2]) << 16;
+ [[fallthrough]];
case 2:
k1 ^= static_cast<gdv_uint64>(tail[1]) << 8;
+ [[fallthrough]];
case 1:
k1 ^= static_cast<gdv_uint64>(tail[0]) << 0;
k1 *= c1;
@@ -308,8 +322,10 @@ static gdv_uint32 murmur3_32_buf(const gdv_uint8* key,
gdv_int32 len, gdv_int32
switch (len & 3) {
case 3:
lk1 = (tail[2] & 0xff) << 16;
+ [[fallthrough]];
case 2:
lk1 |= (tail[1] & 0xff) << 8;
+ [[fallthrough]];
case 1:
lk1 |= (tail[0] & 0xff);
lk1 *= c1;
diff --git a/python/pyarrow/tests/test_cffi.py
b/python/pyarrow/tests/test_cffi.py
index e994a09f92..84290a6b88 100644
--- a/python/pyarrow/tests/test_cffi.py
+++ b/python/pyarrow/tests/test_cffi.py
@@ -492,7 +492,7 @@ def test_export_import_exception_reader():
original._export_to_c(ptr_stream)
reader = pa.RecordBatchReader._import_from_c(ptr_stream)
- with pytest.raises(OSError) as exc_info:
+ with pytest.raises(NotImplementedError) as exc_info:
reader.read_next_batch()
# inner *and* outer exception should be present