Skip to content

Commit

Permalink
drop all uses of basename(2)
Browse files Browse the repository at this point in the history
the POSIX variant of basename(2) can freely write
to the string it is passed. in all call sites, we
were passing a const char* ultimately sourced
from argv[0], to which we must not write. the GNU
variant doesn't have this behavior, but we can't
assume that variant on e.g. musl.

so just drop the basename() calls entirely. they
didn't add much, and arguably lost information.

thanks to znley and celeste of alpine for bringing
this to my attention in

https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/71142

 alpine linux: always kicking ass
  • Loading branch information
dankamongmen committed Aug 30, 2024
1 parent 9cd2998 commit aa4b53c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/growlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -1501,14 +1501,14 @@ watch_dir(int fd, const char *dfp, eventfxn fxn, int *wd, int timeout){

static void
version(const char *name){
diag("%s version %s\n", basename(name), VERSION);
diag("%s version %s\n", name, VERSION);
}

static void
usage(const char *name, int disphelp){
diag("usage: %s [ -h|--help ] [ -v|--verbose ] [ -V|--version ]\n"
"\t[ -t|--target=path ] [ --notroot ] [ -i|--import ]%s\n",
basename(name), disphelp ? " [ --disphelp ]" : "");
name, disphelp ? " [ --disphelp ]" : "");
}

static int
Expand Down

0 comments on commit aa4b53c

Please sign in to comment.