From 1abbfb11ff4d276425f52f9a925cb5f6a146b677 Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Wed, 5 Jul 2006 21:26:26 +0200
Subject: [PATCH] Fixed warnings.

Rev: src/backend.cmod:1.180
Rev: src/block_alloc.h:1.82
Rev: src/builtin.cmod:1.191
Rev: src/callback.c:1.37
Rev: src/errors.h:1.33
Rev: src/mapping.c:1.188
Rev: src/mapping.h:1.64
Rev: src/multiset.c:1.101
Rev: src/object.c:1.270
Rev: src/pike_embed.c:1.8
Rev: src/pike_types.c:1.254
Rev: src/signal_handler.c:1.321
---
 src/backend.cmod     |  8 +++++---
 src/block_alloc.h    |  4 ++--
 src/builtin.cmod     | 14 ++++++--------
 src/callback.c       |  9 ++++++---
 src/errors.h         |  5 +++--
 src/mapping.c        |  4 ++--
 src/mapping.h        |  4 ++--
 src/multiset.c       |  4 +++-
 src/object.c         | 19 ++++++++++++-------
 src/pike_embed.c     |  4 ++--
 src/pike_types.c     |  6 +++---
 src/signal_handler.c |  7 ++++---
 12 files changed, 50 insertions(+), 38 deletions(-)

diff --git a/src/backend.cmod b/src/backend.cmod
index ef1ca53864..470801016c 100644
--- a/src/backend.cmod
+++ b/src/backend.cmod
@@ -5,7 +5,7 @@
 */
 
 /*
- * $Id: backend.cmod,v 1.179 2006/02/21 07:07:50 mast Exp $
+ * $Id: backend.cmod,v 1.180 2006/07/05 19:24:16 mast Exp $
  *
  * Backend object.
  */
@@ -2903,7 +2903,7 @@ PIKECLASS Backend
 	    /* FIXME: This could be too late - the error might be
 	     * clobbered by the callbacks we might have called
 	     * above. */
-	    if (!getsockopt (fd, SOL_SOCKET, SO_ERROR, &err, &len)) {
+	    if (!getsockopt (fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len)) {
 	      IF_PD (fprintf (stderr,
 			      "[%d]BACKEND[%d]: POLLERR on %d, error=%d\n",
 			      THR_NO, me->id, fd, err));
@@ -3133,7 +3133,9 @@ PIKECLASS Backend
     if (timeout.tv_sec < 0)
       push_int (0);
     else
-      push_float ((float) timeout.tv_sec + (float) timeout.tv_usec / 1e6);
+      push_float (DO_NOT_WARN ((FLOAT_TYPE)
+			       (DO_NOT_WARN ((double) timeout.tv_sec) +
+				DO_NOT_WARN ((double) timeout.tv_usec) / 1e6)));
   }
 
 #ifndef tObjImpl_THREAD
diff --git a/src/block_alloc.h b/src/block_alloc.h
index 540e2e6882..abed3adce7 100644
--- a/src/block_alloc.h
+++ b/src/block_alloc.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: block_alloc.h,v 1.81 2006/03/10 05:42:53 mast Exp $
+|| $Id: block_alloc.h,v 1.82 2006/07/05 19:24:18 mast Exp $
 */
 
 #undef PRE_INIT_BLOCK
@@ -508,7 +508,7 @@ static INLINE struct DATA *						     \
  PIKE_CONCAT3(just_find_,DATA,_unlocked)(void *ptr,			     \
 					 PIKE_HASH_T hval)		     \
 {									     \
-  struct DATA *p,**pp;							     \
+  struct DATA *p;							     \
   p=PIKE_CONCAT(DATA,_hash_table)[hval];                                     \
   if(!p || p->PTR_HASH_ALLOC_DATA == ptr)				     \
   {                                                                          \
diff --git a/src/builtin.cmod b/src/builtin.cmod
index ea4cada28e..d3769974c5 100644
--- a/src/builtin.cmod
+++ b/src/builtin.cmod
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: builtin.cmod,v 1.190 2006/07/05 19:21:29 mast Exp $
+|| $Id: builtin.cmod,v 1.191 2006/07/05 19:24:18 mast Exp $
 */
 
 #include "global.h"
@@ -549,10 +549,10 @@ PIKEFUN mapping(string:mixed) gc_parameters (void|mapping(string:mixed) params)
 	  set->u.float_number < 0.0 || set->u.float_number > 1.0)	\
 	SIMPLE_BAD_ARG_ERROR ("Pike.gc_parameters", 1,			\
 			      "float between 0.0 and 1.0 for " NAME);	\
-      VAR = set->u.float_number;					\
+      VAR = DO_NOT_WARN ((double) set->u.float_number);			\
     }, {								\
       get.type = T_FLOAT;						\
-      get.u.float_number = VAR;						\
+      get.u.float_number = DO_NOT_WARN ((FLOAT_TYPE) VAR);		\
     });
 
   HANDLE_PARAM ("enabled", {
@@ -2034,8 +2034,6 @@ PIKECLASS multi_string_replace
   PIKEFUN void create(array(string)|mapping(string:string)|void from_arg,
 		      array(string)|string|void to_arg)
   {
-    int i;
-
     if (THIS->from) free_array(THIS->from);
     if (THIS->to) free_array(THIS->to);
     if (THIS->ctx.v) free_replace_many_context(&THIS->ctx);
@@ -2463,7 +2461,7 @@ PIKECLASS bootstring
 	    INT_TYPE p = output.s->len;
 	    while (--p>i)
 	      s[p] = s[p-1];
-	    s[p] = n;
+	    s[p] = DO_NOT_WARN ((p_wchar0) n);
 	  }
 	  break;
 	case 1:
@@ -2472,7 +2470,7 @@ PIKECLASS bootstring
 	    INT_TYPE p = output.s->len;
 	    while (--p>i)
 	      s[p] = s[p-1];
-	    s[p] = n;
+	    s[p] = DO_NOT_WARN ((p_wchar1) n);
 	  }
 	  break;
 	case 2:
@@ -2481,7 +2479,7 @@ PIKECLASS bootstring
 	    INT_TYPE p = output.s->len;
 	    while (--p>i)
 	      s[p] = s[p-1];
-	    s[p] = n;
+	    s[p] = DO_NOT_WARN ((p_wchar2) n);
 	  }
 	  break;
 	default:
