]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
docs: document not to use FILENAME_MAX in our codebase
authorLennart Poettering <lennart@poettering.net>
Mon, 8 Mar 2021 21:43:07 +0000 (22:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 8 Mar 2021 21:47:44 +0000 (22:47 +0100)
It's a weird thing. Let's explain why.

docs/CODING_STYLE.md

index 851676bc2bda1bdcb0d16083cc0968d41f0daf83..c15dc1abf7c4c49b1f00f1f522e62bb5bdc1a833 100644 (file)
@@ -587,6 +587,12 @@ layout: default
   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!
 
+- Never use FILENAME_MAX. Use PATH_MAX instead (for checking maximum size of
+  paths) and NAME_MAX (for checking maximum size of filenames). FILENAME_MAX is
+  not POSIX, and is a confusingly named alias for PATH_MAX on Linux. Note the
+  NAME_MAX does not include space for a trailing NUL, but PATH_MAX does. UNIX
+  FTW!
+
 ## Committing to git
 
 - Commit message subject lines should be prefixed with an appropriate component