-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
frr: fix compilation with GCC14 #24242
Conversation
38b6496
to
270c077
Compare
I would check if netnspath is writable. |
270c077
to
3d1f77b
Compare
@neheb
Edit: according to https://man7.org/linux/man-pages/man3/basename.3.html
So if we include I analysed a part of the code path: we start with struct event {
…
void *arg; /* event argument */
…
};
…
struct zebra_netns_info {
const char *netnspath;
unsigned int retries;
};
…
int strcmp(const char *s1, const char *s2);
…
#define strmatch(a,b) (!strcmp((a), (b)))
…
#define EVENT_ARG(X) ((X)->arg)
…
struct zebra_netns_info *zns_info = EVENT_ARG(t);
const char *netnspath;
…
netnspath = zns_info->netnspath;
…
if (strmatch(VRF_DEFAULT_NAME, basename(netnspath))) { https://github.com/FRRouting/frr/blob/9852228d1e87bdbad13e0fed8313203f00bf26af/zebra/zebra_netns_notify.c#L235 |
3d1f77b
to
fd82290
Compare
fd82290
to
c9755bb
Compare
@neheb |
basename is
yet const char* are passed. I wonder if the build warns because of this. |
c9755bb
to
3e67390
Compare
@neheb Before arm-openwrt-linux-muslgnueabi-gcc -DHAVE_CONFIG_H -DSYSCONFDIR=\"/etc/frr/\" -DCONFDATE=0 -I. -I./lib/assert -I. -I./include -I./lib -I. -I/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/usr/include -I/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include -I/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify -fms-extensions -fno-omit-frame-pointer -funwind-tables -Wall -Wextra -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wundef -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I/Volumes/wrt3200/openwrt/staging_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/usr/include -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -mfloat-abi=hard -fmacro-prefix-map=/Volumes/wrt3200/openwrt/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/frr-9852228d1e87bdbad13e0fed8313203f00bf26af=frr-9852228d1e87bdbad13e0fed8313203f00bf26af -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -c -o zebra/zebra_netns_notify.o zebra/zebra_netns_notify.c
In file included from ./lib/zebra.h:16,
from zebra/zebra_netns_notify.c:7:
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h: In function 'snprintf':
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h:101:9: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
101 | return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack());
| ^~~~~~
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h: In function 'sprintf':
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h:110:17: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
110 | __r = __orig_snprintf(__s, __b, __f, __builtin_va_arg_pack());
| ^~~
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h:114:17: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
114 | __r = __orig_sprintf(__s, __f, __builtin_va_arg_pack());
| ^~~
zebra/zebra_netns_notify.c: In function 'zebra_ns_ready_read':
zebra/zebra_netns_notify.c:265:39: warning: passing argument 1 of 'basename' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
265 | netnspath_basename = basename(netnspath);
| ^~~~~~~~~
In file included from zebra/zebra_netns_notify.c:17:
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/libgen.h:9:16: note: expected 'char *' but argument is of type 'const char *'
9 | char *basename(char *);
| ^~~~~~ After arm-openwrt-linux-muslgnueabi-gcc -DHAVE_CONFIG_H -DSYSCONFDIR=\"/etc/frr/\" -DCONFDATE=0 -I. -I./lib/assert -I. -I./include -I./lib -I. -I/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/usr/include -I/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include -I/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify -fms-extensions -fno-omit-frame-pointer -funwind-tables -Wall -Wextra -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wundef -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I/Volumes/wrt3200/openwrt/staging_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/usr/include -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -mfloat-abi=hard -fmacro-prefix-map=/Volumes/wrt3200/openwrt/build_dir/target-arm_cortex-a9+vfpv3-d16_musl_eabi/frr-9852228d1e87bdbad13e0fed8313203f00bf26af=frr-9852228d1e87bdbad13e0fed8313203f00bf26af -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -c -o zebra/zebra_netns_notify.o zebra/zebra_netns_notify.c
In file included from ./lib/zebra.h:16,
from zebra/zebra_netns_notify.c:7:
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h: In function 'snprintf':
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h:101:9: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
101 | return __orig_snprintf(__s, __n, __f, __builtin_va_arg_pack());
| ^~~~~~
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h: In function 'sprintf':
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h:110:17: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
110 | __r = __orig_snprintf(__s, __b, __f, __builtin_va_arg_pack());
| ^~~
/Volumes/wrt3200/openwrt/staging_dir/toolchain-arm_cortex-a9+vfpv3-d16_gcc-14.1.0_musl_eabi/include/fortify/stdio.h:114:17: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
114 | __r = __orig_sprintf(__s, __f, __builtin_va_arg_pack());
| ^~~ |
It looks like it is quite different from FRRouting/frr#15987 , which also tries to fix build errors for GCC14. |
@BKPepe |
It would be great if you open a PR against FRR to upstream this |
a8f360a
to
2455b35
Compare
@robimarko @neheb |
Fixes: zebra/zebra_netns_notify.c: In function 'zebra_ns_ready_read': zebra/zebra_netns_notify.c:265:40: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration] 265 | if (strmatch(VRF_DEFAULT_NAME, basename(netnspath))) { | ^~~~~~~~ Fixed by including libgen.h, then since basename may modify its parameter, allocate a copy on the stack, using strdupa, and pass the temporary string to basename. According to the man page for basename: With glibc, one gets the POSIX version of basename() when <libgen.h> is included, and the GNU version otherwise. The POSIX version of basename may modify the contents of path, so we should to pass a copy when calling this function. [1] https://man7.org/linux/man-pages/man3/basename.3.html Signed-off-by: Georgi Valkov <[email protected]>
2455b35
to
cc3480f
Compare
It seems like upstream merged it. Great work! 👏 This is how it should be. Appreciated. I will merge this once CI/CD succeeds. |
@robimarko @neheb @BKPepe Thanks! :) tests completed |
Fixes:
Maintainer: @lucize
Compile tested: WRT3200ACM
Another pending PR: #24083
@neheb @robimarko @PolynomialDivision @1715173329 @trippleflux