From patchwork Wed Jun 26 12:37:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 1952590 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=Z3Pa0kU/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W8LpM21fRz20Z9 for ; Wed, 26 Jun 2024 22:38:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 780163870C3F for ; Wed, 26 Jun 2024 12:38:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 8E3B538708F2 for ; Wed, 26 Jun 2024 12:37:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E3B538708F2 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8E3B538708F2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719405481; cv=none; b=uh8qLRN6UWpu9nCyBjrUr4asa2ZrgdF4gGDeLiJzGSSp9QCiXyk8sGyx/2qhJPYIxlEk2vuS4g8kyGGC5NLW4wFuyz+50zDoP+3C35wnKTa98cSBLmjaftNXaWW30FtCqK3xvr8jNN8TVX0SIyvj4AEl9rJtBZqONzDmZz5ijG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719405481; c=relaxed/simple; bh=LVE4iIhhcK9YS82KwYDo/t+9oPsfS40WN58Th2/ur2Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ICSviHr77Gqe6aosMAsO3C9hHWlFVBDSEWwQbYQ5wwmqFGPTRDATkH/jLec++RAghsTNEpMSS82GIiaeh6UadOzXLwABm/3m+XeFE9kNpAHlL3rWmWtqxNUhEp1086nHf3RiJFCkoqWkbgLBeez5OyTAGoXMph+E/9DdDtHIuu0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45QBpo1n022981 for ; Wed, 26 Jun 2024 12:37:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=pp1; bh=g+mNvfXxR9booJSjGzQxEQTo5y cT2ltwzlZBRoklhIE=; b=Z3Pa0kU/5I4KzYxlyVeGDGxFk9ZFdsiPLuFo1IooYG fXalK0t2aGCuJJcrjZo8ApfP55zP4Cl7ywiT54P/yP7n2DSlzeEs7dqv8J5NTx9V NWHgQJajuZuxwb55slIGa27+iXeajzHK9iCJmAYjHeH79XLZsLwdPVbh/9mWMFVg awda5MXV/jKxi/cdN9+/1Xyrw0XFLGYE7uK45RAfLMYmlI7wHMmSSJ6Rz9CkrVj+ fqIm5/tRZiYZcCB5M5mXlKSfmX1utsXeXw5Mp/wDhGS7Q7epllXWORLKHHhVneZr zeJA1Hugam3eVi3TUUNxcK8yz0hYpOBPP586DkYuuVHQ== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 400hq688am-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 26 Jun 2024 12:37:58 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45QA9RZ8032373 for ; Wed, 26 Jun 2024 12:37:57 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yxbn3c0bx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 26 Jun 2024 12:37:57 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45QCbpC219726728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Jun 2024 12:37:54 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CEA3C2004E; Wed, 26 Jun 2024 12:37:51 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B27212004D; Wed, 26 Jun 2024 12:37:51 +0000 (GMT) Received: from a35lp69.lnxne.boe (unknown [9.152.108.100]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 26 Jun 2024 12:37:51 +0000 (GMT) From: Stefan Liebler To: libc-alpha@sourceware.org Cc: Stefan Liebler Subject: [PATCH] tests-mbwc: Silence gcc 14 -Werror=format-overflow= Date: Wed, 26 Jun 2024 14:37:46 +0200 Message-ID: <20240626123746.2533951-1-stli@linux.ibm.com> X-Mailer: git-send-email 2.45.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: lwvDn8JthQsZV7Lge7xUYK9R6EWp8bmW X-Proofpoint-ORIG-GUID: lwvDn8JthQsZV7Lge7xUYK9R6EWp8bmW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-26_06,2024-06-25_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 priorityscore=1501 spamscore=0 phishscore=0 mlxscore=0 suspectscore=0 clxscore=1015 mlxlogscore=587 lowpriorityscore=0 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406260092 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+incoming=patchwork.ozlabs.org@sourceware.org With gcc 14, I get this warning/werror when building the localedata tests: tests-mbwc/tsp_common.c: In function ‘result.constprop.isra’: tests-mbwc/tsp_common.c:55:43: error: ‘%s’ directive writing up to 92 bytes into a region of size between 0 and 114 [-Werror=format-overflow=] 55 | sprintf (result_rec, "%s:%s:%d:%d:%d:%c:%s\n", func, loc, rec_no, seq_no, | ^~ In file included from ../include/bits/stdio2.h:1, from ../libio/stdio.h:980, from ../include/stdio.h:14, from tests-mbwc/tsp_common.c:10: In function ‘sprintf’, inlined from ‘result.constprop.isra’ at tests-mbwc/tsp_common.c:55:3: ../libio/bits/stdio2.h:30:10: note: ‘__builtin___sprintf_chk’ output between 20 and 234 bytes into a destination of size 132 30 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 31 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors This patch is now using snprintf to determine if we should fallback to stderr or output to fp. The handling of the return-value of snprintf silences the warning. --- localedata/tests-mbwc/tsp_common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/localedata/tests-mbwc/tsp_common.c b/localedata/tests-mbwc/tsp_common.c index cd88274c57..f09cdaf511 100644 --- a/localedata/tests-mbwc/tsp_common.c +++ b/localedata/tests-mbwc/tsp_common.c @@ -44,7 +44,8 @@ result (FILE * fp, char res, const char *func, const char *loc, int rec_no, int seq_no, int case_no, const char *msg) { if (fp == NULL - || strlen (func) + strlen (loc) + strlen (msg) + 32 > MAX_RESULT_REC) + || snprintf (result_rec, MAX_RESULT_REC, "%s:%s:%d:%d:%d:%c:%s\n", func, + loc, rec_no, seq_no, case_no, res, msg) >= MAX_RESULT_REC) { fprintf (stderr, "Warning: result(): can't write the result: %s:%s:%d:%d:%s\n", @@ -52,9 +53,6 @@ result (FILE * fp, char res, const char *func, const char *loc, int rec_no, return 0; } - sprintf (result_rec, "%s:%s:%d:%d:%d:%c:%s\n", func, loc, rec_no, seq_no, - case_no, res, msg); - if (fputs (result_rec, fp) == EOF) { return 0;