Skip to content

Commit 01f97ef

Browse files
authored
Fix http_parser fall-through warnings (#13)
The http_parser.c library uses legacy /* fall through */ comments to denote intentional fall-throughs in switch statements. However, Linux kernels build external modules with stricter checks. Since v5.14, the build system enforces -Wimplicit-fallthrough=5, which deprecates comment markers and requires an explicit macro (commit b7eb335e26a9, "Makefile: Enable -Wimplicit-fallthrough for Clang"). This change causes numerous build warnings when compiling http_parser.c. To resolve this without modifying the upstream source file, this commit adds a sed rule to the Makefile. This rule automatically converts the legacy comments to the kernel-preferred fallthrough; pseudo-keyword at build time, ensuring a clean build against modern kernels. Link: Documentation/process/deprecated.rst ("fallthrough")
2 parents f594192 + 3413cb3 commit 01f97ef

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ http_parser.c:
3838
@sed -i 's/#include <ctype.h>/#include "compat\/ctype.h"/' $@
3939
@sed -i 's/#include <string.h>/#include "compat\/string.h"/' $@
4040
@sed -i 's/#include <limits.h>/#include "compat\/limits.h"/' $@
41+
@sed -i -E 's@/\*[[:space:]]*fall[[:space:]-]*through[[:space:]]*\*/@fallthrough;@Ig' $@
4142
@echo "File $@ was patched."
4243
wget -q https://raw.githubusercontent.com/nodejs/http-parser/main/http_parser.h
4344
@sed -i 's/#include <stddef.h>/#include "compat\/stddef.h"/' http_parser.h

0 commit comments

Comments
 (0)