From patchwork Wed Dec 10 15:54:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 419729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 342A71400DE for ; Thu, 11 Dec 2014 02:54:29 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=XzPcSBv+74TTZ+RyJb3z4S9LwqPa2 FR7uuPupfRgLYfgWSwEvTNbuZyxS+SHwTXWUB79Q5/Mmm+YMa9Ck/yszFV+mOm45 a5fUulBs0DcBZtf6opgt2ixJg5DhUXlqAkx6vpDoXPkUg7vEV0pHStAOTG0Mw+4y zSjhOrvyCjLbZQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=NJq6nS4uAvcfaCNGXKIzW1kIsLw=; b=lmJ 1qpneC1C+wchXY6wPknjCcHQGGThfjgOFqISnY3V204s4p6xR6yRwlpcyVRgFbJy EBXeNVE3fXl/2n2qDG8bvMXHjnYWZU0aa9jT/FH6Q//z4BDG1T1W8I8d8tKZb4U5 j6/9hS7F5ANvcQCoZO9sH7ayLQTWxbuHFs2X35iU= Received: (qmail 17927 invoked by alias); 10 Dec 2014 15:54:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 17918 invoked by uid 89); 10 Dec 2014 15:54:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Wed, 10 Dec 2014 15:54:16 +0000 From: Joseph Myers To: Subject: Clean up localedata tests printf formats, don't use -Wno-format Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 The format checking errors Richard saw in pointed out a genuine problem with formats in some localedata tests, although -Wno-format should have stopped those errors from appearing. I don't know why the -Wno-format was ineffective, but the claim "gcc does not know all the format specifiers we are using here." is long out of date (since around 2000, at least). This patch fixes the localedata tests to use formats and types that match, and removes the use of -Wno-format. %Zd is changed to %zu for size_t arguments (not strictly necessary, but it seems cleanest to use the C99 format unless specifically testing the old GNU %Z extension), %td is used where necessary for ptrdiff_t arguments (some tests already used it), %lc for wint_t and arguments are cast to size_t where needed (when the macro callers are passing an int constant to say what value is expected). Tested for x86_64 and x86. 2014-12-10 Joseph Myers * tst-mbswcs1.c (show): Use %zu format instead of %Zd. Cast corresponding format argument to size_t. * tst-mbswcs2.c (show): Likewise. Use %td format for ptrdiff_t arguments. * tst-mbswcs3.c (show): Use %zu format instead of %Zd. Cast corresponding format argument to size_t. * tst-mbswcs4.c (show): Likewise. Use %td format for ptrdiff_t arguments. * tst-mbswcs5.c (show): Use %zu format instead of %Zd. Cast corresponding format argument to size_t. * tst-trans.c (do_test): Use %lc format for wint_t arguments. * Makefile (CFLAGS-tst-mbswcs1.c): Remove variable. (CFLAGS-tst-mbswcs2.c): Likewise. (CFLAGS-tst-mbswcs3.c): Likewise. (CFLAGS-tst-mbswcs4.c): Likewise. (CFLAGS-tst-mbswcs5.c): Likewise. (CFLAGS-tst-trans.c): Likewise diff --git a/localedata/Makefile b/localedata/Makefile index c2c62a2..0826b36 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -126,14 +126,6 @@ $(inst_i18ndir)/charmaps/%.gz: charmaps/% $(+force) # Install the locale source files in the appropriate directory. $(inst_i18ndir)/locales/%: locales/% $(+force); $(do-install) -# gcc does not know all the format specifiers we are using here. -CFLAGS-tst-mbswcs1.c = -Wno-format -CFLAGS-tst-mbswcs2.c = -Wno-format -CFLAGS-tst-mbswcs3.c = -Wno-format -CFLAGS-tst-mbswcs4.c = -Wno-format -CFLAGS-tst-mbswcs5.c = -Wno-format -CFLAGS-tst-trans.c = -Wno-format - ifeq ($(run-built-tests),yes) generated-dirs += $(LOCALES) diff --git a/localedata/tst-mbswcs1.c b/localedata/tst-mbswcs1.c index 1404829..15691db 100644 --- a/localedata/tst-mbswcs1.c +++ b/localedata/tst-mbswcs1.c @@ -24,11 +24,12 @@ #define show(expr, nexp, wcexp) \ n = expr; \ - printf (#expr " -> %Zd", n); \ + printf (#expr " -> %zu", n); \ printf (", wc = %lu", (unsigned long int) wc); \ if (n != (size_t) nexp || wc != wcexp) \ { \ - printf (", expected %Zd and %lu", nexp, (unsigned long int) wcexp); \ + printf (", expected %zu and %lu", (size_t) nexp, \ + (unsigned long int) wcexp); \ result = 1; \ } \ putc ('\n', stdout) diff --git a/localedata/tst-mbswcs2.c b/localedata/tst-mbswcs2.c index 9cd95d6..d0f502c 100644 --- a/localedata/tst-mbswcs2.c +++ b/localedata/tst-mbswcs2.c @@ -24,12 +24,12 @@ #define show(expr, nexp, wcexp, end) \ n = expr; \ - printf (#expr " -> %Zd", n); \ - printf (", wc = %lu, src = buf+%d", (unsigned long int) wc, \ + printf (#expr " -> %zu", n); \ + printf (", wc = %lu, src = buf+%td", (unsigned long int) wc, \ src - (const char *) buf); \ if (n != (size_t) nexp || wc != wcexp || src != (const char *) (end)) \ { \ - printf (", expected %Zd and %lu and buf+%d", nexp, \ + printf (", expected %zu and %lu and buf+%td", (size_t) nexp, \ (unsigned long int) wcexp, (end) - buf); \ result = 1; \ } \ diff --git a/localedata/tst-mbswcs3.c b/localedata/tst-mbswcs3.c index a068541..ef18a98 100644 --- a/localedata/tst-mbswcs3.c +++ b/localedata/tst-mbswcs3.c @@ -25,13 +25,13 @@ #define show(expr, nexp, srcexp, bufexp) \ { \ size_t res = expr; \ - printf (#expr " -> %Zd", res); \ + printf (#expr " -> %zu", res); \ dst += res; \ printf (", src = srcbuf+%td, dst = buf+%td", \ src - srcbuf, dst - (char *) buf); \ if (res != nexp || src != (srcexp) || dst != (char *) (bufexp)) \ { \ - printf (", expected %Zd and srcbuf+%td and buf+%td", nexp, \ + printf (", expected %zu and srcbuf+%td and buf+%td", (size_t) nexp, \ (srcexp) - srcbuf, (bufexp) - (unsigned char *) buf); \ result = 1; \ } \ diff --git a/localedata/tst-mbswcs4.c b/localedata/tst-mbswcs4.c index a4fe60d..83c5eac 100644 --- a/localedata/tst-mbswcs4.c +++ b/localedata/tst-mbswcs4.c @@ -23,12 +23,12 @@ #define show(expr, nexp, wcexp, end) \ n = expr; \ - printf (#expr " -> %Zd", n); \ - printf (", wc = %lu, src = buf+%d", (unsigned long int) wc, \ + printf (#expr " -> %zu", n); \ + printf (", wc = %lu, src = buf+%td", (unsigned long int) wc, \ src - (const char *) buf); \ if (n != (size_t) nexp || wc != wcexp || src != (const char *) (end)) \ { \ - printf (", expected %Zd and %lu and buf+%d", nexp, \ + printf (", expected %zu and %lu and buf+%td", (size_t) nexp, \ (unsigned long int) wcexp, (end) - buf); \ result = 1; \ } \ diff --git a/localedata/tst-mbswcs5.c b/localedata/tst-mbswcs5.c index c44f12a..1ff56f3 100644 --- a/localedata/tst-mbswcs5.c +++ b/localedata/tst-mbswcs5.c @@ -25,12 +25,12 @@ #define show(expr, nexp, bufexp) \ { \ size_t res = expr; \ - printf (#expr " -> %Zd", res); \ + printf (#expr " -> %zu", res); \ dst += res; \ printf (", dst = buf+%td", dst - (char *) buf); \ if (res != nexp || dst != (char *) (bufexp)) \ { \ - printf (", expected %Zd and buf+%td", nexp, \ + printf (", expected %zu and buf+%td", (size_t) nexp, \ (bufexp) - (unsigned char *) buf); \ result = 1; \ } \ diff --git a/localedata/tst-trans.c b/localedata/tst-trans.c index 0b0be83..616c896 100644 --- a/localedata/tst-trans.c +++ b/localedata/tst-trans.c @@ -44,12 +44,12 @@ do_test (void) } wch = towctrans (L'A', t); - printf ("towctrans (L'A', t) = %c\n", wch); + printf ("towctrans (L'A', t) = %lc\n", wch); if (wch != L'B') errors = 1; wch = towctrans (L'B', t); - printf ("towctrans (L'B', t) = %c\n", wch); + printf ("towctrans (L'B', t) = %lc\n", wch); if (wch != L'C') errors = 1;