From 07f74364b1854810f814e81e73822f35b7677318 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 9 Aug 2020 13:07:01 -0500 Subject: [PATCH] checked_malloc: use %z to format size_t; enable -Wformat=2 Reported-by: Greg Troxel Signed-off-by: Rob Browning Tested-by: Rob Browning --- Makefile | 4 ++-- lib/bup/_helpers.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d96c149..e4bc7d6 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,8 @@ current_sampledata := t/sampledata/var/rev/v$(sampledata_rev) os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok)) os := $(call shout,$(os),Unable to determine OS) -CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS) -CFLAGS := -D_FILE_OFFSET_BITS=64 $(CFLAGS) +CFLAGS := -Wall -Werror=format=2 -O2 -Werror -Wno-unknown-pragmas $(CFLAGS) +CFLAGS := -D_FILE_OFFSET_BITS=64 $(PYINCLUDE) $(CFLAGS) SOEXT:=.so ifeq ($(os),CYGWIN) diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index 489bd14..a6ffd32 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -129,7 +129,7 @@ static void *checked_malloc(size_t n, size_t size) if (__builtin_mul_overflow(n, size, &total)) { PyErr_Format(PyExc_OverflowError, - "request to allocate %lu items of size %lu is too large", + "request to allocate %zu items of size %zu is too large", n, size); return NULL; } -- 2.39.2