diff mbox series

rdma.c: Add <libgen.h> include for basename on musl

Message ID 20240804161054.942439-1-dilfridge@gentoo.org (mailing list archive)
State Not Applicable
Headers show
Series rdma.c: Add <libgen.h> include for basename on musl | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Andreas K. Hüttel Aug. 4, 2024, 4:10 p.m. UTC
This include file is required on musl for availability of basename.

Note that for glibc adding the include can have the side effect of
switching from the GNU implementation of basename (which does not touch
its argument) to the POSIX implementation (which under certain
circumstances modifies the string passed to it, e.g. removing trailing
slashes).

This is safe however since the C99 and C11 standard says:
> The parameters argc and argv and the strings pointed to by the argv
> array shall be modifiable by the program, and retain their last-stored
> values between program startup and program termination.
(multiple google results, unfortunately no official reference link)

Bug: https://bugs.gentoo.org/926341
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
---
Only build-tested so far, but should be straightforward enough...
---
 rdma/rdma.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Leon Romanovsky Aug. 5, 2024, 11:05 a.m. UTC | #1
On Sun, Aug 04, 2024 at 06:10:20PM +0200, Andreas K. Hüttel wrote:
> This include file is required on musl for availability of basename.
> 
> Note that for glibc adding the include can have the side effect of
> switching from the GNU implementation of basename (which does not touch
> its argument) to the POSIX implementation (which under certain
> circumstances modifies the string passed to it, e.g. removing trailing
> slashes).
> 
> This is safe however since the C99 and C11 standard says:
> > The parameters argc and argv and the strings pointed to by the argv
> > array shall be modifiable by the program, and retain their last-stored
> > values between program startup and program termination.
> (multiple google results, unfortunately no official reference link)
> 
> Bug: https://bugs.gentoo.org/926341
> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
> ---
> Only build-tested so far, but should be straightforward enough...
> ---
>  rdma/rdma.c | 1 +
>  1 file changed, 1 insertion(+)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
diff mbox series

Patch

diff --git a/rdma/rdma.c b/rdma/rdma.c
index 131c6b2a..f835bf3f 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -4,6 +4,7 @@ 
  * Authors:     Leon Romanovsky <leonro@mellanox.com>
  */
 
+#include <libgen.h>
 #include "rdma.h"
 #include "version.h"
 #include "color.h"