From 4ee0f622625f8e7cc76488e99762a323c46df952 Mon Sep 17 00:00:00 2001
From: simonmar <unknown>
Date: Wed, 8 Dec 1999 15:47:08 +0000
Subject: [PATCH] [project @ 1999-12-08 15:47:06 by simonmar] misc ansification
 and -Wall cleanup

---
 ghc/lib/std/Time.lhs              |  2 +-
 ghc/lib/std/cbits/Makefile        |  6 +++---
 ghc/lib/std/cbits/fileGetc.c      |  4 ++--
 ghc/lib/std/cbits/fileLookAhead.c |  4 ++--
 ghc/lib/std/cbits/filePosn.c      |  9 +++-----
 ghc/lib/std/cbits/filePutc.c      | 10 ++++-----
 ghc/lib/std/cbits/getLock.c       |  4 ++--
 ghc/lib/std/cbits/inputReady.c    |  4 ++--
 ghc/lib/std/cbits/openFile.c      | 15 ++++----------
 ghc/lib/std/cbits/readFile.c      |  3 +--
 ghc/lib/std/cbits/stgio.h         | 34 +++++++++++++++----------------
 ghc/lib/std/cbits/system.c        |  5 ++---
 ghc/lib/std/cbits/timezone.c      |  5 +++--
 ghc/lib/std/cbits/writeFile.c     |  6 ++----
 14 files changed, 49 insertions(+), 62 deletions(-)

diff --git a/ghc/lib/std/Time.lhs b/ghc/lib/std/Time.lhs
index 0b8d3c5821fe..d9a336f4ae97 100644
--- a/ghc/lib/std/Time.lhs
+++ b/ghc/lib/std/Time.lhs
@@ -600,7 +600,7 @@ type MBytes = MutableByteArray RealWorld Int
 
 foreign import "libHS_cbits" "sizeof_time_t"    sizeof_time_t    :: Int
 
-foreign import "libHS_cbits" "prim_SETZONE" unsafe prim_SETZONE :: MBytes -> MBytes -> IO Int
+foreign import "libHS_cbits" "prim_SETZONE" unsafe prim_SETZONE :: MBytes -> MBytes -> IO ()
 #ifdef __HUGS__
 foreign import "libHS_cbits" "prim_toLocalTime"  unsafe prim_toLocalTime :: Int64 -> MBytes -> IO Int
 foreign import "libHS_cbits" "prim_toUTCTime"    unsafe prim_toUTCTime   :: Int64 -> MBytes -> IO Int
diff --git a/ghc/lib/std/cbits/Makefile b/ghc/lib/std/cbits/Makefile
index 9132b6e4e5be..38549e7c63f8 100644
--- a/ghc/lib/std/cbits/Makefile
+++ b/ghc/lib/std/cbits/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.11 1999/12/07 15:49:53 simonmar Exp $
+# $Id: Makefile,v 1.12 1999/12/08 15:47:07 simonmar Exp $
 
 TOP = ../../..
 include $(TOP)/mk/boilerplate.mk
@@ -15,7 +15,7 @@ C_SRCS= $(wildcard *.c)
 
 C_OBJS  = $(C_SRCS:.c=.$(way_)o)
 LIBOBJS = $(C_OBJS)
-SRC_CC_OPTS += -O -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) $(GhcLibCcOpts)
+SRC_CC_OPTS += -O -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) $(GhcLibCcOpts) -Wall
 
 ifneq "$(way)" "dll"
 SRC_CC_OPTS += -static
@@ -36,7 +36,7 @@ SRC_BLD_DLL_OPTS += -lwinmm -lwsock32 -lHSrts_imp -lgmp -L. -L../../../rts/gmp -
 #
 # Compile the files using the Haskell compiler (ghc really).
 # 
-CC=$(GHC_INPLACE)
+# CC=$(GHC_INPLACE)
 
 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
 
diff --git a/ghc/lib/std/cbits/fileGetc.c b/ghc/lib/std/cbits/fileGetc.c
index 0be92e7a10e2..3a74020f7364 100644
--- a/ghc/lib/std/cbits/fileGetc.c
+++ b/ghc/lib/std/cbits/fileGetc.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: fileGetc.c,v 1.4 1999/11/26 16:25:55 simonmar Exp $
+ * $Id: fileGetc.c,v 1.5 1999/12/08 15:47:07 simonmar Exp $
  *
  * hGetChar Runtime Support
  */
