prevent warnings in libc/reent folder

Message ID 002401d3a0c8$abfcef60$03f6ce20$@jasoon.nl
State New
Headers show
Series
  • prevent warnings in libc/reent folder
Related show

Commit Message

Jaap de Wolff Feb. 8, 2018, 10:36 a.m.
At this moment we get warnings while we compile the libc/reent folder.
This patch will prevent this

Jaap de Wolff

Comments

Corinna Vinschen Feb. 9, 2018, 5:16 p.m. | #1
On Feb  8 11:36, Jaap de Wolff wrote:
> At this moment we get warnings while we compile the libc/reent folder.

> This patch will prevent this


Jaap, can you please send the patches in `git format-patch' format?


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
Corinna Vinschen Feb. 9, 2018, 5:23 p.m. | #2
On Feb  8 11:36, Jaap de Wolff wrote:
> At this moment we get warnings while we compile the libc/reent folder.

> This patch will prevent this


Apart from the patch format, I'm not overly happy with adding all these
forward declararations to C files.  For instance, _fstat is already
declared in sys/stat.h and including this file should have precedence
over a local forward declaration.

Look at newlib/libc/include/sys/stat.h.  Check where the functions
are prototyped and include the matching header.  If functions are not
prototyped, add a prototype to the correct header.  The correct
header is the one where the base function (no trailing underscore)
is defined.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

Patch

=====================================PATCH===============
diff --git a/newlib/libc/reent/closer.c b/newlib/libc/reent/closer.c
index deb34b002..93251fe42 100644
--- a/newlib/libc/reent/closer.c
+++ b/newlib/libc/reent/closer.c
@@ -19,6 +19,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _close(int);
+
 /*
 FUNCTION
 	<<_close_r>>---Reentrant version of close
@@ -35,7 +38,6 @@  DESCRIPTION
 	takes a pointer to the global data block, which holds
 	<<errno>>.
 */
-
 int
 _close_r (ptr, fd)
      struct _reent *ptr;
diff --git a/newlib/libc/reent/execr.c b/newlib/libc/reent/execr.c
index 59b61223e..7b0acf384 100644
--- a/newlib/libc/reent/execr.c
+++ b/newlib/libc/reent/execr.c
@@ -27,6 +27,10 @@  int _dummy_exec_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _execve(const char *, char *const [], char *const []);
+extern int _fork();
+
 /*
 FUNCTION
 	<<_execve_r>>---Reentrant version of execve	
diff --git a/newlib/libc/reent/fcntlr.c b/newlib/libc/reent/fcntlr.c
index cd19d226f..f473af658 100644
--- a/newlib/libc/reent/fcntlr.c
+++ b/newlib/libc/reent/fcntlr.c
@@ -21,6 +21,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _fcntl(int, int, int);
+
 /*
 FUNCTION
 	<<_fcntl_r>>---Reentrant version of fcntl
diff --git a/newlib/libc/reent/fstatr.c b/newlib/libc/reent/fstatr.c
index ec906c98d..6566a09ed 100644
--- a/newlib/libc/reent/fstatr.c
+++ b/newlib/libc/reent/fstatr.c
@@ -25,6 +25,9 @@  int _dummy_fstat_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _fstat(int, struct stat *);
+
 /*
 FUNCTION
 	<<_fstat_r>>---Reentrant version of fstat
diff --git a/newlib/libc/reent/gettimeofdayr.c
b/newlib/libc/reent/gettimeofdayr.c
index 9b982a993..cf451dfc2 100644
--- a/newlib/libc/reent/gettimeofdayr.c
+++ b/newlib/libc/reent/gettimeofdayr.c
@@ -28,6 +28,9 @@  int _dummy_gettimeofday_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _gettimeofday(struct timeval *ptimeval, void *ptimezone);
+
 /*
 FUNCTION
 	<<_gettimeofday_r>>---Reentrant version of gettimeofday
diff --git a/newlib/libc/reent/isattyr.c b/newlib/libc/reent/isattyr.c
index f21bf25b2..8abde61f8 100644
--- a/newlib/libc/reent/isattyr.c
+++ b/newlib/libc/reent/isattyr.c
@@ -23,6 +23,9 @@  int _dummy_isatty_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _isatty(int);
+
 /*
 FUNCTION
 	<<_isatty_r>>---Reentrant version of isatty
diff --git a/newlib/libc/reent/linkr.c b/newlib/libc/reent/linkr.c
index b22da5f94..e86d6c75a 100644
--- a/newlib/libc/reent/linkr.c
+++ b/newlib/libc/reent/linkr.c
@@ -24,6 +24,9 @@  int _dummy_link_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _link(const char *, const char *);
+
 /*
 FUNCTION
 	<<_link_r>>---Reentrant version of link
diff --git a/newlib/libc/reent/lseekr.c b/newlib/libc/reent/lseekr.c
index ac2daaab9..5f75ae8ee 100644
--- a/newlib/libc/reent/lseekr.c
+++ b/newlib/libc/reent/lseekr.c
@@ -19,6 +19,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _lseek(int, off_t , int);
+
 /*
 FUNCTION
 	<<_lseek_r>>---Reentrant version of lseek
diff --git a/newlib/libc/reent/mkdirr.c b/newlib/libc/reent/mkdirr.c
index fd72df64c..4c7f46f70 100644
--- a/newlib/libc/reent/mkdirr.c
+++ b/newlib/libc/reent/mkdirr.c
@@ -19,6 +19,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _mkdir(const char *, int);
+
 /*
 FUNCTION
 	<<_mkdir_r>>---Reentrant version of mkdir
diff --git a/newlib/libc/reent/openr.c b/newlib/libc/reent/openr.c
index c6a7db5de..aa559a389 100644
--- a/newlib/libc/reent/openr.c
+++ b/newlib/libc/reent/openr.c
@@ -20,6 +20,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _open(const char *, int, int);
+
 /*
 FUNCTION
 	<<_open_r>>---Reentrant version of open
diff --git a/newlib/libc/reent/readr.c b/newlib/libc/reent/readr.c
index 7fccefd32..cfef1a734 100644
--- a/newlib/libc/reent/readr.c
+++ b/newlib/libc/reent/readr.c
@@ -19,6 +19,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _read(int, void *, size_t);
+
 /*
 FUNCTION
 	<<_read_r>>---Reentrant version of read
diff --git a/newlib/libc/reent/signalr.c b/newlib/libc/reent/signalr.c
index 345910e4b..9c6fa7d5d 100644
--- a/newlib/libc/reent/signalr.c
+++ b/newlib/libc/reent/signalr.c
@@ -25,6 +25,10 @@  int _dummy_link_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _kill(int, int);
+extern int _getpid();
+
 /*
 FUNCTION
 	<<_kill_r>>---Reentrant version of kill
diff --git a/newlib/libc/reent/statr.c b/newlib/libc/reent/statr.c
index 9388e0246..60d4423a4 100644
--- a/newlib/libc/reent/statr.c
+++ b/newlib/libc/reent/statr.c
@@ -26,6 +26,9 @@  int _dummy_stat_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _stat(const char *, struct stat *);
+
 /*
 FUNCTION
 	<<_stat_r>>---Reentrant version of stat
diff --git a/newlib/libc/reent/timesr.c b/newlib/libc/reent/timesr.c
index bb890035a..54ea34e9a 100644
--- a/newlib/libc/reent/timesr.c
+++ b/newlib/libc/reent/timesr.c
@@ -25,6 +25,9 @@  int _dummy_times_syscalls = 1;
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _times(struct tms *);
+
 /*
 FUNCTION
 	<<_times_r>>---Reentrant version of times
diff --git a/newlib/libc/reent/unlinkr.c b/newlib/libc/reent/unlinkr.c
index 41bac0194..ec20b01ee 100644
--- a/newlib/libc/reent/unlinkr.c
+++ b/newlib/libc/reent/unlinkr.c
@@ -20,6 +20,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _unlink(const char *);
+
 /*
 FUNCTION
 	<<_unlink_r>>---Reentrant version of unlink
diff --git a/newlib/libc/reent/writer.c b/newlib/libc/reent/writer.c
index 704aba18b..68bec8044 100644
--- a/newlib/libc/reent/writer.c
+++ b/newlib/libc/reent/writer.c
@@ -19,6 +19,9 @@ 
 #undef errno
 extern int errno;
 
+/* forward declaration */
+extern int _write(int, const void *, size_t);
+
 /*
 FUNCTION
 	<<_write_r>>---Reentrant version of write