[PATCH] D51634: Define PATH_MAX if missing.

Richard Diamond via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 08:12:47 PDT 2018


DiamondLovesYou created this revision.
DiamondLovesYou added reviewers: Meinersbur, grosser.
Herald added subscribers: kbarton, nemanjai.
Herald added a reviewer: bollu.

Some platforms lack any PATH_MAX definition. This defines PATH_MAX to a
sensibly large size in such cases.

Also, add one to PATH_MAX for the null byte.


Repository:
  rPLO Polly

https://reviews.llvm.org/D51634

Files:
  lib/External/ppcg/cpu.c
  lib/External/ppcg/cuda_common.c
  lib/External/ppcg/ppcg.h


Index: lib/External/ppcg/ppcg.h
===================================================================
--- lib/External/ppcg/ppcg.h
+++ lib/External/ppcg/ppcg.h
@@ -10,6 +10,10 @@
 
 #include "ppcg_options.h"
 
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
 const char *ppcg_base_name(const char *filename);
 int ppcg_extract_base_name(char *name, const char *input);
 
Index: lib/External/ppcg/cuda_common.c
===================================================================
--- lib/External/ppcg/cuda_common.c
+++ lib/External/ppcg/cuda_common.c
@@ -20,7 +20,7 @@
  */
 void cuda_open_files(struct cuda_info *info, const char *input)
 {
-    char name[PATH_MAX];
+    char name[PATH_MAX + 1];
     int len;
 
     len = ppcg_extract_base_name(name, input);
Index: lib/External/ppcg/cpu.c
===================================================================
--- lib/External/ppcg/cpu.c
+++ lib/External/ppcg/cpu.c
@@ -65,7 +65,7 @@
  */
 static FILE *get_output_file(const char *input, const char *output)
 {
-	char name[PATH_MAX];
+	char name[PATH_MAX + 1];
 	const char *ext;
 	const char ppcg_marker[] = ".ppcg";
 	int len;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51634.163826.patch
Type: text/x-patch
Size: 1130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180904/c694d7e3/attachment.bin>


More information about the llvm-commits mailing list