Skip to content

Commit

Permalink
libmultipath: always use glibc basename()
Browse files Browse the repository at this point in the history
Our code relies on the non-destructive behavior of glibc's basename().
Fortunately that function is very simple, and our unit test makes
it easy to verify its functionality.
  • Loading branch information
mwilck committed Oct 27, 2020
1 parent b9ef7e5 commit 03a5456
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libmultipath/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ strchop(char *str)
return i;
}

#ifndef __GLIBC__
/*
* glibc's non-destructive version of basename()
* License: LGPL-2.1-or-later
*/
static const char *__basename(const char *filename)
{
char *p = strrchr(filename, '/');
return p ? p + 1 : filename;
}
#define basename(x) __basename(x)
#endif

int
basenamecpy (const char *src, char *dst, size_t size)
{
Expand Down

0 comments on commit 03a5456

Please sign in to comment.