From 2d76f25b41ffe54b59ae54311e50cd18efd40ad8 Mon Sep 17 00:00:00 2001
From: Martin Stjernholm <mast@lysator.liu.se>
Date: Fri, 20 May 2005 00:35:40 +0200
Subject: [PATCH] Fixed various type errors for 64 bit architectures and other
 warnings. (Most are in harmless debug messages, but anyway..)

Rev: src/array.c:1.181
Rev: src/backend.cmod:1.175
Rev: src/builtin_functions.c:1.599
Rev: src/code/bytecode.h:1.11
Rev: src/encode.c:1.228
Rev: src/gc.c:1.270
Rev: src/interpret_functions.h:1.184
Rev: src/las.c:1.364
Rev: src/modules/Image/image.c:1.222
Rev: src/modules/Parser/html.c:1.177
Rev: src/modules/_Charset/iso2022.c:1.38
Rev: src/modules/files/file.c:1.351
Rev: src/modules/files/sendfile.c:1.72
Rev: src/modules/spider/xml.c:1.75
Rev: src/modules/system/memory.c:1.34
Rev: src/object.c:1.267
Rev: src/peep.c:1.106
Rev: src/pike_types.c:1.247
Rev: src/post_modules/Shuffler/a_source_system_memory.c:1.12
Rev: src/post_modules/Shuffler/b_source_normal_file.c:1.14
Rev: src/program.c:1.588
Rev: src/rbtree.c:1.25
Rev: src/threads.c:1.244
---
 src/array.c                                   | 13 ++++------
 src/backend.cmod                              |  7 +++---
 src/builtin_functions.c                       |  5 ++--
 src/code/bytecode.h                           |  4 +--
 src/encode.c                                  | 16 ++++++------
 src/gc.c                                      |  7 +++---
 src/interpret_functions.h                     |  4 +--
 src/las.c                                     |  4 +--
 src/modules/Image/image.c                     |  4 +--
 src/modules/Parser/html.c                     | 22 +++++++++-------
 src/modules/_Charset/iso2022.c                |  3 ++-
 src/modules/files/file.c                      |  4 +--
 src/modules/files/sendfile.c                  |  4 +--
 src/modules/spider/xml.c                      |  4 +--
 src/modules/system/memory.c                   |  4 +--
 src/object.c                                  |  5 ++--
 src/peep.c                                    |  9 ++++---
 src/pike_types.c                              |  9 ++++---
 .../Shuffler/a_source_system_memory.c         |  4 +--
 .../Shuffler/b_source_normal_file.c           |  6 ++---
 src/program.c                                 | 25 +++++++++++--------
 src/rbtree.c                                  | 17 +++++++------
 src/threads.c                                 |  4 +--
 23 files changed, 100 insertions(+), 84 deletions(-)

diff --git a/src/array.c b/src/array.c
index 3fa35546ee..89054bd819 100644
--- a/src/array.c
+++ b/src/array.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: array.c,v 1.180 2005/04/06 18:43:39 grubba Exp $
+|| $Id: array.c,v 1.181 2005/05/19 22:35:23 mast Exp $
 */
 
 #include "global.h"
