diff mbox series

[nft,3/5] src: silence "implicit-fallthrough" warnings

Message ID 20230829185509.374614-4-thaller@redhat.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series fix compiler warnings with clang and "-Wextra" | expand

Commit Message

Thomas Haller Aug. 29, 2023, 6:54 p.m. UTC
Gcc with "-Wextra" warns:

    CC       segtree.lo
  segtree.c: In function 'get_set_interval_find':
  segtree.c:129:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
    129 |                         if (expr_basetype(i->key)->type != TYPE_STRING)
        |                            ^
  segtree.c:134:17: note: here
    134 |                 case EXPR_PREFIX:
        |                 ^~~~

    CC       optimize.lo
  optimize.c: In function 'rule_collect_stmts':
  optimize.c:396:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
    396 |                         if (stmt->expr->left->etype == EXPR_CONCAT) {
        |                            ^
  optimize.c:400:17: note: here
    400 |                 case STMT_VERDICT:
        |                 ^~~~

Signed-off-by: Thomas Haller <thaller@redhat.com>
---
 src/optimize.c | 1 +
 src/segtree.c  | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/optimize.c b/src/optimize.c
index 0b99b6726115..9c1704831693 100644
--- a/src/optimize.c
+++ b/src/optimize.c
@@ -397,6 +397,7 @@  static int rule_collect_stmts(struct optimize_ctx *ctx, struct rule *rule)
 				clone->ops = &unsupported_stmt_ops;
 				break;
 			}
+			/* fall-through */
 		case STMT_VERDICT:
 			clone->expr = expr_get(stmt->expr);
 			break;
diff --git a/src/segtree.c b/src/segtree.c
index a265a0b30d64..bf207402c945 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -128,9 +128,8 @@  static struct expr *get_set_interval_find(const struct set *cache_set,
 		case EXPR_VALUE:
 			if (expr_basetype(i->key)->type != TYPE_STRING)
 				break;
-			/* string type, check if its a range (wildcard), so
-			 * fall through.
-			 */
+			/* string type, check if its a range (wildcard). */
+			/* fall-through */
 		case EXPR_PREFIX:
 		case EXPR_RANGE:
 			range_expr_value_low(val, i);