@@ -17,7 +17,7 @@ fileGetc(ptr)
 StgForeignPtr ptr;
 {
     IOFileObject* fo = (IOFileObject*)ptr;
-    int l,rc=0;
+    int rc=0;
     unsigned char c;
     
 #if 0
diff --git a/ghc/lib/std/cbits/fileLookAhead.c b/ghc/lib/std/cbits/fileLookAhead.c
index aa47301d6aa4..347853576b92 100644
--- a/ghc/lib/std/cbits/fileLookAhead.c
+++ b/ghc/lib/std/cbits/fileLookAhead.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: fileLookAhead.c,v 1.4 1999/11/25 16:54:14 simonmar Exp $
+ * $Id: fileLookAhead.c,v 1.5 1999/12/08 15:47:07 simonmar Exp $
  *
  * hLookAhead Runtime Support
  */
@@ -47,7 +47,7 @@ StgInt
 ungetChar(StgForeignPtr ptr, StgChar c)
 {
   IOFileObject* fo = (IOFileObject*)ptr;
-  int rc = 0, sz = 0;
+  int sz = 0;
 
 #if 0
   fprintf(stderr, "ug: %d %d %c\n",fo->bufRPtr, fo->bufWPtr,(char)c, fo->flags);
diff --git a/ghc/lib/std/cbits/filePosn.c b/ghc/lib/std/cbits/filePosn.c
index 90949ea5c2da..c3832864db6f 100644
--- a/ghc/lib/std/cbits/filePosn.c
+++ b/ghc/lib/std/cbits/filePosn.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: filePosn.c,v 1.5 1999/09/20 08:36:35 panne Exp $
+ * $Id: filePosn.c,v 1.6 1999/12/08 15:47:07 simonmar Exp $
  *
  * hGetPosn and hSetPosn Runtime Support
  */
@@ -57,13 +57,10 @@ StgForeignPtr ptr;
    (this is ensured by making the Haskell file posn. type abstract.)
 */
 StgInt
-setFilePosn(ptr, size, d)
-StgForeignPtr ptr;
-StgInt size;
-StgByteArray d;
+setFilePosn(StgForeignPtr ptr, StgInt size, StgByteArray d)
 {
     IOFileObject* fo = (IOFileObject*)ptr;
-    int rc, mode;
+    int rc;
     off_t offset;
 
     /*
diff --git a/ghc/lib/std/cbits/filePutc.c b/ghc/lib/std/cbits/filePutc.c
index a95cbf1beacc..f9bacd60be70 100644
--- a/ghc/lib/std/cbits/filePutc.c
+++ b/ghc/lib/std/cbits/filePutc.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: filePutc.c,v 1.10 1999/11/26 16:25:56 simonmar Exp $
+ * $Id: filePutc.c,v 1.11 1999/12/08 15:47:07 simonmar Exp $
  *
  * hPutChar Runtime Support
  */
@@ -76,19 +76,19 @@ filePutc(StgForeignPtr ptr, StgChar c)
     }
 
     /* Unbuffered, write the character directly. */
-    while (rc = (
+    while ((rc = (
 #ifdef USE_WINSOCK
 	         fo->flags & FILEOBJ_WINSOCK ?
 		 send(fo->fd, &c, 1, 0) :
-		 write(fo->fd, &c, 1)) <= 0) {
+		 write(fo->fd, &c, 1))) <= 0) {
 #else
-  	         write(fo->fd, &c, 1)) <= 0) {
+  	         write(fo->fd, &c, 1))) <= 0) {
 #endif
 
         if ( rc == -1 && errno == EAGAIN) {
 	    errno = 0;
 	    return FILEOBJ_BLOCKED_WRITE;
-	} else if (rc == 0 || rc == -1 && errno != EINTR) {
+	} else if (rc == 0 || (rc == -1 && errno != EINTR)) {
 	    cvtErrno();
 	    stdErrno();
 	    return -1;
diff --git a/ghc/lib/std/cbits/getLock.c b/ghc/lib/std/cbits/getLock.c
index 9d392c3ea74f..748ff6562b53 100644
--- a/ghc/lib/std/cbits/getLock.c
+++ b/ghc/lib/std/cbits/getLock.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: getLock.c,v 1.6 1999/05/05 10:33:16 sof Exp $
+ * $Id: getLock.c,v 1.7 1999/12/08 15:47:07 simonmar Exp $
  *
  * stdin/stout/stderr Runtime Support
  */
@@ -134,7 +134,7 @@ int
 unlockFile(fd)
 int fd;
 {
-    int i, rc;
+    int i;
 
     for (i = 0; i < readLocks; i++)
 	if (readLock[i].fd == fd) {
diff --git a/ghc/lib/std/cbits/inputReady.c b/ghc/lib/std/cbits/inputReady.c
index c1af5cc860fb..a7f1068ef03b 100644
--- a/ghc/lib/std/cbits/inputReady.c
+++ b/ghc/lib/std/cbits/inputReady.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: inputReady.c,v 1.5 1999/09/12 16:24:46 sof Exp $
+ * $Id: inputReady.c,v 1.6 1999/12/08 15:47:08 simonmar Exp $
  *
  * hReady Runtime Support
  */
@@ -56,7 +56,7 @@ StgForeignPtr ptr;
 StgInt msecs;
 {
     IOFileObject* fo = (IOFileObject*)ptr;
-    int c, fd, maxfd, ready;
+    int fd, maxfd, ready;
 #ifndef mingw32_TARGET_OS
     fd_set rfd;
     struct timeval tv;
diff --git a/ghc/lib/std/cbits/openFile.c b/ghc/lib/std/cbits/openFile.c
index 5be41540e07d..718f04efd2c2 100644
--- a/ghc/lib/std/cbits/openFile.c
+++ b/ghc/lib/std/cbits/openFile.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: openFile.c,v 1.13 1999/12/08 14:04:32 simonmar Exp $
+ * $Id: openFile.c,v 1.14 1999/12/08 15:47:08 simonmar Exp $
  *
  * openFile Runtime Support
  */
@@ -33,9 +33,7 @@
 #endif
 
 IOFileObject*
-openStdFile(fd,rd)
-StgInt fd;
-StgInt rd;
+openStdFile(StgInt fd, StgInt rd)
 {
     IOFileObject* fo;
     long fd_flags;
@@ -69,12 +67,8 @@ StgInt rd;
 #define OPENFILE_READ_WRITE 3
 
 IOFileObject*
-openFile(file, how, binary)
-StgByteArray file;
-StgInt how;
-StgInt binary;
+openFile(StgByteArray file, StgInt how, StgInt binary)
 {
-    FILE *fp;
     int fd;
     int oflags;
     int for_writing;
@@ -290,10 +284,9 @@ StgInt binary;
 
 /* `Lock' file descriptor and return file object. */
 IOFileObject*
-openFd(StgInt fd,StgInt oflags,StgInt flags)
+openFd(StgInt fd, StgInt oflags, StgInt flags)
 {
     int for_writing;
-    FILE* fp;
     IOFileObject* fo;
 
     for_writing = ( ((oflags & O_WRONLY) || (oflags & O_RDWR)) ? 1 : 0);
diff --git a/ghc/lib/std/cbits/readFile.c b/ghc/lib/std/cbits/readFile.c
index c47b56cfd978..8c3be1437d74 100644
--- a/ghc/lib/std/cbits/readFile.c
+++ b/ghc/lib/std/cbits/readFile.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: readFile.c,v 1.8 1999/09/16 13:14:43 simonmar Exp $
+ * $Id: readFile.c,v 1.9 1999/12/08 15:47:08 simonmar Exp $
  *
  * hGetContents Runtime Support
  */
@@ -211,7 +211,6 @@ readLine(ptr)
 StgForeignPtr ptr;
 {
     IOFileObject* fo = (IOFileObject*)ptr;
-    char *s;
     int rc=0, count;
 
     /* Check if someone hasn't zapped us */
diff --git a/ghc/lib/std/cbits/stgio.h b/ghc/lib/std/cbits/stgio.h
index a80db36cad1b..fcda1810014a 100644
--- a/ghc/lib/std/cbits/stgio.h
+++ b/ghc/lib/std/cbits/stgio.h
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: stgio.h,v 1.15 1999/11/26 16:25:56 simonmar Exp $
+ * $Id: stgio.h,v 1.16 1999/12/08 15:47:08 simonmar Exp $
  *
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1999
  *
@@ -199,22 +199,22 @@ StgInt showTime (StgInt, StgByteArray, StgInt, StgByteArray);
 StgInt	systemCmd (StgByteArray);
 
 /* timezone.c */
-StgInt get_tm_sec   ( StgAddr );
-StgInt get_tm_min   ( StgAddr );
-StgInt get_tm_hour  ( StgAddr );
-StgInt get_tm_mday  ( StgAddr );
-StgInt get_tm_mon   ( StgAddr );
-StgInt get_tm_year  ( StgAddr );
-StgInt get_tm_wday  ( StgAddr );
-StgInt get_tm_yday  ( StgAddr );
-StgInt get_tm_isdst ( StgAddr );
-StgAddr prim_ZONE    ( StgAddr );
-StgInt prim_GMTOFF  ( StgAddr );
-StgInt prim_SETZONE ( StgAddr, StgAddr );
-StgInt sizeof_word      ( void ); 
-StgInt sizeof_struct_tm	( void );
-StgInt sizeof_time_t    ( void );
-char*  get_ZONE     ( StgAddr );
+StgInt  get_tm_sec       ( StgAddr );
+StgInt  get_tm_min       ( StgAddr );
+StgInt  get_tm_hour      ( StgAddr );
+StgInt  get_tm_mday      ( StgAddr );
+StgInt  get_tm_mon       ( StgAddr );
+StgInt  get_tm_year      ( StgAddr );
+StgInt  get_tm_wday      ( StgAddr );
+StgInt  get_tm_yday      ( StgAddr );
+StgInt  get_tm_isdst     ( StgAddr );
+StgAddr prim_ZONE        ( StgAddr );
+StgInt  prim_GMTOFF      ( StgAddr );
+void    prim_SETZONE     ( StgAddr, StgAddr );
+StgInt  sizeof_word      ( void ); 
+StgInt  sizeof_struct_tm ( void );
+StgInt  sizeof_time_t    ( void );
+char*   get_ZONE         ( StgAddr );
 
 /* toLocalTime.c */
 StgAddr toLocalTime (StgInt, StgByteArray, StgByteArray);
diff --git a/ghc/lib/std/cbits/system.c b/ghc/lib/std/cbits/system.c
index 2349ea7c3ca4..7779139b4b1d 100644
--- a/ghc/lib/std/cbits/system.c
+++ b/ghc/lib/std/cbits/system.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: system.c,v 1.5 1999/03/01 08:57:57 sof Exp $
+ * $Id: system.c,v 1.6 1999/12/08 15:47:08 simonmar Exp $
  *
  * system Runtime Support
  */
@@ -28,8 +28,7 @@
 #endif
 
 StgInt
-systemCmd(cmd)
-StgByteArray cmd;
+systemCmd(StgByteArray cmd)
 {
 #if defined(mingw32_TARGET_OS)
   if (system(cmd) < 0) {
diff --git a/ghc/lib/std/cbits/timezone.c b/ghc/lib/std/cbits/timezone.c
index 2866508ca7dd..a54bc1de49b0 100644
--- a/ghc/lib/std/cbits/timezone.c
+++ b/ghc/lib/std/cbits/timezone.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: timezone.c,v 1.5 1999/09/19 19:22:14 sof Exp $
+ * $Id: timezone.c,v 1.6 1999/12/08 15:47:08 simonmar Exp $
  *
  * Timezone Runtime Support
  */
@@ -22,7 +22,8 @@ StgInt get_tm_isdst ( StgAddr x ) { return ((struct tm*)x)->tm_isdst; }
 StgAddr prim_ZONE    ( StgAddr x ) { return ZONE(x);   }
 StgInt prim_GMTOFF  ( StgAddr x ) { return GMTOFF(x); }
 
-StgInt prim_SETZONE ( StgAddr x, StgAddr y )
+void 
+prim_SETZONE ( StgAddr x, StgAddr y )
 {
   SETZONE(x,y);
 }
diff --git a/ghc/lib/std/cbits/writeFile.c b/ghc/lib/std/cbits/writeFile.c
index 108ce99229fa..5255ea91ebb3 100644
--- a/ghc/lib/std/cbits/writeFile.c
+++ b/ghc/lib/std/cbits/writeFile.c
@@ -1,7 +1,7 @@
 /* 
  * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
  *
- * $Id: writeFile.c,v 1.11 1999/11/26 16:25:57 simonmar Exp $
+ * $Id: writeFile.c,v 1.12 1999/12/08 15:47:08 simonmar Exp $
  *
  * hPutStr Runtime Support
  */
@@ -23,8 +23,6 @@ writeFileObject(StgForeignPtr ptr, StgInt bytes)
     int rc=0;
     IOFileObject* fo = (IOFileObject*)ptr;
 
-    char *p = (char *) fo->buf;
-
     /* If we've got a r/w file object in our hand, flush the
        (input) buffer contents first.
     */
@@ -40,7 +38,7 @@ writeFileObject(StgForeignPtr ptr, StgInt bytes)
 StgInt
 writeBuffer(StgForeignPtr ptr, StgInt bytes)
 {
-    int count, rc=0;
+    int count;
     IOFileObject* fo = (IOFileObject*)ptr;
 
     char *pBuf = (char *) fo->buf + fo->bufStart;
-- 
GitLab