[PATCH] D53410: Add missing PATH_MAX for GNU Hurd support

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 18 13:57:54 PDT 2018


rsmith added inline comments.


================
Comment at: lib/Basic/FileManager.cpp:514-519
+// For GNU Hurd
+#if defined(__GNU__) && !defined(PATH_MAX)
+# define PATH_MAX 4096
+#endif
+
+
----------------
This doesn't appear to be necessary: the identifier PATH_MAX does not appear later in this file.


================
Comment at: lib/Frontend/ModuleDependencyCollector.cpp:102-106
+// For GNU Hurd
+#if defined(__GNU__) && !defined(PATH_MAX)
+# define PATH_MAX 4096
+#endif
+
----------------
I think this is generally the wrong way to address this problem on Hurd:

https://www.gnu.org/software/hurd/hurd/porting/guidelines.html#PATH_MAX_tt_MAX_PATH_tt_MAXPATHL

If `PATH_MAX` isn't defined, we should instead pass `NULL` to `realpath` (and deallocate the result): passing a fixed-size buffer is wrong, because we cannot assume that the real path will fit in 4096 bytes.

(If we neither have `PATH_MAX` defined nor a `realpath` that can accept a null pointer as the destination buffer, then `realpath` is unusable on that platform and there's nothing we can do there but return a `false` result to the caller of `real_path`.)


Repository:
  rC Clang

https://reviews.llvm.org/D53410





More information about the cfe-commits mailing list