Annotate fallthru switch statements 57/230057/2
authorKonrad Lipinski <k.lipinski2@samsung.com>
Tue, 7 Apr 2020 11:17:21 +0000 (13:17 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 9 Apr 2020 07:03:21 +0000 (07:03 +0000)
As of gcc 7:
* -Wimplicit-fallthrough is enabled via -Wextra
* the standard statement attribute [[fallthrough]] is supported

Change-Id: Iea6809980b5cb6c9abe28cbded74bcaa8997650d

src/manager/crypto/tz-backend/internals.cpp

index 9962cf5..be96f1f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2017-2019 Samsung Electronics Co., Ltd. All rights reserved
+ *  Copyright (c) 2017-2020 Samsung Electronics Co., Ltd. All rights reserved
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 
 #include <functional>
 
+#ifndef __has_cpp_attribute
+#define __has_cpp_attribute(_) 0
+#endif
+
+#if __has_cpp_attribute(fallthrough)
+#define fallthru [[fallthrough]]
+#else
+#define fallthru ((void)0)
+#endif
+
 namespace {
 
 using DSAPtr = std::unique_ptr<DSA, std::function<void(DSA*)>>;
@@ -395,6 +405,7 @@ RawBuffer symmetricEncrypt(const RawBuffer &key,
                                ThrowErr(Exc::Crypto::InputParam, "Invalid CTR length");
                        }
                        // no break here, we still need to slide down to executeCrypt
+                       fallthru;
                }
                case AlgoType::AES_CBC:
                case AlgoType::AES_CFB: {
@@ -445,6 +456,7 @@ RawBuffer symmetricDecrypt(const RawBuffer &key,
                                ThrowErr(Exc::Crypto::InputParam, "Invalid CTR length");
                        }
                        // no break here, we still need to slide down to executeCrypt
+                       fallthru;
                }
                case AlgoType::AES_CBC:
                case AlgoType::AES_CFB: {