aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2018-09-05 23:41:34 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-09-05 23:41:34 -0700
commita20de6af17c3a73b6a9a88c3c7ddd4c3760ddb3f (patch)
tree3a91077c66f88c901cf4d72d7088604130f4f2ea
parent8d64d386987670c41bba3d5bd06d461eda253478 (diff)
parentbf9c33f401c1dc01fbaf97c7331a087265eafff7 (diff)
downloadpuffin-a20de6af17c3a73b6a9a88c3c7ddd4c3760ddb3f.tar.gz
Enable -Wimplicit-fallthrough. am: e117046df3 am: fdff8b5aef
am: bf9c33f401 Change-Id: Id9703852a258f98afc861d56ecc9bd400a0e1fa3
-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);