frr: fix compilation with GCC14
authorGeorgi Valkov <gvalkov@gmail.com>
Mon, 27 May 2024 14:30:54 +0000 (17:30 +0300)
committerJosef Schlehofer <pepe.schlehofer@gmail.com>
Wed, 5 Jun 2024 14:33:49 +0000 (16:33 +0200)
commit4ef2b7e0fc3d0cb714e7522b8c9fc57185681560
tree90a3682a6b63f80b65efcb2f028f5aed533d404f
parent07c12180097283a7a53d14d173d7a7e6a1c43be8
frr: fix compilation with GCC14

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 <gvalkov@gmail.com>
net/frr/Makefile
net/frr/patches/900-gcc-14-compatibility.patch [new file with mode: 0644]