Skip to contentSkip to conversation

include libgen.h for basename API prototype

PATCH In review Khem Raj 2 participants 2 messages Mar 25, 2024 – Mar 26, 2024

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 include libgen.h for basename API prototype

basename prototype has been removed from string.h from latest musl [1] compilers e.g. clang-18 flags the absense of prototype as error. therefore include libgen.h for providing it.

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

---
 common/main.c    | 1 +
 invutil/invidx.c | 1 +
 2 files changed, 2 insertions(+)
common/main.c +1 -0
index 1db07d4..ca3b7d4 100644
@@ -16,6 +16,7 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <libgen.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
invutil/invidx.c +1 -0
index 5874e8d..c4e2e21 100644
@@ -19,6 +19,7 @@
 #include <xfs/xfs.h>
 #include <xfs/jdm.h>
 
+#include <libgen.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
Signature · 1 line
2.44.0
#1 lore raw
Quoted 5 lines · Khem Raj

basename prototype has been removed from string.h from latest musl [1] compilers e.g. clang-18 flags the absense of prototype as error. therefore include libgen.h for providing it.

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

The basename(3) manpage makes reference to glibc's POSIX implementation modifying the string argument passed in. Is that going to cause problems with the existing callsites in xfsdump?

--D

Quoted 34 lines
---
 common/main.c    | 1 +
 invutil/invidx.c | 1 +
 2 files changed, 2 insertions(+)
common/main.c +1 -0
index 1db07d4..ca3b7d4 100644
@@ -16,6 +16,7 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <libgen.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
invutil/invidx.c +1 -0
index 5874e8d..c4e2e21 100644
@@ -19,6 +19,7 @@
 #include <xfs/xfs.h>
 #include <xfs/jdm.h>
 
+#include <libgen.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
Signature · 1 line
2.44.0