diff --git a/src/callback.c b/src/callback.c
index dddce9ab30..0a132a6da6 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: callback.c,v 1.36 2006/01/24 12:02:37 mast Exp $
+|| $Id: callback.c,v 1.37 2006/07/05 19:24:18 mast Exp $
 */
 
 #include "global.h"
@@ -67,8 +67,7 @@ static int is_in_free_list(struct callback * c)
 
 static void check_callback_chain(struct callback_list *lst)
 {
-  int e,len=0;
-  struct callback_block *tmp;
+  int len=0;
   struct callback *foo;
   if(d_flag>4)
   {
@@ -95,8 +94,11 @@ static void check_callback_chain(struct callback_list *lst)
      * when dmalloc is used. Something like this should perhaps be
      * provided by a consistency check function in block_alloc.
      * /mast */
+    {
+      struct callback_block *tmp;
     for(tmp=callback_blocks;tmp;tmp=tmp->next)
     {
+      int e;
       for(e=0;e<CALLBACK_CHUNK;e++)
       {
 	int d;
@@ -135,6 +137,7 @@ static void check_callback_chain(struct callback_list *lst)
 	}
       }
     }
+    }
 #endif
   }
 }
diff --git a/src/errors.h b/src/errors.h
index 7d8ff63181..97d14c1a2f 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: errors.h,v 1.32 2005/01/21 14:32:30 mast Exp $
+|| $Id: errors.h,v 1.33 2006/07/05 19:24:18 mast Exp $
 */
 
 #ifdef ERR_DECLARE
