From: Paul Smith Date: Sun, 29 Nov 2020 19:28:29 +0000 (-0500) Subject: Resolve unused-result warnings for alloca(0) X-Git-Tag: 4.3.90~203 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b262ea5d8f7df10627e846cb7de3f30a2351dd1b;p=thirdparty%2Fmake.git Resolve unused-result warnings for alloca(0) * src/makeint.h (free_alloca): New macro to defeat warn_unused_result. * src/read.c (eval_makefile): Call it. (eval_buffer): Ditto. * src/remake.c (update_file): Ditto. --- diff --git a/src/makeint.h b/src/makeint.h index edd34ad8..c4cc4dfd 100644 --- a/src/makeint.h +++ b/src/makeint.h @@ -41,6 +41,13 @@ char *alloca (); # endif #endif +/* Some versions of GCC (e.g., 10.x) set the warn_unused_result attribute on + __builtin_alloca. This causes alloca(0) to fail and is not easily worked + around so make a helper. + See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055 */ + +#define free_alloca() do{ void *__p = alloca (0); (void)__p; }while(0) + /* Disable assert() unless we're a maintainer. Some asserts are compute-intensive. */ #ifndef MAKE_MAINTAINER_MODE diff --git a/src/read.c b/src/read.c index 95033a6b..b66f3d4a 100644 --- a/src/read.c +++ b/src/read.c @@ -432,7 +432,7 @@ eval_makefile (const char *filename, unsigned short flags) fclose (ebuf.fp); free (ebuf.bufstart); - alloca (0); + free_alloca (); errno = 0; return deps; @@ -474,7 +474,7 @@ eval_buffer (char *buffer, const floc *flocp) reading_file = curfile; - alloca (0); + free_alloca (); } /* Check LINE to see if it's a variable assignment or undefine. diff --git a/src/remake.c b/src/remake.c index fb237c5e..beaf7e05 100644 --- a/src/remake.c +++ b/src/remake.c @@ -337,7 +337,7 @@ update_file (struct file *file, unsigned int depth) check_renamed (f); /* Clean up any alloca() used during the update. */ - alloca (0); + free_alloca (); /* If we got an error, don't bother with double_colon etc. */ if (new && !keep_going_flag)