@@ -292,8 +292,7 @@ PMOD_EXPORT void simple_array_index_no_free(struct svalue *s,
 	if (a->size) {
 	  index_error(0,0,0,&tmp,ind,
 		      "Index %"PRINTPIKEINT"d is out of array range "
-		      "%"PRINTPTRDIFFT"d..%"PRINTPTRDIFFT"d.\n",
-		      p, -a->size, a->size-1);
+		      "%d..%d.\n", p, -a->size, a->size-1);
 	} else {
 	  index_error(0,0,0,&tmp,ind,
 		      "Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);
@@ -345,8 +344,7 @@ PMOD_EXPORT void simple_set_index(struct array *a,struct svalue *ind,struct sval
       if(i<0 || i>=a->size) {
 	if (a->size) {
 	  Pike_error("Index %"PRINTPIKEINT"d is out of array range "
-		     "%"PRINTPTRDIFFT"d..%"PRINTPTRDIFFT"d.\n",
-		     p, -a->size, a->size-1);
+		     "%d..%d.\n", p, -a->size, a->size-1);
 	} else {
 	  Pike_error("Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);
 	}
@@ -1337,8 +1335,7 @@ PMOD_EXPORT union anything *array_get_item_ptr(struct array *a,
   if(i<0 || i>=a->size) {
     if (a->size) {
       Pike_error("Index %"PRINTPIKEINT"d is out of array range "
-		 "%"PRINTPTRDIFFT"d..%"PRINTPTRDIFFT"d.\n",
-		 p, -a->size, a->size-1);
+		 "%d..%d.\n", p, -a->size, a->size-1);
     } else {
       Pike_error("Attempt to index the empty array with %"PRINTPIKEINT"d.\n", p);
     }
@@ -2236,7 +2233,7 @@ PMOD_EXPORT void apply_array(struct array *a, INT32 args)
   check_stack(120 + args + 1);
 
   /* FIXME: Ought to use a better key on the arguments below. */
-  if (!(cycl = (struct array *)BEGIN_CYCLIC(a, args))) {
+  if (!(cycl = (struct array *)BEGIN_CYCLIC(a, (ptrdiff_t) args))) {
     BEGIN_AGGREGATE_ARRAY(a->size) {
       SET_CYCLIC_RET(Pike_sp[-1].u.array);
       for (e=0;e<a->size;e++) {
diff --git a/src/backend.cmod b/src/backend.cmod
index 0611323d1d..f386af0bae 100644
--- a/src/backend.cmod
+++ b/src/backend.cmod
@@ -5,7 +5,7 @@
 */
 
 /*
- * $Id: backend.cmod,v 1.174 2005/04/13 14:16:43 grubba Exp $
+ * $Id: backend.cmod,v 1.175 2005/05/19 22:35:24 mast Exp $
  *
  * Backend object.
  */
@@ -78,7 +78,7 @@
 #endif
 
 #ifdef PIKE_THREADS
-#define THR_NO PTR_TO_INT (THREAD_T_TO_PTR (th_self()))
+#define THR_NO (int) PTR_TO_INT (THREAD_T_TO_PTR (th_self()))
 #else
 #define THR_NO getpid()
 #endif
@@ -198,7 +198,8 @@ static void low_set_backend_for_fd(int fd, struct Backend_struct *b)
     }
     if(!fd_map)
       Pike_fatal("Out of memory in backend:low_set_backend_for_fd.\n"
-	"Tried to allocate %d bytes.\n",sizeof(struct Backend_struct *) * fd_map_size);
+		 "Tried to allocate %"PRINTSIZET"d bytes.\n",
+		 sizeof(struct Backend_struct *) * fd_map_size);
     
     MEMSET(fd_map+old,0,sizeof(struct Backend_struct *) * (fd_map_size-old));
   }
diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index d85e84ff13..62df470b13 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.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: builtin_functions.c,v 1.598 2005/05/08 11:15:24 nilsson Exp $
+|| $Id: builtin_functions.c,v 1.599 2005/05/19 22:35:25 mast Exp $
 */
 
 #include "global.h"
@@ -2190,7 +2190,8 @@ PMOD_EXPORT void f_utf8_to_string(INT32 args)
 
 #ifdef PIKE_DEBUG
   if (j != len) {
-    Pike_fatal("utf8_to_string(): Calculated and actual lengths differ: %d != %d\n",
+    Pike_fatal("utf8_to_string(): Calculated and actual lengths differ: "
+	       "%"PRINTPTRDIFFT"d != %"PRINTPTRDIFFT"d\n",
 	  len, j);
   }
 #endif /* PIKE_DEBUG */
diff --git a/src/code/bytecode.h b/src/code/bytecode.h
index e4516cacc1..e353d9c232 100644
--- a/src/code/bytecode.h
+++ b/src/code/bytecode.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: bytecode.h,v 1.10 2003/06/03 18:05:58 mast Exp $
+|| $Id: bytecode.h,v 1.11 2005/05/19 22:35:35 mast Exp $
 */
 
 #define UPDATE_PC()
@@ -25,7 +25,7 @@
 #define CHECK_RELOC(REL, PROG_SIZE)		\
   do {						\
     if ((REL) > (PROG_SIZE)-4) {		\
-      Pike_error("Bad relocation: %d > %d\n",	\
+      Pike_error("Bad relocation: %"PRINTSIZET"d > %"PRINTSIZET"d\n",	\
 		 (REL), (PROG_SIZE)-4);		\
     }						\
   } while(0)
diff --git a/src/encode.c b/src/encode.c
index cd3596ba8b..271991b6ba 100644
--- a/src/encode.c
+++ b/src/encode.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: encode.c,v 1.227 2004/12/20 13:14:49 mast Exp $
+|| $Id: encode.c,v 1.228 2005/05/19 22:35:26 mast Exp $
 */
 
 #include "global.h"
@@ -2281,7 +2281,8 @@ static INT32 decode_portable_bytecode(INT32 string_no)
   bytecode = p->strings[string_no];
 
   if (bytecode->len % 3) {
-    Pike_error("Bad bytecode string length: %d (expected multiple of 3).\n",
+    Pike_error("Bad bytecode string length: "
+	       "%"PRINTPTRDIFFT"d (expected multiple of 3).\n",
 	       bytecode->len);
   }
 
@@ -3465,7 +3466,7 @@ static void decode_value2(struct decode_data *data)
 	   * __pragma_save_parent__.
 	   */
 	  lex.pragmas = (old_pragmas & ~ID_SAVE_PARENT)|ID_DONT_SAVE_PARENT;
-	  SET_ONERROR(err2, set_lex_pragmas, old_pragmas);
+	  SET_ONERROR(err2, set_lex_pragmas, (ptrdiff_t) old_pragmas);
 
 	  /* Start the new program. */
 	  orig_compilation_depth = compilation_depth;
@@ -3563,7 +3564,7 @@ static void decode_value2(struct decode_data *data)
 	    for (e=0; e<(int)local_num_relocations; e++) {
 	      size_t reloc;
 	      decode_number(reloc, data);
-	      CHECK_RELOC(reloc, local_num_program);
+	      CHECK_RELOC(reloc, (size_t) local_num_program);
 	      add_to_relocations(reloc);
 	    }
 
@@ -4108,9 +4109,10 @@ static void decode_value2(struct decode_data *data)
 	    ref_push_program (p);					\
 	    decode_error(Pike_sp - 1, NULL,				\
 			 "Value mismatch for num_" TOSTR(NAME) ": "	\
-			 "%d != %d (bytecode method: %d)\n",		\
-			 PIKE_CONCAT(local_num_, NAME),			\
-			 p->PIKE_CONCAT(num_, NAME),			\
+			 "%"PRINTSIZET"d != %"PRINTSIZET"d "		\
+			 "(bytecode method: %d)\n",			\
+			 (size_t) PIKE_CONCAT(local_num_, NAME),	\
+			 (size_t) p->PIKE_CONCAT(num_, NAME),		\
 			 bytecode_method);				\
           }
 #include "program_areas.h"
diff --git a/src/gc.c b/src/gc.c
index cc07cdbd63..8cc7e929d5 100644
--- a/src/gc.c
+++ b/src/gc.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: gc.c,v 1.269 2005/04/14 22:50:12 mast Exp $
+|| $Id: gc.c,v 1.270 2005/05/19 22:35:27 mast Exp $
 */
 
 #include "global.h"
@@ -535,8 +535,7 @@ void describe_location(void *real_memblock,
 		e, p->constants[e].name ? p->constants[e].name->str : "no name");
 #else /* !0 */
 	fprintf(stderr,"%*s  **In p->constants[%"PRINTPTRDIFFT"d] "
-		"(%"PRINTPTRDIFFT"d)\n",
-		indent,"",
+		"(%"PRINTPTRDIFFT"d)\n",indent,"",
 		e, p->constants[e].offset);
 #endif /* 0 */
 	break;
@@ -1099,7 +1098,7 @@ again:
       {
 #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \
       fprintf(stderr, "%*s* " #NAME " %p[%"PRINTSIZET"u]\n", \
-              indent, "", p->NAME, (size_t)p->PIKE_CONCAT(num_,NAME));
+	      indent, "", p->NAME, (size_t)p->PIKE_CONCAT(num_,NAME));
 #include "program_areas.h"
       }
 
diff --git a/src/interpret_functions.h b/src/interpret_functions.h
index 87ee5d1b9a..2097c31513 100644
--- a/src/interpret_functions.h
+++ b/src/interpret_functions.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: interpret_functions.h,v 1.183 2004/12/19 16:16:55 grubba Exp $
+|| $Id: interpret_functions.h,v 1.184 2005/05/19 22:35:28 mast Exp $
 */
 
 /*
@@ -2203,7 +2203,7 @@ OPCODE1_JUMP(F_CALL_OTHER_AND_RETURN,"call other & return", I_UPDATE_ALL, {
       Pike_fatal("Function popped too many arguments: %s\n",		 \
 	    s->u.efun->name->str);					 \
     if(Pike_sp>expected_stack+1)					 \
-      Pike_fatal("Function left %d droppings on stack: %s\n",		 \
+      Pike_fatal("Function left %"PRINTPTRDIFFT"d droppings on stack: %s\n", \
            Pike_sp-(expected_stack+1),					 \
 	    s->u.efun->name->str);					 \
     if(Pike_sp == expected_stack && !s->u.efun->may_return_void)	 \
diff --git a/src/las.c b/src/las.c
index 8168f88bda..22565e1e8c 100644
--- a/src/las.c
+++ b/src/las.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: las.c,v 1.363 2005/04/06 17:54:43 grubba Exp $
+|| $Id: las.c,v 1.364 2005/05/19 22:35:29 mast Exp $
 */
 
 #include "global.h"
@@ -642,7 +642,7 @@ void free_all_nodes(void)
 	}
 #ifdef PIKE_DEBUG
 	if(!cumulative_parse_error)
-	  Pike_fatal("Failed to free %d nodes when compiling!\n",e2);
+	  Pike_fatal("Failed to free %"PRINTSIZET"d nodes when compiling!\n",e2);
 #endif
       }
 #ifndef PIKE_DEBUG
diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c
index 361d4d2c71..204f9b5090 100644
--- a/src/modules/Image/image.c
+++ b/src/modules/Image/image.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: image.c,v 1.221 2005/03/18 15:35:05 grubba Exp $
+|| $Id: image.c,v 1.222 2005/05/19 22:35:35 mast Exp $
 */
 
 /*
@@ -4727,7 +4727,7 @@ void image__decode( INT32 args )
     w = a->item[0].u.integer;
     h = a->item[1].u.integer;
 
-    if( w*h*sizeof(rgb_group) != a->item[2].u.string->len )
+    if( w*h*(ptrdiff_t) sizeof(rgb_group) != a->item[2].u.string->len )
 	Pike_error("Illegal image data\n");
 
     if( THIS->img )
diff --git a/src/modules/Parser/html.c b/src/modules/Parser/html.c
index 6814595743..dd7aca8025 100644
--- a/src/modules/Parser/html.c
+++ b/src/modules/Parser/html.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: html.c,v 1.176 2004/10/15 14:57:04 grubba Exp $
+|| $Id: html.c,v 1.177 2005/05/19 22:35:36 mast Exp $
 */
 
 #include "global.h"
@@ -592,8 +592,9 @@ found_start:
    CC->num_look_for_start=n;
 #ifdef PIKE_DEBUG
    if (n > NELEM (CC->look_for_start))
-     Pike_fatal ("Static size of calc_chars.look_for_start is %d but %d required.\n",
-	    NELEM (CC->look_for_start), n);
+     Pike_fatal ("Static size of calc_chars.look_for_start is "
+		 "%"PRINTSIZET"d but %"PRINTSIZET"d required.\n",
+		 NELEM (CC->look_for_start), n);
 #endif
 
    for (k=0; k < NARGQ (this); k++)
@@ -619,14 +620,16 @@ found_start:
       CC->num_look_for_end[k]=n;
 #ifdef PIKE_DEBUG
       if (n > NELEM (CC->look_for_end[k]))
-	Pike_fatal ("Static size of calc_chars.look_for_end[k] is %d but %d required.\n",
-	       NELEM (CC->look_for_end[k]), n);
+	Pike_fatal ("Static size of calc_chars.look_for_end[k] is "
+		    "%"PRINTSIZET"d but %"PRINTSIZET"d required.\n",
+		    NELEM (CC->look_for_end[k]), n);
 #endif
    }
 #ifdef PIKE_DEBUG
    if (k > NELEM (CC->look_for_end))
-     Pike_fatal ("Static size of calc_chars.look_for_end is %d but %d required.\n",
-	    NELEM (CC->look_for_end), k);
+     Pike_fatal ("Static size of calc_chars.look_for_end is "
+		 "%"PRINTSIZET"d but %"PRINTSIZET"d required.\n",
+		 NELEM (CC->look_for_end), k);
 #endif
 
    n = check_fin ? 4 : 3;
@@ -654,8 +657,9 @@ found_start:
 #else
 #ifdef PIKE_DEBUG
    if (CC->n_arg_break_chars > NELEM (CC->arg_break_chars))
-     Pike_fatal ("Static size of calc_chars.arg_break_chars is %d but %d required.\n",
-	    NELEM (CC->arg_break_chars), CC->n_arg_break_chars);
+     Pike_fatal ("Static size of calc_chars.arg_break_chars is "
+		 "%"PRINTSIZET"d but %"PRINTSIZET"d required.\n",
+		 NELEM (CC->arg_break_chars), CC->n_arg_break_chars);
 #endif
 #endif
 
diff --git a/src/modules/_Charset/iso2022.c b/src/modules/_Charset/iso2022.c
index 9fec7d599e..a569cbd2ba 100644
--- a/src/modules/_Charset/iso2022.c
+++ b/src/modules/_Charset/iso2022.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: iso2022.c,v 1.37 2005/02/17 16:37:50 grubba Exp $
+|| $Id: iso2022.c,v 1.38 2005/05/19 22:35:37 mast Exp $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -802,6 +802,7 @@ static void eat_enc_string(struct pike_string *str, struct iso2022enc_stor *s,
 	}
 	if (c < 0) {
 	  /* User reserved character. */
+	  /* FIXME: This doesn't work since p_wchar2 is unsigned. */
 	} else
 #ifdef OPTIMIZE_ISO2022
 	/* This optimization breaks on some 2022 decoders,
diff --git a/src/modules/files/file.c b/src/modules/files/file.c
index c0cc3d2d2a..d30a2e4ca5 100644
--- a/src/modules/files/file.c
+++ b/src/modules/files/file.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: file.c,v 1.350 2005/05/06 00:45:46 nilsson Exp $
+|| $Id: file.c,v 1.351 2005/05/19 22:35:38 mast Exp $
 */
 
 #define NO_PIKE_SHORTHAND
@@ -199,7 +199,7 @@ static void debug_check_internals (struct my_file *f)
   for (ev = 0; ev < NELEM (f->event_cbs); ev++)
     if (f->event_cbs[ev].type == PIKE_T_INT &&
 	f->box.backend && f->box.events & (1 << ev))
-      Pike_fatal ("Got event flag but no callback for event %d.\n", ev);
+      Pike_fatal ("Got event flag but no callback for event %"PRINTSIZET"d.\n", ev);
 }
 #else
 #define debug_check_internals(f) do {} while (0)
diff --git a/src/modules/files/sendfile.c b/src/modules/files/sendfile.c
index a978c35dc2..c730b04051 100644
--- a/src/modules/files/sendfile.c
+++ b/src/modules/files/sendfile.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: sendfile.c,v 1.71 2005/01/23 01:50:41 nilsson Exp $
+|| $Id: sendfile.c,v 1.72 2005/05/19 22:35:39 mast Exp $
 */
 
 /*
@@ -345,7 +345,7 @@ void low_do_sendfile(struct pike_sendfile *this)
 {
 #if defined(SOL_TCP) && (defined(TCP_CORK) || defined(TCP_NODELAY))
   int old_val = -1;
-  size_t old_len = sizeof(old_val);	/* Might want to use socklen_t here. */
+  socklen_t old_len = (socklen_t) sizeof(old_val);
 #ifdef TCP_CORK
   int new_val = 1;
 #else /* !TCP_CORK */
diff --git a/src/modules/spider/xml.c b/src/modules/spider/xml.c
index 8ca8fcef6b..3993453c3b 100644
--- a/src/modules/spider/xml.c
+++ b/src/modules/spider/xml.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: xml.c,v 1.74 2005/05/06 00:45:14 nilsson Exp $
+|| $Id: xml.c,v 1.75 2005/05/19 22:35:39 mast Exp $
 */
 
 #include "global.h"
@@ -702,7 +702,7 @@ ISWRAP(isHexChar)
 #ifdef PIKE_DEBUG
 #define CHECK_INPUT(INPUT) do {					\
     if ((INPUT).len < 0) {					\
-      Pike_fatal("Negative input length: %d\n", (INPUT).len);	\
+      Pike_fatal("Negative input length: %"PRINTPTRDIFFT"d\n", (INPUT).len); \
     }								\
   } while(0)
 #else /* !PIKE_DEBUG */
diff --git a/src/modules/system/memory.c b/src/modules/system/memory.c
index ec1be1d03b..5901859cbe 100644
--- a/src/modules/system/memory.c
+++ b/src/modules/system/memory.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: memory.c,v 1.33 2005/05/06 00:42:35 nilsson Exp $
+|| $Id: memory.c,v 1.34 2005/05/19 22:35:40 mast Exp $
 */
 
 /*! @module System
@@ -672,7 +672,7 @@ static void copy_reverse_string1_to_2(unsigned char *d,
      struct pike_string *ps;						\
      ps = begin_wide_shared_string(len, N);				\
      PIKE_CONCAT(copy_reverse_string, N)				\
-       (PIKE_CONCAT(STR, N)(ps), s, len);				\
+       ((unsigned char *) PIKE_CONCAT(STR, N)(ps), s, len);		\
      return end_shared_string(ps);					\
    }
 
diff --git a/src/object.c b/src/object.c
index a29a918bf4..0df06e06e7 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.266 2005/03/18 14:44:24 grubba Exp $
+|| $Id: object.c,v 1.267 2005/05/19 22:35:30 mast Exp $
 */
 
 #include "global.h"
@@ -477,7 +477,8 @@ 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: %d < %d\n",
+	Pike_fatal("low_read_file(%s) failed, short read: "
+		   "%"PRINTPTRDIFFT"d < %"PRINTPTRDIFFT"d\n",
 		   file, pos, len);
       }
       pos+=tmp;
diff --git a/src/peep.c b/src/peep.c
index 89e5f5f367..661df7b33c 100644
--- a/src/peep.c
+++ b/src/peep.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: peep.c,v 1.105 2004/12/30 13:41:08 grubba Exp $
+|| $Id: peep.c,v 1.106 2005/05/19 22:35:30 mast Exp $
 */
 
 #include "global.h"
@@ -427,8 +427,9 @@ INT32 assemble(int store_linenumbers)
   {
 #ifdef PIKE_DEBUG
     if (c != (((p_instr *)instrbuf.s.str)+e)) {
-      Pike_fatal("Instruction loop deviates. 0x%04x != 0x%04x\n",
-		 e, DO_NOT_WARN((INT32)(c - ((p_instr *)instrbuf.s.str))));
+      Pike_fatal("Instruction loop deviates. "
+		 "0x%04"PRINTPTRDIFFT"x != 0x%04"PRINTPTRDIFFT"x\n",
+		 e, c - ((p_instr *)instrbuf.s.str));
     }
     if((a_flag > 2 && store_linenumbers) || a_flag > 3)
     {
@@ -689,7 +690,7 @@ INT32 assemble(int store_linenumbers)
   if (a_flag > 6) {
     size_t len = (Pike_compiler->new_program->num_program - fun_start)*
       sizeof(PIKE_OPCODE_T);
-    fprintf(stderr, "Code at offset %d through %d:\n",
+    fprintf(stderr, "Code at offset %"PRINTSIZET"d through %"PRINTSIZET"d:\n",
 	    fun_start, Pike_compiler->new_program->num_program-1);
 #ifdef DISASSEMBLE_CODE
     DISASSEMBLE_CODE(Pike_compiler->new_program->program + fun_start, len);
diff --git a/src/pike_types.c b/src/pike_types.c
index b204511d0b..c5cc36e50f 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.246 2005/04/06 17:38:15 grubba Exp $
+|| $Id: pike_types.c,v 1.247 2005/05/19 22:35:31 mast Exp $
 */
 
 #include "global.h"
@@ -358,7 +358,8 @@ static inline struct pike_type *debug_mk_type(unsigned INT32 type,
 	       car, cdr);
   }
   if (index >= pike_type_hash_size) {
-    Pike_fatal("Modulo operation failed for hash:%u, index:%u, size:%u.\n",
+    Pike_fatal("Modulo operation failed for hash:%u, index:%u, "
+	       "size:%"PRINTSIZET"d.\n",
 	       hash, index, pike_type_hash_size);
   }
   /* End PIKE_DEBUG code */
@@ -1001,7 +1002,7 @@ struct pike_type *debug_pop_unfinished_type(void)
   len = pop_stack_mark();
 
   if (len != 1) {
-    Pike_fatal("pop_unfinished_type(): Unexpected len: %d\n", len);
+    Pike_fatal("pop_unfinished_type(): Unexpected len: %"PRINTPTRDIFFT"d\n", len);
   }
 
   TYPE_STACK_DEBUG("pop_unfinished_type");
@@ -1022,7 +1023,7 @@ static void internal_parse_typeA(const char **_s)
   for(len=0;isidchar(EXTRACT_UCHAR(s[0]+len));len++)
   {
     if(len>=sizeof(buf)) {
-      my_yyerror("Buffer overflow in parse_type(\"%s\") (limit %d).",
+      my_yyerror("Buffer overflow in parse_type(\"%s\") (limit %"PRINTSIZET"d).",
 		 *s, sizeof(buf));
       push_type(T_MIXED);
       return;
diff --git a/src/post_modules/Shuffler/a_source_system_memory.c b/src/post_modules/Shuffler/a_source_system_memory.c
index 2b22cfa578..7eddcd2568 100644
--- a/src/post_modules/Shuffler/a_source_system_memory.c
+++ b/src/post_modules/Shuffler/a_source_system_memory.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: a_source_system_memory.c,v 1.11 2004/10/16 07:27:29 agehall Exp $
+|| $Id: a_source_system_memory.c,v 1.12 2005/05/19 22:35:40 mast Exp $
 */
 
 #include "global.h"
@@ -101,7 +101,7 @@ struct source *source_system_memory_make( struct svalue *s,
   res->offset = start;
 
   if( len != -1 )
-    if( len > res->mem->len-start )
+    if( len > (ptrdiff_t) res->mem->len - start )
     {
       sub_ref(res->obj);
       free(res);
diff --git a/src/post_modules/Shuffler/b_source_normal_file.c b/src/post_modules/Shuffler/b_source_normal_file.c
index b52a9643b6..7904389804 100644
--- a/src/post_modules/Shuffler/b_source_normal_file.c
+++ b/src/post_modules/Shuffler/b_source_normal_file.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: b_source_normal_file.c,v 1.13 2004/08/27 09:16:56 agehall Exp $
+|| $Id: b_source_normal_file.c,v 1.14 2005/05/19 22:35:40 mast Exp $
 */
 
 #include "global.h"
@@ -37,7 +37,7 @@ struct fd_source
   off_t len;
 };
 
-static struct data get_data( struct source *_s, off_t len )
+static struct data get_data( struct source *_s, int len )
 {
   struct fd_source *s = (struct fd_source *)_s;
   struct data res;
@@ -61,7 +61,7 @@ static struct data get_data( struct source *_s, off_t len )
 
   res.len = rr;
 
-  if( rr<0 || (unsigned)rr < len )
+  if( rr<0 || rr < len )
     s->s.eof = 1;
   return res;
 }
diff --git a/src/program.c b/src/program.c
index 08e1d7ce6e..30ca570f01 100644
--- a/src/program.c
+++ b/src/program.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: program.c,v 1.587 2005/04/08 17:01:02 grubba Exp $
+|| $Id: program.c,v 1.588 2005/05/19 22:35:32 mast Exp $
 */
 
 #include "global.h"
@@ -2666,7 +2666,7 @@ void dump_program_tables (struct program *p, int indent)
   for (d=0; d < p->num_inherits; d++) {
     struct inherit *inh = p->inherits + d;
 
-    fprintf(stderr, "%*s  %4d: %5d %7d %8d %12d %6d %8d %10d %11d\n",
+    fprintf(stderr, "%*s  %4d: %5d %7d %8d %12"PRINTPTRDIFFT"d %6d %8d %10d %11"PRINTSIZET"d\n",
 	    indent, "",
 	    d, inh->inherit_level,
 	    inh->prog ? inh->prog->id : -1,
@@ -2682,7 +2682,7 @@ void dump_program_tables (struct program *p, int indent)
   for (d=0; d < p->num_identifiers; d++) {
     struct identifier *id = p->identifiers + d;
 
-    fprintf(stderr, "%*s  %4d: %5x %6d %4d \"%s\"\n",
+    fprintf(stderr, "%*s  %4d: %5x %6"PRINTPTRDIFFT"d %4d \"%s\"\n",
 	    indent, "",
 	    d, id->identifier_flags, id->func.offset,
 	    id->run_time_type, id->name->str);
@@ -2709,7 +2709,7 @@ void dump_program_tables (struct program *p, int indent)
 	    d, get_name_of_type (c->sval.type),
 	    c->name?"\"":"",c->name?c->name->str:"NULL",c->name?"\"":"");
 #else /* !0 */
-    fprintf(stderr, "%*s  %4d: %-15s %d\n",
+    fprintf(stderr, "%*s  %4d: %-15s %"PRINTPTRDIFFT"d\n",
 	    indent, "",
 	    d, get_name_of_type (c->sval.type),
 	    c->offset);
@@ -2922,8 +2922,9 @@ void check_program(struct program *p)
 	  if(ID_FROM_INT(p,variable_positions[offset+q])->run_time_type !=
 	     i->run_time_type)
 	  {
-	    fprintf(stderr, "Storage offset: 0x%08x vs 0x%08x\n"
-		    "Func offset: 0x%08x vs 0x%08x\n"
+	    fprintf(stderr, "Storage offset: "
+		    "0x%08"PRINTPTRDIFFT"x vs 0x%08"PRINTPTRDIFFT"x\n"
+		    "Func offset: 0x%08"PRINTPTRDIFFT"x vs 0x%08"PRINTPTRDIFFT"x\n"
 		    "Type: %s vs %s\n",
 		    INHERIT_FROM_INT(p, variable_positions[offset+q])->
 		    storage_offset,
@@ -2935,7 +2936,9 @@ void check_program(struct program *p)
 		    get_name_of_type(i->run_time_type));
 	    if (i->name) {
 	      Pike_fatal("Variable '%s' and '%s' overlap\n"
-		    "Offset 0x%08x - 0x%08x overlaps with 0x%08x - 0x%08x\n",
+			 "Offset 0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x "
+			 "overlaps with "
+			 "0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x\n",
 		    ID_FROM_INT(p, variable_positions[offset+q])->name->str,
 		    i->name->str,
 		    INHERIT_FROM_INT(p, variable_positions[offset+q])->
@@ -2949,7 +2952,9 @@ void check_program(struct program *p)
 		    offset, offset+size-1);
 	    } else {
 	      Pike_fatal("Variable '%s' and anonymous variable (%d) overlap\n"
-		    "Offset 0x%08x - 0x%08x overlaps with 0x%08x - 0x%08x\n",
+			 "Offset 0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x "
+			 "overlaps with "
+			 "0x%08"PRINTPTRDIFFT"x - 0x%08"PRINTPTRDIFFT"x\n",
 		    ID_FROM_INT(p, variable_positions[offset+q])->name->str,
 		    e,
 		    INHERIT_FROM_INT(p, variable_positions[offset+q])->
@@ -5611,7 +5616,7 @@ void store_linenumber(INT32 current_line, struct pike_string *current_file)
 	cnt += len<<shift;
 	if (a_flag > 100) {
 	  fprintf(stderr, "Filename entry:\n"
-		  "  len: %d, shift: %d\n",
+		  "  len: %"PRINTSIZET"d, shift: %d\n",
 		  len, shift);
 	}
       }
@@ -5637,7 +5642,7 @@ void store_linenumber(INT32 current_line, struct pike_string *current_file)
 	    "    (line : %d ?= %d)!\n"
 	    "    (  pc : %d ?= %d)!\n"
 	    "    (shift: %d ?= %d)!\n"
-	    "    (len  : %d ?= %d)!\n"
+	    "    (len  : %"PRINTSIZET"d ?= %"PRINTSIZET"d)!\n"
 	    "    (file : %s ?= %s)!\n",
 	    Pike_compiler->last_line, line,
 	    Pike_compiler->last_pc, off,
diff --git a/src/rbtree.c b/src/rbtree.c
index 6bea43d05d..b4c4415e04 100644
--- a/src/rbtree.c
+++ b/src/rbtree.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: rbtree.c,v 1.24 2004/09/18 20:50:55 nilsson Exp $
+|| $Id: rbtree.c,v 1.25 2005/05/19 22:35:34 mast Exp $
 */
 
 /* An implementation of a threaded red/black balanced binary tree.
@@ -1711,7 +1711,7 @@ void debug_dump_rb_tree (struct rb_node_hdr *root, dump_data_fn *dump_data,
     struct rb_node_hdr *node = root;
     struct rb_node_hdr *n, *n2;
     struct rbstack_ptr p;
-    size_t depth = 0;
+    int depth = 0;
     RBSTACK_INIT (rbstack);
 
     LOW_RB_TRAVERSE (
@@ -1839,7 +1839,8 @@ void debug_check_rb_tree (struct rb_node_hdr *root, dump_data_fn *dump_data, voi
   if (root) {
     struct rb_node_hdr *node = root, *n, *n2;
     struct rbstack_ptr p;
-    size_t blacks = 1, max_blacks = 0, depth = 0;
+    size_t blacks = 1, max_blacks = 0;
+    int depth = 0;
     RBSTACK_INIT (rbstack);
 
     if (root->flags & RB_RED) custom_rb_fatal (root, dump_data, extra,
@@ -1862,8 +1863,9 @@ void debug_check_rb_tree (struct rb_node_hdr *root, dump_data_fn *dump_data, voi
 	if (max_blacks) {
 	  if (blacks != max_blacks)
 	    custom_rb_fatal (root, dump_data, extra,
-			     "Unbalanced tree - leftmost branch is %d, "
-			     "prev @ %p is %d.\n", max_blacks, node, blacks);
+			     "Unbalanced tree - leftmost branch is %"PRINTSIZET"d, "
+			     "prev @ %p is %"PRINTSIZET"d.\n",
+			     max_blacks, node, blacks);
 	}
 	else max_blacks = blacks;
 
@@ -1888,8 +1890,9 @@ void debug_check_rb_tree (struct rb_node_hdr *root, dump_data_fn *dump_data, voi
       }, {			/* next is leaf. */
 	if (blacks != max_blacks)
 	  custom_rb_fatal (root, dump_data, extra,
-			   "Unbalanced tree - leftmost branch is %d, "
-			   "next @ %p is %d.\n", max_blacks, node, blacks);
+			   "Unbalanced tree - leftmost branch is %"PRINTSIZET"d, "
+			   "next @ %p is %"PRINTSIZET"d.\n",
+			   max_blacks, node, blacks);
 
 	p = rbstack;
 	n2 = node;
diff --git a/src/threads.c b/src/threads.c
index fc5b2fd277..a517f93c67 100644
--- a/src/threads.c
+++ b/src/threads.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: threads.c,v 1.243 2005/03/31 02:19:46 nilsson Exp $
+|| $Id: threads.c,v 1.244 2005/05/19 22:35:34 mast Exp $
 */
 
 #ifndef CONFIGURE_TEST
@@ -692,7 +692,7 @@ void debug_list_all_threads(void)
     for(s=thread_table_chains[x]; s; s=s->hashlink) {
       struct object *o = THREADSTATE2OBJ(s);
       fprintf(stderr,"ThTab[%d]: state=%p, obj=%p, "
-	      "swapped=%d, sp=%p (%+d), fp=%p, stackbase=%p",
+	      "swapped=%d, sp=%p (%+"PRINTPTRDIFFT"d), fp=%p, stackbase=%p",
 	      x, s, o, s->swapped,
 	      s->state.stack_pointer,
 	      s->state.stack_pointer - s->state.evaluator_stack,
-- 
GitLab