@@ -47,7 +47,8 @@ struct PIKE_CONCAT(NAME,_error_struct) { \
   MAP_VARIABLE(#NAME2, CTYPE, 0, \
 	       current_offset + (((char *)&(foo.NAME2))-((char *)&foo)), RUNTYPE);
 
-#define EMPTY
+/* Reference foo just to avoid warning. */
+#define EMPTY &foo;
 
 #define ERR_INHERIT(NAME) \
   low_inherit(PIKE_CONCAT(NAME,_error_program),0,0,0,0,0);
diff --git a/src/mapping.c b/src/mapping.c
index 1d86ed8818..ae32996518 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: mapping.c,v 1.187 2006/06/21 11:33:01 mast Exp $
+|| $Id: mapping.c,v 1.188 2006/07/05 19:24:18 mast Exp $
 */
 
 #include "global.h"
@@ -117,7 +117,7 @@ BLOCK_ALLOC_FILL_PAGES(mapping, 2)
 static void check_mapping_type_fields(struct mapping *m)
 {
   INT32 e;
-  struct keypair *k=0,**prev;
+  struct keypair *k=0;
   struct mapping_data *md;
   TYPE_FIELD ind_types, val_types;
 
diff --git a/src/mapping.h b/src/mapping.h
index cd2349eb35..30ae2e937b 100644
--- a/src/mapping.h
+++ b/src/mapping.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: mapping.h,v 1.63 2006/07/05 02:19:15 mast Exp $
+|| $Id: mapping.h,v 1.64 2006/07/05 19:24:19 mast Exp $
 */
 
 #ifndef MAPPING_H
@@ -111,7 +111,7 @@ extern struct mapping *gc_internal_mapping;
       really_free_mapping(m_);						\
   }while(0)
 
-#endif	/* !DYNAMIC_MODULE */
+#endif	/* !(USE_DLL && DYNAMIC_MODULE) */
 
 /** Free only the mapping data leaving the mapping structure itself intact.
   *
diff --git a/src/multiset.c b/src/multiset.c
index 51a00ade46..3a49d5b531 100644
--- a/src/multiset.c
+++ b/src/multiset.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: multiset.c,v 1.100 2006/03/10 06:58:03 mast Exp $
+|| $Id: multiset.c,v 1.101 2006/07/05 19:24:19 mast Exp $
 */
 
 #include "global.h"
@@ -4234,6 +4234,7 @@ void init_multiset()
 #ifdef PIKE_DEBUG
   /* This test is buggy in GCC 4.0.1, hence the volatile. */
   volatile union msnode test;
+#define msnode_check(X) ((volatile union msnode *) (X))
   HDR (&test)->flags = 0;
   test.i.ind.type = (1 << 8) - 1;
   test.i.ind.subtype = (1 << 16) - 1;
@@ -4258,6 +4259,7 @@ void init_multiset()
 	       HDR(&test)->flags, MULTISET_FLAG_MASK,
 	       RB_FLAG_MASK, MULTISET_FLAG_MARKER,
 	       test.i.ind.type);
+#undef msnode_check
 #endif
 #ifndef HAVE_UNION_INIT
   svalue_int_one.u.integer = 1;
diff --git a/src/object.c b/src/object.c
index b3892e1090..09b4243e17 100644
--- a/src/object.c
+++ b/src/object.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: object.c,v 1.269 2006/01/24 13:10:27 mast Exp $
+|| $Id: object.c,v 1.270 2006/07/05 19:24:19 mast Exp $
 */
 
 #include "global.h"
