Commit 5f91872f96 for frr
commit 5f91872f96fcd766c012b2f2cebfe9d343a1bb4a
Author: Vincent Jardin <vjardin@free.fr>
Date: Mon Nov 9 19:11:07 2026 +0100
lib: avoid the fall-through trick in defun_lex.l
The token-to-name mapping in clippy_parse() was written as a chain of
always-false "if (!(type = ...))" statements whose bodies are the next
case labels, with a "/* fallthru */" comment.
macOS clang does not honour comments for -Wimplicit-fallthrough and
it warns:
lib/defun_lex.l:332:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
Signed-off-by: Vincent Jardin <vjardin@free.fr>
diff --git a/lib/defun_lex.l b/lib/defun_lex.l
index 6180e476f0..5415368893 100644
--- a/lib/defun_lex.l
+++ b/lib/defun_lex.l
@@ -327,17 +327,23 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
PyObject *pyItem = NULL, *pyArgs;
switch (token) {
case DEFUNNY:
- if (!(type = "DEFUNNY"))
- /* fallthru */
case INSTALL:
- if (!(type = "INSTALL"))
- /* fallthru */
case AUXILIARY:
- if (!(type = "AUXILIARY"))
- /* fallthru */
case HOOK:
- if (!(type = "HOOK"))
- (void)0;
+ switch (token) {
+ case DEFUNNY:
+ type = "DEFUNNY";
+ break;
+ case INSTALL:
+ type = "INSTALL";
+ break;
+ case AUXILIARY:
+ type = "AUXILIARY";
+ break;
+ default:
+ type = "HOOK";
+ break;
+ }
off_start -= strlen(tval);