From patchwork Sun Dec 22 00:04:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 852884 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2768916wrq; Sat, 21 Dec 2024 16:11:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUKMrkKK8swV5cU1rkWBArqXhy9/ixGYl+KuGWIGf9tHML6qNcwd81A3gXFjSlnfcO19LR3HA==@linaro.org X-Google-Smtp-Source: AGHT+IH31JrLNO6D3Do1GRBIzdQODg6Dp9zWPfHMR5gB8bCsIUXGIqGV/UXuvHOnignp+24RaF5g X-Received: by 2002:a05:6214:c6e:b0:6d8:ab3c:5e8 with SMTP id 6a1803df08f44-6dd2335ddbfmr114025366d6.29.1734826316092; Sat, 21 Dec 2024 16:11:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1734826316; cv=pass; d=google.com; s=arc-20240605; b=MtYWH97r5ARMVs8BSrhn9AjUPMCJGNJTSENSpXvIWzJ1uVhosF0Q/UNu4SO/LVLdXU chtzsqHljkCxjzfbqDUuxVIYSRYol1CZd6PklFxl50wBNPLilE6B8IBHqLbGQh3ifFog /Viz4YqTxGk+n+Rdc31kOYozurXLSXgeyaIo057YYRHPk/tpqzLzomxIA1qSp6LZNZCx eFOVYLMdSy0o9gocY5SGgw2KIEMw7zS9/jZxZExl4rWusZ4bGFFdpwGltcEoODHjshtN /Ts+aV7vvzxV7vyqqRyMPmCL8KuWagJBRdggfJLEJ2rODAI6NJu2K1DzVyATljz0Mf0L dcAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Or4dF0rvG7MszB1UGemXhk/dh+3FveWLDf6tKUwPKiM=; fh=uKlFkH9AUukvL1xmvBA9M7Oe4ntiJIR8HCR4+3TPd4w=; b=HLolOy//dWCZQ8Sy7wzrdNsTaZTKYhSGIqnsbWU9FoDQzNpXprGzfyEQLnEXKXp8oE bSU5VFWDCyrgDJ/YpFBZq+5N7Ps1pCUoPQKBe38FdFE7X/PRIrIPhnhlcpkjYTwotroc 7PpqEAJdeQeaSNmdpuwXM9yRg7sbg+ZXvfTmu/LpO2rnnp0z3h/71sSvkcFjC1hk5VeW w6rBD5zMSOieMzANKyZ25R5oN0C30jZlLxsD6tmjAmlaDfVg5LuO2J+t1ziny9XW6GVP tmyxm6Jc7JZp+mg9jLEqCsQoB/Wa52JtKE1nfwzGLVFG4P7fpSjd5QJZgWZXMRp7oIqH 2EeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SOgTtNyH; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18252741si72874196d6.348.2024.12.21.16.11.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 16:11:56 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SOgTtNyH; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B6E02385801B for ; Sun, 22 Dec 2024 00:11:55 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 8FFD23858023 for ; Sun, 22 Dec 2024 00:05:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FFD23858023 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8FFD23858023 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734825931; cv=none; b=LT0bPbDIJNsUvl51/zhfEcz/vG3HoApwVyh5aPdNSIhjq2koAm5YJjTvHJA+a+1DEMWmKoWdAl07g2yGJXWjqpy8eGuEBNCyaK55t1yen2USkrW6Xyzt1oaU2scb6A+fp68oVuZG9YojahSSgozHOevB7qPOxUox/FSy1gA0Wic= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734825931; c=relaxed/simple; bh=Nppd87TTeZaYO/gyNnr1vuKxyBP4IhhVzkLFfPggfao=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jF+7aJzY+hLVsxWx2oDZIuuXtUI7vckGPaa6DNqqxUMD9X2NWROEFNccs3h5C2Qy3rDDGBGMVLLeKzpfToA8Xj2bKPpCor5NQSaDvWLAjeDdff8rbUex16l+qTo5VwQi4l3eRx7072CxE40lzrm+n4Ysw3mi6+aH9XgOBDuAO+8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-7ee11ff7210so2287763a12.1 for ; Sat, 21 Dec 2024 16:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734825926; x=1735430726; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Or4dF0rvG7MszB1UGemXhk/dh+3FveWLDf6tKUwPKiM=; b=SOgTtNyHQL3hPtjfZ5XcOaQhMErDMvrjOWS5KXUIm/JlVSr5GccJp+MMxBVkIBpI/w t2alCgs4/x3fGMueCS+vkxAnuHlaTaoCSDWts4RHAhD0WkLdkFFyZjektr4DSwRas5PG Yzhs8cZ7aOsXN3t/ZK56gr3If6kC8xY8LGRlgWoVvdPr2gdTjeVurN2OsWWIIffw+g77 /RncrzP2O11bOQeEmPXkNt/3rHj1Tc1Eu6jAlW5AEDIFkaRINJW04mnDGFvfkHGNNlqr BwdiOj3pdBVz6TAqKHY4W5a2cnpDy+uvWWk3LFsgEkLQwGXq8n+guiHkc3IbWg8ZicMX yzUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734825926; x=1735430726; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Or4dF0rvG7MszB1UGemXhk/dh+3FveWLDf6tKUwPKiM=; b=di0mS0TtAWNfEmoMySJpFLM+rdID/JV35lZsaoZL5r29RFiogZtmLg1y4BWWEl1DxD 71p7JjAM3TPppOA68TLiAoLn5NPhJvTiUIB6SUv3fuRXYa/RSp4j0ZUv2vHZQwS/Bsz6 vbvKbeUgAFRjBz/evlEWMvihqiOfB0ljNlQ61667uyJxlCRAgCL5quofeATuiklP//W/ iWGGHHR7jNWNsZ7CZIT9cXDno+LROlUcBfM5G3CihAMl9FOZOOGilu617ZjvxsO8CNaC hMCIXb0eBU2AqfzgeFE0TW0UbX/jY0TKqDLgyzhduMfY0eoqzOOnKUy188i9o4Ly7kqp B7Qg== X-Gm-Message-State: AOJu0Yzc7vlKtLEhHX7t6rkg1NR9ZU5pmpBziouXqchs/+4IM0j2bRBl nli+Ko2fM6PDpPgcbVCwWD3ZCejsjwOkcZLIX+xgLMPcZWcF/D4L X-Gm-Gg: ASbGnctx2dqZsBRY89JNDpfcyvSE4xW8XPHdfru8BmgLuEQB5QtvMk54Dwf/BqXlLz0 1G+nhwULWasc+irY/m9EROzBnnKcHlxycLRa6K0cXgv7xSAl+6+C3IEMZ3Zv4q248GRlFX77oo6 XcNHq9LuTGoVAVU7Vhc6x0gQ37hiDzH1Y/T3pC3umhmhAvNUfABrpBSm7XHZlPQJBtMxblpdj11 mLEvzK35VUNjUqDDX4bMezvbyvkCTJlSL9Q2LQ3Ux5T/bnG6LlHcqfI8BE8BwWxrzEkUPY= X-Received: by 2002:a05:6a21:3996:b0:1e1:c4e4:8898 with SMTP id adf61e73a8af0-1e5dfb67313mr12734248637.0.1734825925818; Sat, 21 Dec 2024 16:05:25 -0800 (PST) Received: from gnu-tgl-3.localdomain ([120.204.185.181]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8164desm5274686b3a.18.2024.12.21.16.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 16:05:24 -0800 (PST) Received: from gnu-tgl-3.lan (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 4E465C0AF2; Sun, 22 Dec 2024 08:05:15 +0800 (CST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: sam@gentoo.org, Adhemerval Zanella Subject: [PATCH 26/39] stdio: Suppress %Z format for clang Date: Sun, 22 Dec 2024 08:04:49 +0800 Message-ID: <20241222000509.2205895-27-hjl.tools@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241222000509.2205895-1-hjl.tools@gmail.com> References: <20241222000509.2205895-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org From: Adhemerval Zanella clang does not handle %Z on print, and just suppressing -Wformat-invalid-specifier might trigger another warning for extra arguments (since %Z is ignored). So suppress -Wformat-extra-args as well. For tst-fphex.c a heavy hammer is used since the printf is more complex and clang thrown a more generic warning. Reviewed-by: Sam James --- stdio-common/bug1.c | 11 +++++++++++ stdio-common/bug5.c | 6 ++++++ stdio-common/test_rdwr.c | 7 +++++++ stdio-common/tst-fphex.c | 5 +++++ stdio-common/tstgetln.c | 6 ++++++ 5 files changed, 35 insertions(+) diff --git a/stdio-common/bug1.c b/stdio-common/bug1.c index 18e7d4c257..f23ee5b6bb 100644 --- a/stdio-common/bug1.c +++ b/stdio-common/bug1.c @@ -1,6 +1,7 @@ #include #include #include +#include int main (void) @@ -13,12 +14,22 @@ main (void) stream = open_memstream (&bp, &size); fprintf (stream, "hello"); fflush (stream); + /* clang do not handle %Z format. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-invalid-specifier"); + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-extra-args"); printf ("buf = %s, size = %Zu\n", bp, size); + DIAG_POP_NEEDS_COMMENT_CLANG; lose |= size != 5; lose |= strncmp (bp, "hello", size); fprintf (stream, ", world"); fclose (stream); + /* clang do not handle %Z format. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-invalid-specifier"); + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-extra-args"); printf ("buf = %s, size = %Zu\n", bp, size); + DIAG_POP_NEEDS_COMMENT_CLANG; lose |= size != 12; lose |= strncmp (bp, "hello, world", 12); diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c index dfa19aed55..c46810f94c 100644 --- a/stdio-common/bug5.c +++ b/stdio-common/bug5.c @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -30,7 +31,12 @@ main (void) return 1; } for (i = 0; i < 1000; ++i) + /* clang do not handle %Z format. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-invalid-specifier"); + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-extra-args"); fprintf (in, "%Zu\n", i); + DIAG_POP_NEEDS_COMMENT_CLANG; out = fopen (outname, "w"); if (out == NULL) diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c index 67fbe4e1de..8e501ba20f 100644 --- a/stdio-common/test_rdwr.c +++ b/stdio-common/test_rdwr.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -54,6 +55,11 @@ main (int argc, char **argv) rewind (f); (void) fputs (buf, f); rewind (f); + + /* clang do not handle %Z format. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-invalid-specifier"); + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-extra-args"); { size_t i; for (i = 0; i < replace_from; ++i) @@ -101,6 +107,7 @@ main (int argc, char **argv) lose = 1; } } + DIAG_POP_NEEDS_COMMENT_CLANG; if (!lose) { diff --git a/stdio-common/tst-fphex.c b/stdio-common/tst-fphex.c index efba482537..7c0e4bd6fc 100644 --- a/stdio-common/tst-fphex.c +++ b/stdio-common/tst-fphex.c @@ -3,6 +3,7 @@ #include #include #include +#include #ifndef WIDE # define STR_LEN strlen @@ -56,10 +57,14 @@ do_test (void) int n = SPRINT (buf, array_length (buf), t->fmt, t->value); if (n != STR_LEN (t->expect) || STR_CMP (buf, t->expect) != 0) { + /* clang do not handle %Z format. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat"); PRINT (L_("" S "\tExpected \"" S "\" (%Zu)\n\tGot \"" S "\" (%d, %Zu)\n"), t->fmt, t->expect, STR_LEN (t->expect), buf, n, STR_LEN (buf)); + DIAG_POP_NEEDS_COMMENT_CLANG; result = 1; } } diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c index b2e8263283..c0a64d22c7 100644 --- a/stdio-common/tstgetln.c +++ b/stdio-common/tstgetln.c @@ -16,6 +16,7 @@ . */ #include +#include int main (int argc, char *argv[]) @@ -26,7 +27,12 @@ main (int argc, char *argv[]) while ((len = getline (&buf, &size, stdin)) != -1) { + /* clang do not handle %Z format. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-invalid-specifier"); + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wformat-extra-args"); printf ("bufsize %Zu; read %Zd: ", size, len); + DIAG_POP_NEEDS_COMMENT_CLANG; if (fwrite (buf, len, 1, stdout) != 1) { perror ("fwrite");