@@ -462,7 +462,7 @@ struct object *decode_value_clone_object(struct svalue *prog)
 static struct pike_string *low_read_file(const char *file)
 {
   struct pike_string *s;
-  ptrdiff_t len;
+  PIKE_OFF_T len;
   FD f;
 
   while((f = fd_open(file,fd_RDONLY,0666)) <0 && errno==EINTR)
@@ -473,11 +473,16 @@ static struct pike_string *low_read_file(const char *file)
 
     len = fd_lseek(f, 0, SEEK_END);
     fd_lseek(f, 0, SEEK_SET);
-    s = begin_shared_string(len);
+
+    if (len > MAX_INT32)
+      Pike_fatal ("low_read_file(%s): File too large: %"PRINTPIKEOFFT"d b.\n",
+		  file, len);
+
+    s = begin_shared_string (DO_NOT_WARN ((ptrdiff_t) len));
 
     while(pos<len)
     {
-      tmp = fd_read(f,s->str+pos,len-pos);
+      tmp = fd_read(f,s->str+pos, DO_NOT_WARN ((ptrdiff_t) len) - pos);
       if(tmp<=0)
       {
 	if (tmp < 0) {
@@ -488,7 +493,7 @@ static struct pike_string *low_read_file(const char *file)
 	  Pike_fatal("low_read_file(%s) failed, errno=%d\n",file,errno);
 	}
 	Pike_fatal("low_read_file(%s) failed, short read: "
-		   "%"PRINTPTRDIFFT"d < %"PRINTPTRDIFFT"d\n",
+		   "%"PRINTPIKEOFFT"d < %"PRINTPIKEOFFT"d\n",
 		   file, pos, len);
       }
       pos+=tmp;
@@ -549,8 +554,8 @@ PMOD_EXPORT struct object *get_master(void)
 
     s = NULL;
     if (!fd_stat(tmp, &stat_buf)) {
-      long ts1 = stat_buf.st_mtime;
-      long ts2 = 0;		/* FIXME: Should really be MIN_INT, but... */
+      time_t ts1 = stat_buf.st_mtime;
+      time_t ts2 = 0;
 
       if (!fd_stat(master_file, &stat_buf)) {
 	ts2 = stat_buf.st_mtime;
diff --git a/src/pike_embed.c b/src/pike_embed.c
index 6e92e7297b..043b22da61 100644
--- a/src/pike_embed.c
+++ b/src/pike_embed.c
@@ -1,5 +1,5 @@
 /*
- * $Id: pike_embed.c,v 1.7 2006/02/27 12:07:10 mast Exp $
+ * $Id: pike_embed.c,v 1.8 2006/07/05 19:24:19 mast Exp $
  *
  * Pike embedding API.
  *
@@ -327,7 +327,7 @@ void init_pike_runtime(void (*exit_cb)(int))
   }
 #else /* !HAVE_GETRLIMIT || !RLIMIT_STACK */
   /* 128 MB seems a bit extreme, most OS's seem to have their limit at ~8MB */
-  Pike_interpreter.stack_top += STACK_DIRECTION * (1024*1024 * 8 - 8192 * sizeof(char *));
+  Pike_interpreter.stack_top += STACK_DIRECTION * (1024*1024 * 8 - 8192 * (ptrdiff_t) sizeof(char *));
 #ifdef STACK_DEBUG
   fprintf(stderr, "2: C-stack: 0x%08p - 0x%08p, direction:%d\n",
 	  &exit_cb, Pike_interpreter.stack_top, STACK_DIRECTION);
diff --git a/src/pike_types.c b/src/pike_types.c
index 134003fb6f..9279aaaf61 100644
--- a/src/pike_types.c
+++ b/src/pike_types.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: pike_types.c,v 1.253 2006/01/20 17:50:51 grubba Exp $
+|| $Id: pike_types.c,v 1.254 2006/07/05 19:26:26 mast Exp $
 */
 
 #include "global.h"
@@ -1077,7 +1077,7 @@ static void internal_parse_typeA(const char **_s)
 	    min=STRTOL((const char *)*s,(char **)s,0);
 	    while(ISSPACE(**s)) ++*s;
 	  } else {
-	    min = -0x80000000;
+	    min = MIN_INT32;
 	  }
 	  if(s[0][0]=='.' && s[0][1]=='.')
 	    s[0]+=2;
@@ -1090,7 +1090,7 @@ static void internal_parse_typeA(const char **_s)
 	    max=STRTOL((const char *)*s,(char **)s,0);
 	    while(ISSPACE(**s)) ++*s;
 	  } else {
-	    max = 0x7fffffff;
+	    max = MAX_INT32;
 	  }
 
 	  if(**s != ')') yyerror("Missing ')' in integer range.");
diff --git a/src/signal_handler.c b/src/signal_handler.c
index 9f76955a2e..66b55a5da7 100644
--- a/src/signal_handler.c
+++ b/src/signal_handler.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: signal_handler.c,v 1.320 2006/05/02 18:10:25 grubba Exp $
+|| $Id: signal_handler.c,v 1.321 2006/07/05 19:24:19 mast Exp $
 */
 
 #include "global.h"
@@ -1423,7 +1423,6 @@ static TH_RETURN_TYPE wait_thread(void *data)
  */
 static void f_pid_status_wait(INT32 args)
 {
-  int wait_for_stopped;
   if(THIS->pid == -1)
     Pike_error("This process object has no process associated with it.\n");
 
@@ -1456,7 +1455,8 @@ static void f_pid_status_wait(INT32 args)
     push_int(xcode);
   }
 #else
-
+  {
+    int wait_for_stopped;
   if (THIS->pid == getpid())
     Pike_error("Waiting for self.\n");
 
@@ -1585,6 +1585,7 @@ static void f_pid_status_wait(INT32 args)
   } else {
     push_int(THIS->result);
   }
+  }
 #endif /* __NT__ */
 }
 
-- 
GitLab