Suppress implicit-fallthrough warnings.

Add FALLTHROUGH_INTENDED for clang compiler.

Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
This commit is contained in:
Chih-Hung Hsieh 2018-09-13 11:08:41 -07:00 committed by Chih-hung Hsieh
parent c2501fda60
commit 502f4864d6
13 changed files with 52 additions and 31 deletions

View file

@ -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__)

View file

@ -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);

View file

@ -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)

View file

@ -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;
}

View file

@ -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:

View file

@ -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++);
}

View file

@ -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));

View file

@ -59,6 +59,7 @@ cc_defaults {
"-Werror",
],
header_libs: [
"libbase_headers",
"libutils_headers",
],
export_header_lib_headers: [

View file

@ -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();
}

View file

@ -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]);
}
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;