public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Add missing headers to fix implicit function defns
@ 2017-01-16 9:14 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2017-01-16 9:14 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e02866a1b43fae39d6842bd182de79e54d8e74cd
commit e02866a1b43fae39d6842bd182de79e54d8e74cd
Author: Pat Pannuto <pat.pannuto@gmail.com>
Date: Sun Jan 15 19:12:02 2017 -0500
Add missing headers to fix implicit function defns
A few files were missing headers for memset/malloc, likely missed
because the files don't directly call the functions, rather they
come in via macros in libc/include/sys/reent.h:
#define _REENT_CHECK(var, what, type, size, init) do { \
struct _reent *_r = (var); \
if (_r->what == NULL) { \
_r->what = (type)malloc(size); \
#define _REENT_CHECK_ASCTIME_BUF(var) \
_REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \
memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE))
Without these fixes, implicit function signatures are provided,
which gcc warns could cause aliasing issues down the line:
../../../../../../../newlib-2.5.0/newlib/libc/time/asctime.c:62:3: warning: type of 'memset' does not match original declaration [-Wlto-type-mismatch]
/Volumes/code/external/newlib-cygwin/newlib/libc/include/string.h:29:7: note: return value type mismatch
_PTR _EXFUN(memset,(_PTR, int, size_t));
^
/Volumes/code/external/newlib-cygwin/newlib/libc/include/string.h:29:7: note: 'memset' was previously declared here
/Volumes/code/external/newlib-cygwin/newlib/libc/include/string.h:29:7: note: code may be misoptimized unless -fno-strict-aliasing is used
../../../../../../../newlib-2.5.0/newlib/libc/time/asctime.c:62:3: warning: type of 'malloc' does not match original declaration [-Wlto-type-mismatch]
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: return value type mismatch
extern _PTR malloc _PARAMS ((size_t));
^
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: 'malloc' was previously declared here
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: code may be misoptimized unless -fno-strict-aliasing is used
../../../../../../../newlib-2.5.0/newlib/libc/time/lcltime.c:58:3: warning: type of 'malloc' does not match original declaration [-Wlto-type-mismatch]
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: return value type mismatch
extern _PTR malloc _PARAMS ((size_t));
^
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: 'malloc' was previously declared here
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: code may be misoptimized unless -fno-strict-aliasing is used
../../../../../../../newlib-2.5.0/newlib/libc/string/strsignal.c:70:3: warning: type of 'malloc' does not match original declaration [-Wlto-type-mismatch]
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: return value type mismatch
extern _PTR malloc _PARAMS ((size_t));
^
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: 'malloc' was previously declared here
/Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: code may be misoptimized unless -fno-strict-aliasing is used
Including the proper headers elminates the implicit function
signatures and these warnings.
Diff:
---
newlib/libc/string/strsignal.c | 1 +
newlib/libc/string/strtok.c | 1 +
newlib/libc/time/asctime.c | 2 ++
newlib/libc/time/lcltime.c | 1 +
4 files changed, 5 insertions(+)
diff --git a/newlib/libc/string/strsignal.c b/newlib/libc/string/strsignal.c
index e03c108..94ae26d 100644
--- a/newlib/libc/string/strsignal.c
+++ b/newlib/libc/string/strsignal.c
@@ -56,6 +56,7 @@ QUICKREF
#include <string.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <reent.h>
char *
diff --git a/newlib/libc/string/strtok.c b/newlib/libc/string/strtok.c
index 21607e0..8d07ab3 100644
--- a/newlib/libc/string/strtok.c
+++ b/newlib/libc/string/strtok.c
@@ -85,6 +85,7 @@ QUICKREF
/* undef STRICT_ANSI so that strtok_r prototype will be defined */
#undef __STRICT_ANSI__
#include <string.h>
+#include <stdlib.h>
#include <_ansi.h>
#include <reent.h>
diff --git a/newlib/libc/time/asctime.c b/newlib/libc/time/asctime.c
index 024310b..f56b511 100644
--- a/newlib/libc/time/asctime.c
+++ b/newlib/libc/time/asctime.c
@@ -47,6 +47,8 @@ ANSI C requires <<asctime>>.
<<asctime>> requires no supporting OS subroutines.
*/
+#include <stdlib.h>
+#include <string.h>
#include <time.h>
#include <_ansi.h>
#include <reent.h>
diff --git a/newlib/libc/time/lcltime.c b/newlib/libc/time/lcltime.c
index 16162bf..2c9a25f 100644
--- a/newlib/libc/time/lcltime.c
+++ b/newlib/libc/time/lcltime.c
@@ -44,6 +44,7 @@ ANSI C requires <<localtime>>.
<<localtime>> requires no supporting OS subroutines.
*/
+#include <stdlib.h>
#include <time.h>
#include <reent.h>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-16 9:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-16 9:14 [newlib-cygwin] Add missing headers to fix implicit function defns Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).