Environment:
OpenWrt version: 25.12 (master branch)
Kernel version: 6.18.31
Target architecture: x86_64
Compiler: x86_64-openwrt-linux-musl-gcc
Plugin version: latest from master branch
Description:
When trying to compile OpenAppFilter (oaf) on OpenWrt 25.12 with kernel 6.18.31, the build fails because the kernel build system uses -Werror and enables several strict warnings that are triggered by the current code. The following types of errors are observed across multiple source files (app_filter.c, af_utils.c, af_config.c, regexp.c, cJSON.c, af_client.c, af_log.c, etc.):
Missing prototypes – non-static functions without a previous prototype declaration (e.g., ipv6_to_str, add_app_feature, regexp_match, cJSON_CreateStringArray, etc.)
Unused variables – variables that are defined but never used (e.g., dst_port, drop, ct, smac, ethhdr, etc.)
Implicit fallthrough – switch cases without an explicit fallthrough annotation (e.g., in k_vsscanf and parse_string)
Missing braces around initializer – the matchfun array in regexp.c
Assignment used as truth value – lack of parentheses around assignment in conditional (e.g., if(ret = matchhere(...)))
Unused static variable – oaf_root_table defined but not used when kernel version >= 6.4.0
Sample error log:
app_filter.c:71:7: error: no previous prototype for 'ipv6_to_str' [-Werror=missing-prototypes]
af_utils.c:86:5: error: no previous prototype for 'isprint_char' [-Werror=missing-prototypes]
af_utils.c:283:30: error: this statement may fall through [-Werror=implicit-fallthrough=]
regexp.c:223:58: error: missing braces around initializer [-Werror=missing-braces]
cJSON.c:519:8: error: no previous prototype for 'cJSON_CreateStringArray' [-Werror=missing-prototypes]
af_client.c:97:5: error: no previous prototype for 'get_mac_hash_code' [-Werror=missing-prototypes]
af_log.c:141:25: error: 'oaf_root_table' defined but not used [-Werror=unused-variable]
Expected behavior:
The module should compile cleanly on OpenWrt 25.12 / kernel 6.18.31 without errors.
Suggested fixes:
Add static keyword to functions that are not used outside their translation unit.
Add proper function prototypes in headers for exported functions (e.g., regexp_match, cJSON_CreateIntArray).
Delete unused variables or mark them with __maybe_unused.
Add fallthrough; or /* fall through */ comments in switch cases.
Use #if to conditionally define unused variables/tables for newer kernels (e.g., oaf_root_table should only be defined when LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)).
Alternatively, consider adding -Wno-error to the module Makefile for compatibility with older kernels, but a proper code cleanup is preferred.
Additional note:
Many of these issues are due to recent kernel changes that enable stricter checks. A systematic review to make the code compatible with kernels >= 6.8 would be highly appreciated. I’d be happy to test a pull request if provided.
Thank you for maintaining this useful project!
Environment:
OpenWrt version: 25.12 (master branch)
Kernel version: 6.18.31
Target architecture: x86_64
Compiler: x86_64-openwrt-linux-musl-gcc
Plugin version: latest from master branch
Description:
When trying to compile OpenAppFilter (oaf) on OpenWrt 25.12 with kernel 6.18.31, the build fails because the kernel build system uses -Werror and enables several strict warnings that are triggered by the current code. The following types of errors are observed across multiple source files (app_filter.c, af_utils.c, af_config.c, regexp.c, cJSON.c, af_client.c, af_log.c, etc.):
Missing prototypes – non-static functions without a previous prototype declaration (e.g., ipv6_to_str, add_app_feature, regexp_match, cJSON_CreateStringArray, etc.)
Unused variables – variables that are defined but never used (e.g., dst_port, drop, ct, smac, ethhdr, etc.)
Implicit fallthrough – switch cases without an explicit fallthrough annotation (e.g., in k_vsscanf and parse_string)
Missing braces around initializer – the matchfun array in regexp.c
Assignment used as truth value – lack of parentheses around assignment in conditional (e.g., if(ret = matchhere(...)))
Unused static variable – oaf_root_table defined but not used when kernel version >= 6.4.0
Sample error log:
app_filter.c:71:7: error: no previous prototype for 'ipv6_to_str' [-Werror=missing-prototypes]
af_utils.c:86:5: error: no previous prototype for 'isprint_char' [-Werror=missing-prototypes]
af_utils.c:283:30: error: this statement may fall through [-Werror=implicit-fallthrough=]
regexp.c:223:58: error: missing braces around initializer [-Werror=missing-braces]
cJSON.c:519:8: error: no previous prototype for 'cJSON_CreateStringArray' [-Werror=missing-prototypes]
af_client.c:97:5: error: no previous prototype for 'get_mac_hash_code' [-Werror=missing-prototypes]
af_log.c:141:25: error: 'oaf_root_table' defined but not used [-Werror=unused-variable]
Expected behavior:
The module should compile cleanly on OpenWrt 25.12 / kernel 6.18.31 without errors.
Suggested fixes:
Add static keyword to functions that are not used outside their translation unit.
Add proper function prototypes in headers for exported functions (e.g., regexp_match, cJSON_CreateIntArray).
Delete unused variables or mark them with __maybe_unused.
Add fallthrough; or /* fall through */ comments in switch cases.
Use #if to conditionally define unused variables/tables for newer kernels (e.g., oaf_root_table should only be defined when LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)).
Alternatively, consider adding -Wno-error to the module Makefile for compatibility with older kernels, but a proper code cleanup is preferred.
Additional note:
Many of these issues are due to recent kernel changes that enable stricter checks. A systematic review to make the code compatible with kernels >= 6.8 would be highly appreciated. I’d be happy to test a pull request if provided.
Thank you for maintaining this useful project!