Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1999300lqe; Tue, 9 Apr 2024 07:02:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXm5mso+T5Usv+YPT22Y7KFJ0wkopWGfO/xMOq7p6B09ZtCBCPgpkNuqInJA4bfelP9FPDlUx3AzvmubK4Eeg+uUlZ4Rdjvf8K+DibclA== X-Google-Smtp-Source: AGHT+IEsx8ujZ4QpOYRtYJSIKPJUQpykIe03TdYheqOyFj7ffCCjxCWIv4BEU4Pztyfn5bMu0Qk/ X-Received: by 2002:a17:907:9810:b0:a4e:299f:7f4f with SMTP id ji16-20020a170907981000b00a4e299f7f4fmr9062323ejc.48.1712671348839; Tue, 09 Apr 2024 07:02:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712671348; cv=pass; d=google.com; s=arc-20160816; b=n6od4nazWiip7C9MHnnynM61V39Qe9nuRfvnczaiEOC0fqEC6SLKVttUSwNRXVBMAY 9ggW3lL9MwwjOm1YUR9BkV2FTK419UxgB9c5n3zc4U42eEMQrgpsv/wWf5kMzcNvPAw7 vU9cbCOpvZ4NrfTXVWWImD+wAV3IUUeSPjkwlsaQcxecf3SSk7S7oC2bsQNTrPG/+Vvp MsHQgrEmCNXwrf7ymv1ezwxAqR/Ju2TKqHqs8sic0rsuMYlkbv2JPpKusp66jph/YPcJ HJBKWnCqV85qAUkwmclB8tbP3ittBwvGzYTcoe47MFrJqkKjZrUqzh8MtAAEdHElcB69 zmaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WXtgLsdr092ZHb3GuTQ6KoudMu22+ccAo9XriS/ToiE=; fh=d7NWZzVMBe+YtQ0AhDOD1J4yzuU7RP8mHyX/yJVFxsg=; b=fgbQaaIJuvA9armplQFvBx7+csmcp4H3WYbnvc5gjmklcjqFgwcifHSX2XYynDfYri aDrTY8m47DwfxaSh/sGuSv7+tvpQ4xiU5VN2qdoOZXAUfriDSmCdZ5GU/DV0qAq3kXcS XwuONNk64hD04L1zvx2Ut8POvcFT9XBGc+/H/kAqs73sRLoewbtimUrRg6f6eoALGsZO 7fNdH4BEVH6yiOtHTal5OUvfhx0yE2K/jzHaXwsbN6uggPTWfe6dpb/+c7byP9HpMFed 2oSbY4qp6J6+ogg6RqH9aGlSQanhy01J5LNLsutBUWotv+PVOnmyxGl+26Jl0AbbGpSE sOhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f+sLbW0I; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ji7-20020a170907980700b00a519df2e361si4965161ejc.204.2024.04.09.07.02.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 07:02:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f+sLbW0I; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-137045-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137045-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5A7A51F2358C for ; Tue, 9 Apr 2024 14:02:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 945DD12FF73; Tue, 9 Apr 2024 14:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f+sLbW0I" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 966F3130ACF; Tue, 9 Apr 2024 14:01:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712671273; cv=none; b=WQMtXTcj+B2/YUzi7QVbZO7nwoFQxSCNp/+KheKDscYkYNUYV6ezUtsDpSmK5KLAhu+ulz0hkUET1LTANZ/tPiZYby28r2rBuobnb44FfMwPPM0t1oXlYcMv5iceU9F0amtxm8LIFMP6gbWuV6w1kzO6kJihkQqYext/lzaKwKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712671273; c=relaxed/simple; bh=51Sfm2xp0PQT1gFODKUdeFbVWX58fUeGaMiFqFdRF90=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G2XYJ2neX2oRO4Q2KyfznSQOrnoK5Fc5SlJabwKeD4pVdAV+TObloGw9D+W0S2PAO7aUPF4FlfyqF7rn9kPFeF986M5YJsA0O2YQaysJU45sjuv75oM1dcCmIUR0XY18RCcYiJh/8LFVrMA1S+HwWqLS53POBCQlh5qZmy+IrPU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f+sLbW0I; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D60BFC433B1; Tue, 9 Apr 2024 14:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712671273; bh=51Sfm2xp0PQT1gFODKUdeFbVWX58fUeGaMiFqFdRF90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+sLbW0ImOrvVzf5VOnMgtlmcW5JlPVUKLm+TksiUIm87QHwts5XhrwCkeu0+a775 kucx+qagico8Y7FiqyDwpWV7aJYhNg/sBc4ij6yZwCml8OLedkqHfMy990NutRYSLo o2Q69k0HsodpvGjQC9oZW1jLG9QOQjoI8T30/2Tb3qIYnJoc1GfbYdKoVRbVrBsZ4S 7WCJGAMull3hGNt4lnfSrrA7+hz7p/FD8CRkT1Jz1k/HspEJOLrVwINHLlCQsYcUlp FiuuTQvX6PhA0pez7lzCebwbKsCQtj64D/VfLCV3Zq4Bx3KiNzr0BxVWhbtvcI4E/P SBVvxTGXuNKkQ== From: Arnd Bergmann To: linux-kbuild@vger.kernel.org Cc: Arnd Bergmann , "Richard Russon" , Jens Axboe , Robert Moore , "Rafael J. Wysocki" , Len Brown , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Lin Ming , Alexey Starikovskiy , linux-ntfs-dev@lists.sourceforge.net, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, acpica-devel@lists.linux.dev, linux-trace-kernel@vger.kernel.org, Justin Stitt Subject: [PATCH 1/5] [v2] test_hexdump: avoid string truncation warning Date: Tue, 9 Apr 2024 16:00:54 +0200 Message-Id: <20240409140059.3806717-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240409140059.3806717-1-arnd@kernel.org> References: <20240409140059.3806717-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann gcc can warn when a string is too long to fit into the strncpy() destination buffer, as it is here depending on the function arguments: inlined from 'test_hexdump_prepare_test.constprop' at /home/arnd/arm-soc/lib/test_hexdump.c:116:3: include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' output truncated copying between 0 and 32 bytes from a string of length 32 [-Werror=stringop-truncation] 108 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/fortify-string.h:187:16: note: in expansion of macro '__underlying_strncpy' 187 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ The intention here is to copy exactly 'l' bytes without any padding or NUL-termination, so the most logical change is to use memcpy(), just as a previous change adapted the other output from strncpy() to memcpy(). Cc: Justin Stitt Signed-off-by: Arnd Bergmann --- --- lib/test_hexdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_hexdump.c b/lib/test_hexdump.c index b916801f23a8..fe2682bb21e6 100644 --- a/lib/test_hexdump.c +++ b/lib/test_hexdump.c @@ -113,7 +113,7 @@ static void __init test_hexdump_prepare_test(size_t len, int rowsize, *p++ = ' '; } while (p < test + rs * 2 + rs / gs + 1); - strncpy(p, data_a, l); + memcpy(p, data_a, l); p += l; } -- 2.39.2