Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx-util: do not use fallthrough attribute #15661

Merged
merged 1 commit into from
May 29, 2021

Conversation

peter-stadler
Copy link
Contributor

Maintainer: me
Compile tested: x86_64, x86_64 qemu, master
Run tested: x86_64, x86_64 qemu, master, run tests

Description: fix compile warning/error (issue #15653)

@ptpt52
Copy link
Contributor

ptpt52 commented May 19, 2021

looks like a wrong fix

@peter-stadler
Copy link
Contributor Author

Do you know a better method? Else: It should work, duplicating the code instead of falling through ...

@ptpt52
Copy link
Contributor

ptpt52 commented May 19, 2021

try this:

diff --git a/net/nginx-util/src/nginx-ssl-util.hpp b/net/nginx-util/src/nginx-ssl-util.hpp
index 4f12925db..b52346b7f 100644
--- a/net/nginx-util/src/nginx-ssl-util.hpp
+++ b/net/nginx-util/src/nginx-ssl-util.hpp
@@ -166,8 +166,10 @@ static constexpr auto _escape = _Line{
         std::string ret{};
         for (char c : strptr) {
             switch (c) {
-                case '^': ret += '\\'; [[fallthrough]];
-                case '_': [[fallthrough]];
+                case '^': ret += '\\';
+                         /* fallthrough */
+                case '_':
+                         /* fallthrough */
                 case '-': ret += c; break;
                 default:
                     if ((isalpha(c) != 0) || (isdigit(c) != 0)) {

do not use [[fallthrough]]

@ptpt52
Copy link
Contributor

ptpt52 commented May 19, 2021

or more simple:

diff --git a/net/nginx-util/src/nginx-ssl-util.hpp b/net/nginx-util/src/nginx-ssl-util.hpp
index 4f12925db..4484b3550 100644
--- a/net/nginx-util/src/nginx-ssl-util.hpp
+++ b/net/nginx-util/src/nginx-ssl-util.hpp
@@ -166,8 +166,8 @@ static constexpr auto _escape = _Line{
         std::string ret{};
         for (char c : strptr) {
             switch (c) {
-                case '^': ret += '\\'; [[fallthrough]];
-                case '_': [[fallthrough]];
+                case '^': ret += '\\'; /* fallthrough */
+                case '_': /* fallthrough */
                 case '-': ret += c; break;
                 default:
                     if ((isalpha(c) != 0) || (isdigit(c) != 0)) {

@peter-stadler
Copy link
Contributor Author

I changed it, thank you :-)
Do you happen to know why the [[fallthrough]]; attribute is not working anymore?

@peter-stadler
Copy link
Contributor Author

I thought about the c++17 standard attribute not the legacy one, but it is not that important ...

fixes issue openwrt#15653

Signed-off-by: Peter Stadler <peter.stadler@student.uibk.ac.at>
@peter-stadler
Copy link
Contributor Author

I am not sure if the comment /* fallthrough */ would work with gcc 10, so I copy the ret += c; break; instead of falling through.

(The command fallthrough; would work, too, but AFAIK it is not standard c++ and clang-tidy is not recognizing it. So I hesitate using it here.)

@neheb neheb merged commit 26337dd into openwrt:master May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants