From patchwork Sun Dec 22 00:04:54 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: 852898 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2774165wrq; Sat, 21 Dec 2024 16:33:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfE8oX7fAaGs+e0jlSDjdwBnW4I/LFluRVsOhBwfwPTJp8rqSmKd510CkDN/nCCP7j8t5OWg==@linaro.org X-Google-Smtp-Source: AGHT+IE5vrY+nQ2SYopzm08WnknFVhGPMAXu7ltLYP1XKjvbIROu+SR3KNsP3PvkOIzXVDXEfrcC X-Received: by 2002:a05:620a:2449:b0:7b6:fdb9:1be6 with SMTP id af79cd13be357-7b9ba7a582bmr1108059085a.29.1734827612980; Sat, 21 Dec 2024 16:33:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1734827612; cv=pass; d=google.com; s=arc-20240605; b=ge6I4ZoNOlL1s0OGd0RtGzcJII7gv8RGkc/7vwftzEIkg4QlLyJ6eum3AjPbG0OpHw GamAQoTPNSgKjhlEkxbzx+E+WQBvW0I5pbbWrNUAyadZL4wTkX0KxviRsFOzFsPNzPhG L6nH9fZlqEDoZpLZHa+1HZ1kMHqaDRq8aMluZkU0Q7fVh8oFDzjUUh8NN3C8jNXdYUrj SuzNY5WZSbEZ+Bi1++4xBhCL4YdA16Ghih3jvVuT0lGenEzmj4OyXp36LnnxK3lG187v Fg6hYaATYnUDe9AqePQ+5WF6vVftkcbj16xytock11/2IgoqnB53/LvbJBq/21eucFk7 KgDA== 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 :dkim-filter; bh=ax5OnTZHzyQf8MhwgFJtihzpupsr1aJ7N0NIw6nrVOY=; fh=uKlFkH9AUukvL1xmvBA9M7Oe4ntiJIR8HCR4+3TPd4w=; b=Iep47Pvez8nY7U9dcfkKEeg9qBKi6+pC0vImklQY5+mSLz1//cBZ70ff9sL/w+MEWG HgQYYY/QqATExpoHBWZ6n4ZBbdtb2cPMc8s2H73CXkv7OSr8fhd8rrDGXXu+6av9I32d EXQkuFQydPLt5TiOixX6INaYQ5gKFWiwg4plJKNplxt3kUnAYYNhHGiw5vsFCHLKdwsS SQHieEVC7bHJ6mF0fu3Qip2qHhelLv4i0aYwelNo0euO8BORjkpOt9PvNxdbsJHLPp++ ANKiOgiyHQzpCLSdQcbm+bxF1OEPudNyFpBHstGWNzggbyVLZjFXxb4GDd43WmwUGpO5 XuKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="M/Cc813O"; 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 af79cd13be357-7b9ac2ab70bsi866053485a.31.2024.12.21.16.33.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 16:33:32 -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="M/Cc813O"; 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 EAD433858D3C for ; Sun, 22 Dec 2024 00:33:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAD433858D3C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M/Cc813O X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 8FBC73858280 for ; Sun, 22 Dec 2024 00:05:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FBC73858280 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 8FBC73858280 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::436 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734825927; cv=none; b=TxlPLQN43fcu/QT3Blo+DUXSGw99hnTwM17X3DZ9vSm2y6c8szbyro7W2FDJDB/65UlUXwPq3rdCfWrw8c4h6LAWhTbH+h2ffBXaaKvGrcjtIOtw8mz/Fim7oDURrYDNsn9y32cYWgpJLfFom+yTNInwb0QfnpAPMMucNBNBtW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734825927; c=relaxed/simple; bh=krU9AMZB8ifNaY9kNWRxKN0nLuvnmUCaCFM0MUYCM+U=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=O6H6vuwAkub+Rm8kCCN84O1Sdo9/bHC/IAIYT47PEJBQpefjT3H5qzzQ+d+5RbKiP417nUZtgF5S6+9kzM1gunfTeNFNBehTL62Y1WUU7yr1GVuvvuHDUeXh539XaSSpJnAZZvW1hYtFNvWat+xNp7Vbb9uXIlg6DZJwCCNP/+Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-725dac69699so2803034b3a.0 for ; Sat, 21 Dec 2024 16:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734825923; x=1735430723; 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=ax5OnTZHzyQf8MhwgFJtihzpupsr1aJ7N0NIw6nrVOY=; b=M/Cc813OJaSJtaeduLp45N8+6iK1dR/kfy4yHzLovE2pZOIIKcB1VFX1EaZFKZrW1G gHrZ6fx09RLKdy/E+jR4dIquq++JrRe509mipUz1fr6v/WNyY8f3BJIGhtLWbJSbWBrM XKSu2Iz32exMA0qDmBOZ7JZiEtT3YD7IQVLcx6F9Ci5SWEMeGrzYyu/USD1oQ6q0xAo9 A9DnlhBzV0HwtIScXaK7TKlnhVrtSmWZG08U3ZkPynfM1eBqcZFgvPh24D6zcf2z84Vg EBYXzGjIzbSg82U3EXoIvt9QqD02L2TC6gkgJfta3rkicD6J9J0oLZd2FTxjDQoodQuA VrUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734825923; x=1735430723; 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=ax5OnTZHzyQf8MhwgFJtihzpupsr1aJ7N0NIw6nrVOY=; b=ficMFCPkUPeOLdxbUxnfrX8ysmeWsipVwFI9l4dccgzXfR3BBKcahsBOYu6YMOUQ1d cIO+LIgt/VihMqZce7ajcL9gDbMYOfO0bCDb8tlvMt/eEM4lQJGqvFFSsafmtJHJ5AuL A5ILw8WmX6/MDd/RJZ+BgZolRzbZjg4waW61ufmjMqbZvE3QA52WF825whTqNECBPM89 drV6SqsSh0qdm1vueQk0GCyGI1VOkY30MJkuhZF7ZWONJCT9mksOZ+SHF6YvAgnFSYCx BdtqVj/mnvTXguwhCAdnN6/yYFIeFeiJ1bkLMAYj6b1lw+BOXOv4JiUPxFG+hTJhZhih fVsA== X-Gm-Message-State: AOJu0Yxd+L5DQ2bcwOuYjrwq0f1TSnoN4noFoeit8qYaNq0EIBN9RrbG jes3dLcBN9wKVDQO7zu1Cr/tYf8zuDUwna2fmR8J4oA1G09QRfeC X-Gm-Gg: ASbGncuNL2W1fPysp5B7KUe5Mt6OkDZbX3FJ8T81OHfBE3HHF4VJ/KS3UBQ/CE1GhhD cXMqMz8VdRJ5elkJEm1Ttbk+71390t2zAa4/+O2DdgyY6uXXOTJhKzwtZxY3jXP+7r+lQl4Ourj LNDqgvKFHQiDnmMskcJMslrH5tQHzl/p9J3e1tEDwTHt8U0/LYRyK7W4X1DvVbzibO55HpbhtZn XI9M8jbNHkQpqMDIhNOTJeemOKLCUHSLcpYA+2GDfwfjEWqUqBbmhBnDyK222UVLKrtQZI= X-Received: by 2002:a05:6a20:9f96:b0:1e0:dd4a:46b3 with SMTP id adf61e73a8af0-1e5e0461e0dmr12613227637.16.1734825922706; Sat, 21 Dec 2024 16:05:22 -0800 (PST) Received: from gnu-tgl-3.localdomain ([120.204.185.181]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8daf1bsm5269819b3a.118.2024.12.21.16.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2024 16:05:22 -0800 (PST) Received: from gnu-tgl-3.lan (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 83BFBC0BA4; 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 31/39] string: Suppress clang -Wfortify-source warning on tester.c Date: Sun, 22 Dec 2024 08:04:54 +0800 Message-ID: <20241222000509.2205895-32-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 Suppress clang -Wfortify-source warnings on tester.c, like: tester.c:385:10: error: 'strncat' size argument is too large; destination buffer has size 50, but size argument is 99 [-Werror,-Wfortify-source] 385 | check (strncat (one, "lmn", 99) == one, 1); /* Returned value. */ Reviewed-by: Sam James --- string/tester.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/string/tester.c b/string/tester.c index 3e3660777e..aa880be46c 100644 --- a/string/tester.c +++ b/string/tester.c @@ -391,11 +391,19 @@ test_strncat (void) mechanism. */ it = "strncat"; (void) strcpy (one, "ijk"); + /* clang complains that size argument is too large for the destination + buffer. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wfortify-source"); check (strncat (one, "lmn", 99) == one, 1); /* Returned value. */ + DIAG_POP_NEEDS_COMMENT_CLANG; equal (one, "ijklmn", 2); /* Basic test. */ (void) strcpy (one, "x"); + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wfortify-source"); (void) strncat (one, "yz", 99); + DIAG_POP_NEEDS_COMMENT_CLANG; equal (one, "xyz", 3); /* Writeover. */ equal (one+4, "mn", 4); /* Wrote too much? */ @@ -408,6 +416,7 @@ test_strncat (void) GCC 7 or newer. */ #if __GNUC_PREREQ (7, 0) (void) strncat (one, two, 99); + DIAG_POP_NEEDS_COMMENT_CLANG; equal (one, "ghef", 5); /* Basic test encore. */ #else equal (one, "gh", 2); @@ -415,13 +424,22 @@ test_strncat (void) equal (two, "ef", 6); /* Stomped on source? */ (void) strcpy (one, ""); + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wfortify-source"); (void) strncat (one, "", 99); + DIAG_POP_NEEDS_COMMENT_CLANG; equal (one, "", 7); /* Boundary conditions. */ (void) strcpy (one, "ab"); + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wfortify-source"); (void) strncat (one, "", 99); + DIAG_POP_NEEDS_COMMENT_CLANG; equal (one, "ab", 8); (void) strcpy (one, ""); + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wfortify-source"); (void) strncat (one, "cd", 99); + DIAG_POP_NEEDS_COMMENT_CLANG; equal (one, "cd", 9); (void) strcpy (one, "ab"); @@ -434,7 +452,10 @@ test_strncat (void) (void) strncat (one, "gh", 2); equal (one, "abcdgh", 12); /* Count and length equal. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wfortify-source"); (void) strncat (one, "ij", (size_t)-1); /* set sign bit in count */ + DIAG_POP_NEEDS_COMMENT_CLANG; equal (one, "abcdghij", 13); int ntest = 14; @@ -1438,7 +1459,12 @@ test_bzero (void) equal(one+4, "ef", 3); (void) strcpy(one, "abcdef"); + + DIAG_PUSH_NEEDS_COMMENT_CLANG; + /* clang complains about the 0 size argument for bzero. */ + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wsuspicious-bzero"); bzero(one+2, 0); + DIAG_POP_NEEDS_COMMENT_CLANG equal(one, "abcdef", 4); /* Zero-length copy. */ }