diff mbox

S390: Get rid of format warning in mem.c

Message ID m6ep44$p04$1@ger.gmane.org
State Committed
Headers show

Commit Message

Stefan Liebler Dec. 12, 2014, 1:04 p.m. UTC

on 31bit s390 i get the following warning/error:
gcc mem.c -c ...
mem.c: In function 'gc':
mem.c:428:4: error: format '%zu' expects argument of type 'size_t', but 
argument 2 has type 'int' [-Werror=format=]
        dbnames[db - dbs]);
cc1: all warnings being treated as errors

This patch adds a cast to size_t in order to disable the warning.

Ok to commit?


2014-12-12  Stefan Liebler  <stli@linux.vnet.ibm.com>

	* nscd/mem.c (gc):
	Cast argument to size_t to disable format warning.


Roland McGrath Dec. 12, 2014, 9:10 p.m. UTC | #1
Wouldn't %Zu match the existing type?
Stefan Liebler Dec. 15, 2014, 3:01 p.m. UTC | #2
On 12/12/2014 10:10 PM, Roland McGrath wrote:
> Wouldn't %Zu match the existing type?
The warning is emitted with %zu or %Zu.

The type of db->head->first_free is nscd_ssize_t, which is an int32_t 
(sysdeps/generic/nscd-types.h) and int64_t on alpha 

Casts were added to avoid warnings in other usages of 
db->head->first_free in combination with dbg_log()-messages in this file 
(see commit-id 568470bbff2c86996cbb7ebb5411a2b5d4c46fe4).
Roland McGrath Dec. 16, 2014, 5:51 p.m. UTC | #3
OK, then the cast is fine.
diff mbox


diff --git a/nscd/mem.c b/nscd/mem.c
index b4090fb..d94c6db 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -423,7 +423,7 @@  gc (struct database_dyn *db)
       if (__glibc_unlikely (debug_level >= 3))
 	dbg_log (_("freed %zu bytes in %s cache"),
-		 db->head->first_free
+		 (size_t) db->head->first_free
 		 - ((char *) moves->to + moves->size - db->data),
 		 dbnames[db - dbs]);