diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-08-22 13:36:30 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-08-23 15:10:15 +0200 |
commit | e109541fe6988fd0e73b92226f36f41abc829883 (patch) | |
tree | e865d22557f976c69f87eddff186f3e4512c969c /docs/CODING_STYLE.md | |
parent | path-util: drop the now unused dirname_malloc() (diff) | |
download | systemd-e109541fe6988fd0e73b92226f36f41abc829883.tar.xz systemd-e109541fe6988fd0e73b92226f36f41abc829883.zip |
docs: suggests people use path_extract_filename() + path_extract_directory()
Diffstat (limited to 'docs/CODING_STYLE.md')
-rw-r--r-- | docs/CODING_STYLE.md | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md index b7e700237a..ac35dc38d5 100644 --- a/docs/CODING_STYLE.md +++ b/docs/CODING_STYLE.md @@ -667,11 +667,11 @@ SPDX-License-Identifier: LGPL-2.1-or-later process, please use `_exit()` instead of `exit()`, so that the exit handlers are not run. -- We never use the POSIX version of `basename()` (which glibc defines in - `libgen.h`), only the GNU version (which glibc defines in `string.h`). The - only reason to include `libgen.h` is because `dirname()` is needed. Every - time you need that please immediately undefine `basename()`, and add a - comment about it, so that no code ever ends up using the POSIX version! +- Do not use `basename()` or `dirname()`. The semantics in corner cases are + full of pitfalls, and the fact that there are two quite different versions of + `basename()` (one POSIX and one GNU, of which the latter is much more useful) + doesn't make it bette either. Use path_extract_filename() and + path_extract_directory() instead. - Never use `FILENAME_MAX`. Use `PATH_MAX` instead (for checking maximum size of paths) and `NAME_MAX` (for checking maximum size of filenames). |