From patchwork Thu Nov 1 17:14:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 992020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-96903-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="JpKqmJlJ"; dkim-atps=neutral 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 42mBfM116Xz9sTt for ; Fri, 2 Nov 2018 04:15:06 +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=nLY06Bt0f4ZN+kH58yVvxWDAV+Jaj 0Ee8INimLS9f0R8RHmIJ61VJMuqCEfbgVblitQh4g6ifLNaSEgejvV4fqR2ppBRv /O1Wxw8AyeWasXRc2W1bbIoqclVnV1rPqiODRygur+sQXnE5pNUZP873+HtYTHVq MxMpvLa4W3KuQs= 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=qS9KWDUaWggicDoBSERxaSMETeg=; b=JpK qmJlJ98ScxxXOc/MEGTX68ptIPILiT6MLCzwdT7mkkIGSZnTNRL97LPS33vxmrD0 YLNlGDod0hB0CBLCyvi8SIlkfM4MeJMStA34Dh17GVFPnmthxGWLlzM94CKM3omA 2uyp2aZNKbNWyElACFm2vJvml7ZAt8O9cvvd7RG0= Received: (qmail 8344 invoked by alias); 1 Nov 2018 17:15:00 -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 8219 invoked by uid 89); 1 Nov 2018 17:14:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Thu, 1 Nov 2018 17:14:45 +0000 From: Joseph Myers To: Subject: Disable -Wformat-overflow= warnings for some printf tests [committed] Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Recent GCC -Wformat-overflow= changes result in some printf tests failing to build, because those tests are deliberately testing the handling of formats writing more than INT_MAX characters and the handling of NULL arguments to the %s format, which GCC now warns about. This patch duly disables -Wformat-overflow= for the relevant calls to printf functions. Tested with build-many-glibcs.py with GCC mainline for aarch64-linux-gnu. Committed. 2018-11-01 Joseph Myers * stdio-common/bug22.c: Include . (do_test): Disable -Wformat-overflow= warnings around fprintf calls outputting more than INT_MAX characters. * stdio-common/tst-printf.c: Disable -Wformat-overflow= warnings around printf call with NULL %s argument. diff --git a/stdio-common/bug22.c b/stdio-common/bug22.c index b26399acb7..b3d48eb8e1 100644 --- a/stdio-common/bug22.c +++ b/stdio-common/bug22.c @@ -1,6 +1,7 @@ /* BZ #5424 */ #include #include +#include /* INT_MAX + 1 */ #define N 2147483648 @@ -30,12 +31,26 @@ do_test (void) return 1; } + /* GCC 9 warns about output of more than INT_MAX characters; this is + deliberately tested here. */ + DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-overflow="); +#endif ret = fprintf (fp, "%" SN "d", 1); + DIAG_POP_NEEDS_COMMENT; printf ("ret = %d\n", ret); if (ret != -1 || errno != EOVERFLOW) return 1; + /* GCC 9 warns about output of more than INT_MAX characters; this is + deliberately tested here. */ + DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-overflow="); +#endif ret = fprintf (fp, "%." SN "d", 1); + DIAG_POP_NEEDS_COMMENT; printf ("ret = %d\n", ret); if (ret != -1 || errno != EOVERFLOW) return 1; @@ -45,7 +60,14 @@ do_test (void) if (ret != -1 || errno != EOVERFLOW) return 1; + /* GCC 9 warns about output of more than INT_MAX characters; this is + deliberately tested here. */ + DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-overflow="); +#endif ret = fprintf (fp, "%" SN2 "d%" SN2 "d", 1, 1); + DIAG_POP_NEEDS_COMMENT; printf ("ret = %d\n", ret); return ret != -1 || errno != EOVERFLOW; diff --git a/stdio-common/tst-printf.c b/stdio-common/tst-printf.c index 70d9e584b3..e4f4f1624d 100644 --- a/stdio-common/tst-printf.c +++ b/stdio-common/tst-printf.c @@ -110,7 +110,14 @@ I am ready for my first lesson today."; printf("left-adjusted Z string:\t\"%-010s\"\n", shortstr); printf("space-padded string:\t\"%10s\"\n", shortstr); printf("left-adjusted S string:\t\"%-10s\"\n", shortstr); + /* GCC 9 warns about the NULL format argument; this is deliberately + tested here. */ + DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wformat-overflow="); +#endif printf("null string:\t\"%s\"\n", (char *)NULL); + DIAG_POP_NEEDS_COMMENT; printf("limited string:\t\"%.22s\"\n", longstr); printf("a-style max:\t\"%a\"\n", DBL_MAX);