Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support POSIX basename() from musl libc #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Apr 14, 2024

  1. Support POSIX basename() from musl libc

    Musl libc 1.2.5 removed the definition of the basename() function from
    string.h and only provides it in libgen.h as the POSIX standard
    defines it.
    
    This change fixes compilation with musl libc 1.2.5.
    ````
    build_dir/target-mips_24kc_musl/tini-0.19.0/src/tini.c:227:36: error: implicit declaration of function 'basename' [-Wimplicit-function-declaration]
      227 |         fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING);
    build_dir/target-mips_24kc_musl/tini-0.19.0/src/tini.c:227:25: error: format '%s' expects argument of type 'char *', but argument 3 has type 'int' [-Werror=format=]
      227 |         fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING);
          |                        ~^          ~~~~~~~~~~~~~~
          |                         |          |
          |                         char *     int
          |                        %d
    
    ````
    
    basename() modifies the input string, copy it first with strdup(), If
    strdup() returns NULL the code will handle it.
    
    Signed-off-by: Hauke Mehrtens <[email protected]>
    hauke committed Apr 14, 2024
    Configuration menu
    Copy the full SHA
    10479a6 View commit details
    Browse the repository at this point in the history