Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp457155lqh; Thu, 28 Mar 2024 07:07:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU/emygK8K1HBtnewWB9T8b2oesyOD3Lomn1XgKBkJnODWH5h5y/SIBE5Ilh8/WkiW4MTAyOhFrqrLcY8PHGNY8XvMFZupO2YCtwoS/cA== X-Google-Smtp-Source: AGHT+IHT8CE2yyIaYsUZZWJZEfHVXBpcNGrE9xCE5j48J1SvJLRd+pq8r9961IejkUKjr/z9i0vd X-Received: by 2002:a67:eb44:0:b0:476:bc52:2577 with SMTP id x4-20020a67eb44000000b00476bc522577mr3370393vso.4.1711634829796; Thu, 28 Mar 2024 07:07:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711634829; cv=pass; d=google.com; s=arc-20160816; b=mHO2tI8TjXv5VadQUzMaNmayiiHyExhAAj+p6iGXFrye7S94bwUiiSwHyGcgo2fbv+ Cglxgpi7+B4g8s29oWFQkfzRUuffM1fkiXKIKV1PpKxkFALX84lf8BX3yolH3xGS+qe5 S5upgXVRqmU+aGk3xvjQ04xbJRcoalmliBEaff2EKq9UNo5WlXlBP7LFXUyYf8J/gLE2 ftO2X6LU/GRt6XJHXd8GCDo8vvWntvAxHBhhhp7QbEjqZ4KO5PhLU73h8j3UkeGVfGc6 xsjreCBTUmb9LkVoebovLgqRdZjE52HIwxiLOReIT30ifD6uJ+I9zCo/z30nanijoRL4 q3hQ== 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=7bvrlQIWMWosoAeNTGUguL0He7SZ99nSDU+X/+zlQNA=; fh=CQwWcE6ctBCG+ds4E/fIo3ExJFeBoegbh6ZCTc3S4x0=; b=ETQogXmBDvzj7NNxMlK8t6tJ6Gu4kyNbFJNxUPh5xH6gZ/zF76aYRMTfFcDfyqyC/R /ZmH0sQz3OcrkVHfZwMmjjrD3ATkMUqeM9nMZqQWuV8TeCCuZ70jgmc77Ac+UiCyPkKH pGC0P6baG9orOFxpxyRdAQNOaGvbVmOpb2IkJ0azyQ8RuL4awQ1DOIFRsdt/ReWg2p73 nxfed8WdavAfzOlCy3Lt5SLrFAnY/cJxlX9YVFnkKOWzKBVyBdLY8ydlFeYmPCFhtCAK lqdb9jasNiTgqroXzFHxCxX6DrM0ZCfcOX9wwKl5gm1fOVbdTGQnZxRi5W5LGNeEHJxN KxEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tGBrVSKg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123020-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123020-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d7-20020a056102148700b00476dcc6feaasi174098vsv.153.2024.03.28.07.07.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 07:07:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123020-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tGBrVSKg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-123020-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123020-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 198861C2B5F8 for ; Thu, 28 Mar 2024 14:07:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB06F12D1E0; Thu, 28 Mar 2024 14:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tGBrVSKg" 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 D73E812B17C for ; Thu, 28 Mar 2024 14:06:34 +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=1711634794; cv=none; b=s9yyeTvGF2KmiCO7QB3PYWKo1ZDYXGLFtGRYr1gSOSiecXgELF+gPpp8OyNX2QBZZLrMnAPnzJvnmbaljmFuyqdKrta6Qy2VUPy2AivA8ZsxRquuwb4HtYFDwxnCdTfqI96WvKezgLyZcUi/VOAQolB4Iwx1mhqu9LDiG624sig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711634794; c=relaxed/simple; bh=/z3penlJXNolNdo44Cwa/toSbF2yR8i4Mak3/kq291A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IEGxqkzhcu1ZgeJGSy6cfb15eHg8Kyhulf00vcPTZFqMqInqqJfKRkgkn/h5/SQA8DVDp5S32G7nQ2z+lq0HkoLqZBn3WxSwIPA8TZqM0lk18RoiFUW0xiOtoiHaKBOTXRbx9Of1jVotBPzgk0HhjslpSK5b0F4B6JEyNUGanes= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tGBrVSKg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D44CDC433F1; Thu, 28 Mar 2024 14:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711634794; bh=/z3penlJXNolNdo44Cwa/toSbF2yR8i4Mak3/kq291A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tGBrVSKgykDqZ/dQD9dRPlC4fzYpN5MH+e6VEjn5Vn+S8EMrOcW+VR00oxIcEQ4WC OPmWGINlce6iA+Tsxrum92mvIhbquKTD38lqNu/4/hMjeaidIPGOQauXutFGf2OM03 JH99OxIHFRTK82X+eCbL4Noh+bK9V2TxuSEbo93wtW3aEJrkw/hGJTlBPMwiUwtsGh yGOQ8nzqXVoY6gFELp1qSs/D76NKaFg8jsEeIDgqyJ+rsuTv473vnhLq/cNSGxFqna MMJmXF1CUDmrA18LLyKd4bG59oRLVJZRHbe/g4sdeF6I0IoxWHmpvvm5IcdTz24fFl LNwgHuQw/ptnA== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Andrew Morton Cc: Arnd Bergmann Subject: [PATCH 05/11] test_hexdump: avoid string truncation warning Date: Thu, 28 Mar 2024 15:04:49 +0100 Message-Id: <20240328140512.4148825-6-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328140512.4148825-1-arnd@kernel.org> References: <20240328140512.4148825-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); | ^~~~~~~~~~~~~~~~~~~~ As far as I can tell, this is harmless here because the truncation is intentional, but using strscpy_pad() will avoid the warning since gcc does not (yet) know about it. 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..c9820122af56 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); + strscpy_pad(p, data_a, l); p += l; } -- 2.39.2