Brad Smith <[email protected]> writes:

> Currently there is a warning for implicit declaration of function for
> alloca() on OpenBSD and
> thus the other BSD's too with ecc-random.c, getopt.c, and pss-mgf1.c.
> The appropriate missing
> header is stdlib.h. What is the preferred method for fixing this? I
> was looking at adding stdlib.h
> to aclocal.m4 in LSH_FUNC_ALLOCA.

What do you think of the below patch?

For getopt.h, it includes stdlib.h unconditionally, just like the gnulib
version. To fix the other places, add the include in nettle-internal.h.

Regards,
/Niels

-----8<---------
diff --git a/getopt.c b/getopt.c
index 6be0aafa..9d29de7c 100644
--- a/getopt.c
+++ b/getopt.c
@@ -30,6 +30,10 @@
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
 
 /* Comment out all this code if we are using the GNU C Library, and are not
    actually compiling the library itself.  This code is part of the GNU C
@@ -50,17 +54,6 @@
 #ifndef ELIDE_CODE
 
 
-/* This needs to come after some library #include
-   to get __GNU_LIBRARY__ defined.  */
-#ifdef __GNU_LIBRARY__
-/* Don't include stdlib.h for non-GNU C libraries because some of them
-   contain conflicting prototypes for getopt.  */
-# include <stdlib.h>
-# include <unistd.h>
-#endif /* GNU C library.  */
-
-#include <string.h>
-
 #ifdef VMS
 # include <unixlib.h>
 #endif
diff --git a/hmac.c b/hmac.c
index 6ac5e11a..ea356970 100644
--- a/hmac.c
+++ b/hmac.c
@@ -36,8 +36,6 @@
 #endif
 
 #include <assert.h>
-/* Needed for alloca on freebsd */
-#include <stdlib.h>
 #include <string.h>
 
 #include "hmac.h"
diff --git a/nettle-internal.h b/nettle-internal.h
index ddc483de..ac55c459 100644
--- a/nettle-internal.h
+++ b/nettle-internal.h
@@ -36,6 +36,8 @@
 #define NETTLE_INTERNAL_H_INCLUDED
 
 #include <assert.h>
+/* Needed for alloca on freebsd */
+#include <stdlib.h>
 
 #include "nettle-meta.h"
 

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
_______________________________________________
nettle-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to