branch-1.6 distcheck failure: printf %* and integer type

Ralf Wildenhues <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Organization Department of Numerical Simulation, University of Bonn
Message-ID <[email protected]>
Hi Eric,

I need the following patch to get branch-1.6 M4 to pass distcheck on
GNU/Linux.

cc1: warnings being treated as errors
../../src/builtin.c: In function 'm4_maketemp':
../../src/builtin.c:1674: warning: field precision should have type 'int', but argument 3 has type 'size_t' [-Wformat]
[...]
../../src/macro.c:750: warning: format '%d' expects type 'int', but argument 4 has type 'size_t' [-Wformat]

Cheers,
Ralf

2009-11-27  Ralf Wildenhues  <[email protected]>

	Fix -Wformat warnings.
	* src/builtin.c (m4_maketemp): Cast printf %*d length argument
	to int.
	* src/macro.c (adjust_refcount): Cast size_t to unsigned long,
	adjust printf format string.

diff --git a/src/builtin.c b/src/builtin.c
index ea27f74..9795837 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -1671,7 +1671,7 @@ m4_maketemp (struct obstack *obs, int argc, macro_arguments *argv)
       if (len - i < pid_len)
 	obstack_grow (obs, pid + pid_len - (len - i), len - i);
       else
-	obstack_printf (obs, "%.*d%s", len - i - pid_len, 0, pid);
+	obstack_printf (obs, "%.*d%s", (int)(len - i - pid_len), 0, pid);
     }
   else
     mkstemp_helper (obs, me, ARG (1), ARG_LEN (1));
diff --git a/src/macro.c b/src/macro.c
index 403a90d..8f588d3 100644
--- a/src/macro.c
+++ b/src/macro.c
@@ -746,8 +746,8 @@ adjust_refcount (int level, bool increase)
     }
   if (debug_macro_level
       & (increase ? PRINT_REFCOUNT_INCREASE : PRINT_REFCOUNT_DECREASE))
-    xfprintf (debug, "m4debug: level %d refcount=%d\n", level,
-	      stacks[level].refcount);
+    xfprintf (debug, "m4debug: level %d refcount=%lu\n", level,
+	      (unsigned long) stacks[level].refcount);
   return stacks[level].refcount;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.