Skip to content

Build fails with musl libc: implicit declaration of function 'basename'  #12

@ncopa

Description

@ncopa

Building source from git fails with:

Monitor.c:257:34: error: implicit declaration of function 'basename' [-Werror=implicit-function-declaration]
  257 |                                  basename(mdlist->devname));
      |                                  ^~~~~~~~
In file included from Monitor.c:25:
mdadm.h:115:20: error: format '%s' expects argument of type 'char *', but argument 4 has type 'int' [-Werror=format=]
  115 | #define DEV_MD_DIR "/dev/md/"
      |                    ^~~~~~~~~~
Monitor.c:256:81: note: in expansion of macro 'DEV_MD_DIR'
  256 |                         snprintf(st->devname, MD_NAME_MAX + sizeof(DEV_MD_DIR), DEV_MD_DIR "%s",
      |                                                                                 ^~~~~~~~~~
Monitor.c:256:94: note: format string is defined here
  256 |                    snprintf(st->devname, MD_NAME_MAX + sizeof(DEV_MD_DIR), DEV_MD_DIR "%s",
      |                                                                                        ~^
      |                                                                                         |
      |                                                                                         char *
      |                                                                                        %d
Monitor.c: In function 'check_one_sharer':
Monitor.c:492:21: error: passing argument 1 of 'strncmp' makes pointer from integer without a cast [-Werror=int-conversion]
  492 |         if (strncmp(basename(comm), Name, strlen(Name)) == 0) {
      |                     ^~~~~~~~~~~~~~
      |                     |
      |                     int
In file included from /usr/include/fortify/string.h:23,
                 from mdadm.h:48:
/usr/include/string.h:40:14: note: expected 'const char *' but argument is of type 'int'
   40 | int strncmp (const char *, const char *, size_t);
      |              ^~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:211: Monitor.o] Error 1

In POSIX basename is defined in libgen.h, but there is also a GNU implementation. I am not sure which variant mdadm intended to use?

Related downstream issue and merge request:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions