aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2018-09-05 18:32:30 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-09-05 18:32:30 -0700
commitfdff8b5aef9eb05479dc741a3f7b2ddb3b3208d7 (patch)
tree3a91077c66f88c901cf4d72d7088604130f4f2ea
parent0e09828fa49698f990961be85d761a13555d8706 (diff)
parente117046df35aa9de5c7dc7215951418ce935c764 (diff)
downloadpuffin-fdff8b5aef9eb05479dc741a3f7b2ddb3b3208d7.tar.gz
Enable -Wimplicit-fallthrough.
am: e117046df3 Change-Id: I63c35b7c1d58be9133266afa6a6c9b0067717d1a
-rw-r--r--Android.bp1
-rw-r--r--src/include/puffin/common.h8
-rw-r--r--src/puff_writer.cc2
-rw-r--r--src/puffin_unittest.cc1
4 files changed, 11 insertions, 1 deletions
diff --git a/Android.bp b/Android.bp
index 819b50d..79d124a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -17,6 +17,7 @@ cc_defaults {
"-Wall",
"-Werror",
"-Wextra",
+ "-Wimplicit-fallthrough",
],
target: {
darwin: {
diff --git a/src/include/puffin/common.h b/src/include/puffin/common.h
index 527686f..4ead74d 100644
--- a/src/include/puffin/common.h
+++ b/src/include/puffin/common.h
@@ -28,6 +28,14 @@
#endif // USE_BRILLO
+#ifndef FALLTHROUGH_INTENDED
+#ifdef __clang__
+#define FALLTHROUGH_INTENDED [[clang::fallthrough]]
+#else
+#define FALLTHROUGH_INTENDED
+#endif // __clang__
+#endif // FALLTHROUGH_INTENDED
+
namespace puffin {
using Buffer = std::vector<uint8_t>;
diff --git a/src/puff_writer.cc b/src/puff_writer.cc
index 1c5c491..e26c3be 100644
--- a/src/puff_writer.cc
+++ b/src/puff_writer.cc
@@ -30,7 +30,7 @@ bool BufferPuffWriter::Insert(const PuffData& pd) {
if (pd.length == 0) {
return true;
}
- // We don't break here. It will be processed in kLiteral;
+ FALLTHROUGH_INTENDED;
case PuffData::Type::kLiteral: {
DVLOG(2) << "Write literals length: " << pd.length;
size_t length = pd.type == PuffData::Type::kLiteral ? 1 : pd.length;
diff --git a/src/puffin_unittest.cc b/src/puffin_unittest.cc
index 574c483..2ccf23f 100644
--- a/src/puffin_unittest.cc
+++ b/src/puffin_unittest.cc
@@ -54,6 +54,7 @@ class PuffinTest : public ::testing::Test {
case PuffData::Type::kLiteral:
*start = pd.byte;
start++;
+ FALLTHROUGH_INTENDED;
case PuffData::Type::kLiterals:
pd.read_fn(start, pd.length);