diff options
author | Chih-Hung Hsieh <chh@google.com> | 2018-09-13 11:08:41 -0700 |
---|---|---|
committer | Chih-hung Hsieh <chh@google.com> | 2018-09-17 16:50:11 +0000 |
commit | 502f4864d6c92fce4cb0e4f7f2b12d7124da902b (patch) | |
tree | b34cb377a8a6543fb0baf68e566b120209b3aaf9 | |
parent | c2501fda600ea2067099c1de042e3db7acde74ee (diff) | |
download | system_core-502f4864d6c92fce4cb0e4f7f2b12d7124da902b.tar.gz system_core-502f4864d6c92fce4cb0e4f7f2b12d7124da902b.tar.bz2 system_core-502f4864d6c92fce4cb0e4f7f2b12d7124da902b.zip |
Suppress implicit-fallthrough warnings.
Add FALLTHROUGH_INTENDED for clang compiler.
Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
-rw-r--r-- | base/include/android-base/macros.h | 2 | ||||
-rw-r--r-- | liblog/tests/liblog_test.cpp | 3 | ||||
-rw-r--r-- | libpixelflinger/Android.mk | 1 | ||||
-rw-r--r-- | libpixelflinger/buffer.cpp | 9 | ||||
-rw-r--r-- | libpixelflinger/codeflinger/blending.cpp | 3 | ||||
-rw-r--r-- | libsysutils/src/SocketClient.cpp | 5 | ||||
-rw-r--r-- | libunwindstack/DwarfCfa.cpp | 7 | ||||
-rw-r--r-- | libutils/Android.bp | 1 | ||||
-rw-r--r-- | libutils/RefBase.cpp | 4 | ||||
-rw-r--r-- | libutils/Unicode.cpp | 6 | ||||
-rw-r--r-- | logcat/logcat.cpp | 13 | ||||
-rw-r--r-- | logcat/tests/logcat_test.cpp | 25 | ||||
-rw-r--r-- | logd/LogKlog.cpp | 4 |
13 files changed, 52 insertions, 31 deletions
diff --git a/base/include/android-base/macros.h b/base/include/android-base/macros.h index 49cc0c980..174866570 100644 --- a/base/include/android-base/macros.h +++ b/base/include/android-base/macros.h @@ -170,7 +170,9 @@ void UNUSED(const T&...) { // // In either case this macro has no effect on runtime behavior and performance // of code. +#ifndef FALLTHROUGH_INTENDED #define FALLTHROUGH_INTENDED [[clang::fallthrough]] // NOLINT +#endif // Current ABI string #if defined(__arm__) diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp index a8a9a120a..d1f20f495 100644 --- a/liblog/tests/liblog_test.cpp +++ b/liblog/tests/liblog_test.cpp @@ -30,6 +30,7 @@ #include <string> #include <android-base/file.h> +#include <android-base/macros.h> #include <android-base/stringprintf.h> #ifdef __ANDROID__ // includes sys/properties.h which does not exist outside #include <cutils/properties.h> @@ -2516,7 +2517,7 @@ static int android_log_buffer_to_string(const char* msg, size_t len, #endif elem.data.string = const_cast<char*>("<unknown>"); elem.len = strlen(elem.data.string); - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case EVENT_TYPE_STRING: if (elem.len <= strOutLen) { memcpy(strOut, elem.data.string, elem.len); diff --git a/libpixelflinger/Android.mk b/libpixelflinger/Android.mk index 14883f46a..8c80f6a65 100644 --- a/libpixelflinger/Android.mk +++ b/libpixelflinger/Android.mk @@ -73,6 +73,7 @@ LOCAL_SRC_FILES_mips64 := $(PIXELFLINGER_SRC_FILES_mips64) LOCAL_CFLAGS := $(PIXELFLINGER_CFLAGS) LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_C_INCLUDES += $(LOCAL_EXPORT_C_INCLUDE_DIRS) +LOCAL_HEADER_LIBRARIES := libbase_headers LOCAL_SHARED_LIBRARIES := libcutils liblog libutils include $(BUILD_SHARED_LIBRARY) diff --git a/libpixelflinger/buffer.cpp b/libpixelflinger/buffer.cpp index dcb95c5a2..ea9514ca4 100644 --- a/libpixelflinger/buffer.cpp +++ b/libpixelflinger/buffer.cpp @@ -18,6 +18,8 @@ #include <assert.h> +#include <android-base/macros.h> + #include "buffer.h" namespace android { @@ -266,8 +268,11 @@ uint32_t ggl_pack_color(context_t* c, int32_t format, p = downshift_component(p, b, hbits, lbits, f->bh, f->bl, 0, 1, -1); p = downshift_component(p, a, hbits, lbits, f->ah, f->al, 0, 1, -1); switch (f->size) { - case 1: p |= p << 8; // fallthrough - case 2: p |= p << 16; + case 1: + p |= p << 8; + FALLTHROUGH_INTENDED; + case 2: + p |= p << 16; } return p; } diff --git a/libpixelflinger/codeflinger/blending.cpp b/libpixelflinger/codeflinger/blending.cpp index a55dfe3dd..2cbb00f83 100644 --- a/libpixelflinger/codeflinger/blending.cpp +++ b/libpixelflinger/codeflinger/blending.cpp @@ -23,6 +23,7 @@ #include <stdlib.h> #include <sys/types.h> +#include <android-base/macros.h> #include <log/log.h> #include "GGLAssembler.h" @@ -301,7 +302,7 @@ void GGLAssembler::build_blend_factor( return; } } - // fall-through... + FALLTHROUGH_INTENDED; case GGL_ONE_MINUS_DST_COLOR: case GGL_DST_COLOR: case GGL_ONE_MINUS_SRC_COLOR: diff --git a/libsysutils/src/SocketClient.cpp b/libsysutils/src/SocketClient.cpp index 0625db781..fe2f3d668 100644 --- a/libsysutils/src/SocketClient.cpp +++ b/libsysutils/src/SocketClient.cpp @@ -27,6 +27,8 @@ #include <sys/types.h> #include <unistd.h> +#include <android-base/file.h> +#include <android-base/macros.h> #include <log/log.h> #include <sysutils/SocketClient.h> @@ -145,7 +147,8 @@ char *SocketClient::quoteArg(const char *arg) { switch (*arg) { case '\\': case '"': - *(current++) = '\\'; // fallthrough + *(current++) = '\\'; + FALLTHROUGH_INTENDED; default: *(current++) = *(arg++); } diff --git a/libunwindstack/DwarfCfa.cpp b/libunwindstack/DwarfCfa.cpp index cd9ef6141..0fa163820 100644 --- a/libunwindstack/DwarfCfa.cpp +++ b/libunwindstack/DwarfCfa.cpp @@ -21,6 +21,7 @@ #include <type_traits> #include <vector> +#include <android-base/macros.h> #include <android-base/stringprintf.h> #include <unwindstack/DwarfError.h> @@ -154,13 +155,15 @@ std::string DwarfCfa<AddressType>::GetOperandString(uint8_t operand, uint64_t va break; case DwarfCfaInfo::DWARF_DISPLAY_ADVANCE_LOC: *cur_pc += value; - // Fall through to log the value. + FALLTHROUGH_INTENDED; + // Fall through to log the value. case DwarfCfaInfo::DWARF_DISPLAY_NUMBER: string += " " + std::to_string(value); break; case DwarfCfaInfo::DWARF_DISPLAY_SET_LOC: *cur_pc = value; - // Fall through to log the value. + FALLTHROUGH_INTENDED; + // Fall through to log the value. case DwarfCfaInfo::DWARF_DISPLAY_ADDRESS: if (std::is_same<AddressType, uint32_t>::value) { string += android::base::StringPrintf(" 0x%" PRIx32, static_cast<uint32_t>(value)); diff --git a/libutils/Android.bp b/libutils/Android.bp index 1c1bdf788..600c91c0e 100644 --- a/libutils/Android.bp +++ b/libutils/Android.bp @@ -59,6 +59,7 @@ cc_defaults { "-Werror", ], header_libs: [ + "libbase_headers", "libutils_headers", ], export_header_lib_headers: [ diff --git a/libutils/RefBase.cpp b/libutils/RefBase.cpp index 3f1e79a04..ae107893c 100644 --- a/libutils/RefBase.cpp +++ b/libutils/RefBase.cpp @@ -19,6 +19,8 @@ #include <memory> +#include <android-base/macros.h> + #include <utils/RefBase.h> #include <utils/CallStack.h> @@ -479,7 +481,7 @@ void RefBase::forceIncStrong(const void* id) const case INITIAL_STRONG_VALUE: refs->mStrong.fetch_sub(INITIAL_STRONG_VALUE, std::memory_order_relaxed); - // fall through... + FALLTHROUGH_INTENDED; case 0: refs->mBase->onFirstRef(); } diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp index 82f650dce..5f0a51f1c 100644 --- a/libutils/Unicode.cpp +++ b/libutils/Unicode.cpp @@ -16,8 +16,9 @@ #define LOG_TAG "unicode" -#include <utils/Unicode.h> +#include <android-base/macros.h> #include <limits.h> +#include <utils/Unicode.h> #include <log/log.h> @@ -105,8 +106,11 @@ static inline void utf32_codepoint_to_utf8(uint8_t* dstP, char32_t srcChar, size switch (bytes) { /* note: everything falls through. */ case 4: *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask); srcChar >>= 6; + FALLTHROUGH_INTENDED; case 3: *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask); srcChar >>= 6; + FALLTHROUGH_INTENDED; case 2: *--dstP = (uint8_t)((srcChar | kByteMark) & kByteMask); srcChar >>= 6; + FALLTHROUGH_INTENDED; case 1: *--dstP = (uint8_t)(srcChar | kFirstByteMark[bytes]); } } diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index 0f1badb15..115b1a365 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -16,6 +16,7 @@ #include "logcat.h" +#include <android-base/macros.h> #include <arpa/inet.h> #include <assert.h> #include <ctype.h> @@ -959,7 +960,7 @@ static int __logcat(android_logcat_context_internal* context) { case 't': got_t = true; mode |= ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK; - // FALLTHRU + FALLTHROUGH_INTENDED; case 'T': if (strspn(optarg, "0123456789") != strlen(optarg)) { char* cp = parseTime(tail_time, optarg); @@ -1009,7 +1010,7 @@ static int __logcat(android_logcat_context_internal* context) { getLogSize = true; break; } - // FALLTHRU + FALLTHROUGH_INTENDED; case 'G': { char* cp; @@ -1023,15 +1024,15 @@ static int __logcat(android_logcat_context_internal* context) { case 'g': case 'G': setLogSize *= 1024; - // FALLTHRU + FALLTHROUGH_INTENDED; case 'm': case 'M': setLogSize *= 1024; - // FALLTHRU + FALLTHROUGH_INTENDED; case 'k': case 'K': setLogSize *= 1024; - // FALLTHRU + FALLTHROUGH_INTENDED; case '\0': break; @@ -1051,7 +1052,7 @@ static int __logcat(android_logcat_context_internal* context) { getPruneList = true; break; } - // FALLTHRU + FALLTHROUGH_INTENDED; case 'P': setPruneList = optarg; diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp index bebcc7192..9483bb2d5 100644 --- a/logcat/tests/logcat_test.cpp +++ b/logcat/tests/logcat_test.cpp @@ -31,6 +31,7 @@ #include <string> #include <android-base/file.h> +#include <android-base/macros.h> #include <android-base/stringprintf.h> #include <gtest/gtest.h> #include <log/event_tag_map.h> @@ -572,13 +573,13 @@ static int get_groups(const char* cmd) { switch (size_mult[0]) { case 'G': full_size *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'M': full_size *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'K': full_size *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'B': break; default: @@ -588,13 +589,13 @@ static int get_groups(const char* cmd) { switch (consumed_mult[0]) { case 'G': full_consumed *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'M': full_consumed *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'K': full_consumed *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'B': break; default: @@ -1241,26 +1242,26 @@ TEST(logcat, blocking_clear) { switch (size_mult[0]) { case 'G': full_size *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'M': full_size *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'K': full_size *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'B': break; } switch (consumed_mult[0]) { case 'G': full_consumed *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'M': full_consumed *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'K': full_consumed *= 1024; - /* FALLTHRU */ + FALLTHROUGH_INTENDED; case 'B': break; } diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp index e4393a3c1..513c0c3f9 100644 --- a/logd/LogKlog.cpp +++ b/logd/LogKlog.cpp @@ -475,9 +475,7 @@ void LogKlog::synchronize(const char* buf, ssize_t len) { static int convertKernelPrioToAndroidPrio(int pri) { switch (pri & LOG_PRIMASK) { case LOG_EMERG: - // FALLTHRU case LOG_ALERT: - // FALLTHRU case LOG_CRIT: return ANDROID_LOG_FATAL; @@ -488,9 +486,7 @@ static int convertKernelPrioToAndroidPrio(int pri) { return ANDROID_LOG_WARN; default: - // FALLTHRU case LOG_NOTICE: - // FALLTHRU case LOG_INFO: break; |