Skip to content

Conversation

@bkuhls
Copy link

@bkuhls bkuhls commented Nov 27, 2025

Fixes various build errors like

block.c: In function 'block_set_devnode':
block.c:226:22: error: implicit declaration of function 'basename'
 [-Wimplicit-function-declaration]
  226 |         char *name = basename(device->sysfs_path);

Recorded by the buildroot autobuilders:
https://autobuild.buildroot.net/results/942/942cb2dcd061b8620211b63d4be34dc414251b62/build-end.log

Alpine Linux contains a similar patch for ledmon v1.0.0:
https://gitlab.alpinelinux.org/p_q/aports/-/blob/master/testing/ledmon/gcc14-basename.patch

@bkucman
Copy link
Collaborator

bkucman commented Dec 1, 2025

Hi, thansk for your fix.

It looks like this fix breaks basic compatibility; I’ve already seen a solution for a similar issue that is safer.
md-raid-utilities/mdadm#12
md-raid-utilities/mdadm#14

bkuhls added a commit to bkuhls/ledmon that referenced this pull request Dec 1, 2025
If GNU basename is not avilable, define it. It is safer to use that
rather than include libgen.h with XPG basename() definition.

Suggested in
md-raid-utilities#272 (comment)

Code copied from
md-raid-utilities/mdadm@9dbd11e
@bkuhls
Copy link
Author

bkuhls commented Dec 1, 2025

I’ve already seen a solution for a similar issue that is safer.
md-raid-utilities/mdadm#12
md-raid-utilities/mdadm#14

Hi, thanks for the review. I force-pushed a new patch which fixes the problem reported by buildroot toolchains with musl and does not introduce build errors for uClibc and glibc. I hope that I used the correct header file.

Copy link
Collaborator

@bkucman bkucman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
In my opinion, this is a right header for this define.

please fix style issues.

If GNU basename is not avilable, define it. It is safer to use that
rather than include libgen.h with XPG basename() definition.

Suggested in https://github.com/md-raid-utilities/ledmon/pull/
272#issuecomment-3596495739

Code copied from
md-raid-utilities/mdadm@9dbd11e

Signed-off-by: Bernd Kuhls <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants