Message ID | 20240214205523.1109159-1-denkenz@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | wiphy: Remove basename() use | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
prestwoj/iwd-alpine-ci-fetch | success | Fetch PR |
prestwoj/iwd-ci-gitlint | success | GitLint |
prestwoj/iwd-ci-fetch | success | Fetch PR |
prestwoj/iwd-alpine-ci-makedistcheck | success | Make Distcheck |
prestwoj/iwd-alpine-ci-incremental_build | success | Incremental build not run PASS |
prestwoj/iwd-ci-makedistcheck | success | Make Distcheck |
prestwoj/iwd-ci-incremental_build | success | Incremental build not run PASS |
prestwoj/iwd-ci-build | success | Build - Configure |
prestwoj/iwd-alpine-ci-build | success | Build - Configure |
prestwoj/iwd-ci-makecheck | success | Make Check |
prestwoj/iwd-ci-makecheckvalgrind | success | Make Check w/Valgrind |
prestwoj/iwd-ci-clang | success | clang PASS |
prestwoj/iwd-alpine-ci-makecheckvalgrind | success | Make Check w/Valgrind |
prestwoj/iwd-alpine-ci-makecheck | success | Make Check |
prestwoj/iwd-ci-testrunner | success | test-runner PASS |
On 2/14/24 14:55, Denis Kenzior wrote: > basename use is considered harmful. There are two versions of > basename (see man 3 basename for details). The more intuitive version, > which is currently being used inside wiphy.c, is not supported by musl > libc implementation. Use of the libgen version is not preferred, so > drop use of basename entirely. Since wiphy.c is the only call site of > basename() inside iwd, open code the required logic. > --- > src/wiphy.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > Applied.
diff --git a/src/wiphy.c b/src/wiphy.c index 3258b761af15..0d64b1b31eb8 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -1896,6 +1896,7 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy) unsigned int j; const struct l_settings *config = iwd_get_config(); char **flag_list; + char *driver; driver_link = l_strdup_printf("/sys/class/ieee80211/%s/device/driver", wiphy->name); @@ -1907,7 +1908,9 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy) } driver_path[len] = '\0'; - wiphy->driver_str = l_strdup(basename(driver_path)); + + driver = memrchr(driver_path, '/', len); + wiphy->driver_str = l_strdup(driver ? driver + 1 : driver_path); for (i = 0; i < L_ARRAY_SIZE(driver_infos); i++) if (!fnmatch(driver_infos[i].prefix, wiphy->driver_str, 0))