diff options
author | Kenneth Graunke <[email protected]> | 2016-11-15 11:53:33 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2016-11-17 14:14:37 -0800 |
commit | 9bfee7047b70cb0aa026ca9536465762f96cb2b1 (patch) | |
tree | 81bb846aef35496b6249cab8b3bde0ab07167ea8 /src/mesa/main/arbprogram.c | |
parent | ca76e6b5213c92432b9f3a641cb26f5861d53e09 (diff) |
mesa: Drop PATH_MAX usage.
GNU/Hurd does not define PATH_MAX since it doesn't have such arbitrary
limitation, so this failed to compile. Apparently glibc does not
enforce PATH_MAX restrictions anyway, so it's kind of a hoax:
https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html
MSVC uses a different name (_MAX_PATH) as well, which is annoying.
We don't really need it. We can simply asprintf() the filenames.
If the filename exceeds an OS path limit, presumably fopen() will
fail, and we already check that. (We actually use ralloc_asprintf
because Mesa provides that everywhere, and it doesn't look like we've
provided an implementation of GNU's asprintf() for all platforms.)
Fixes the build on GNU/Hurd.
Cc: "13.0" <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98632
Signed-off-by: Samuel Thibault <[email protected]>
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/mesa/main/arbprogram.c')
-rw-r--r-- | src/mesa/main/arbprogram.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index cb67fe33bb5..70b40b3c490 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -41,11 +41,6 @@ #include "program/program.h" #include "program/prog_print.h" -#ifdef _MSC_VER -#include <stdlib.h> -#define PATH_MAX _MAX_PATH -#endif - /** * Bind a program (make it current) * \note Called from the GL API dispatcher by both glBindProgramNV @@ -383,12 +378,12 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, const char *capture_path = _mesa_get_shader_capture_path(); if (capture_path != NULL) { FILE *file; - char filename[PATH_MAX]; const char *shader_type = target == GL_FRAGMENT_PROGRAM_ARB ? "fragment" : "vertex"; + char *filename = + ralloc_asprintf(NULL, "%s/%cp-%u.shader_test", + capture_path, shader_type[0], prog->Id); - _mesa_snprintf(filename, sizeof(filename), "%s/%cp-%u.shader_test", - capture_path, shader_type[0], prog->Id); file = fopen(filename, "w"); if (file) { fprintf(file, @@ -398,6 +393,7 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len, } else { _mesa_warning(ctx, "Failed to open %s", filename); } + ralloc_free(filename); } } |