Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7204335rdb; Wed, 3 Jan 2024 07:57:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJtg5VHP8jl6trTtP0Um1VpQxMNFeqoPukgVNG1p+rYvTnKSkvkFEGeBQSitjOjuLgwOk/ X-Received: by 2002:a05:6830:1d70:b0:6db:fdf8:2347 with SMTP id l16-20020a0568301d7000b006dbfdf82347mr11126550oti.5.1704297435426; Wed, 03 Jan 2024 07:57:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704297435; cv=none; d=google.com; s=arc-20160816; b=ourzf2n030bViWrbgS/6uqiMCdjuSPyQcP4OpYuSTrzhWJMp8UCChQcC5Xs9LndQsx 1yTgPFO43f7Asc285R4S0zNdCYayaRhFfc4oyP7zEb8Y1VPBgMZYhaaC45/wYYDyHLE2 bgePGpINiE22wLiKvTevgc89++v032H1yGFdd8Wbc0627HH6tkurhRxk8ug85Ync1XwO OYPs+rAfxRk4VQ14UdriXw7t4bcLUTwRgXPseg/UUTx6XuHYOOpf5P3Vwzi18CCaxLPQ 2n3KNXIMaTnam5CoSYow/YvruePEZOS9mtzWmX3gYVF6+tQO5wemNs9me1R476EIp3kd eV7Q== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=TLBb7DQUElgXNvrClvdksa5Uy8ZfaNeQxv6yIl0GIds=; fh=uX1PtTQGM7m2H4joLkBk12PH7m96Z5dFi1DtE6ZZN2I=; b=HqnpoytuZciCWpURfCcVC4QL02cJ0rmgLUGXJvbDxS5zUvob5hnDd6ZeaZXruLH/4N ucqSmoOL/PlX1AEYgeqjneHBN3DYTPoWhbCRPHJuZ7GX4h/ZoP7uUjfDwFaWJnu6+6RD yAU68UFQ2pDY+wHjwD0Ud7sq+Lcn2ibtwEDjQK0Coy5zAmI93KpCc/dFPzgrBGcZQJSe POlo36TUMNNEOWYsZBU/6y5CqYVH4Zkxufw7S+4paNJ+aWyiBJoEEDHMbrSA2217vAXt WLdrUutmCrOx14M6eRsxnQBok+kNYs4cXhvSFtZlbFVkPnCgXbJN7c8jQkB1ChFTnAGf dW9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=faOA7cXY; spf=pass (google.com: domain of linux-kernel+bounces-15719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15719-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bv186-20020a632ec3000000b005c6646565c6si21889005pgb.639.2024.01.03.07.57.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 07:57:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=faOA7cXY; spf=pass (google.com: domain of linux-kernel+bounces-15719-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15719-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 094F3286735 for ; Wed, 3 Jan 2024 15:57:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 849F21B285; Wed, 3 Jan 2024 15:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="faOA7cXY" X-Original-To: linux-kernel@vger.kernel.org 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 BB7E21B270 for ; Wed, 3 Jan 2024 15:57:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86B40C433C7; Wed, 3 Jan 2024 15:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704297428; bh=NpPuzQFBGbgeu9AeAOqJOV1DXdhIz90+Va4NzPBZOdM=; h=From:To:Cc:Subject:Date:From; b=faOA7cXYIXfg6x8l7HMNTrgs7Nbr/DyiDw0mx6ONZ5H2KlMWcmx54k8Gx+Xwi16gz 0W9fvhrfuIbCevzLuUA+4IV5SSRSCT6H45ldbvYJ1PU4d1/iTC4i/bkEJ7RdSwTgVR u80wcRWQnHpjXylTi3JdpOyLFKl40YElLrvZXuOje7RijnPVP+ba8RlX8Pel9U1c60 CMIoa2ePFb37x0xNySPhjXmSf4fA/2yX4rvadYY3f2TMaBfcH9Rcyu6tJPljr2eDk9 SbFnj04EgcDwbiNhlVlMB7E/gyHXO1s8J2mG2PVqX+Jh82+aABEsLsDdpTtBET5N3T H0N0q5+gvut8Q== From: Arnd Bergmann To: Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni Cc: Arnd Bergmann , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] nvmet: re-fix tracing strncpy() warning Date: Wed, 3 Jan 2024 16:56:55 +0100 Message-Id: <20240103155702.4045835-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Arnd Bergmann An earlier patch had tried to address a warning about a string copy with missing zero termination: drivers/nvme/target/trace.h:52:3: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] The new version causes a different warning with some compiler versions, notably gcc-9 and gcc-10, and also misses the zero padding that was apparently done intentionally in the original code: drivers/nvme/target/trace.h:56:2: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] Change it to use strscpy_pad() with the original length, which will give a properly padded and zero-terminated string as well as avoiding the warning. Fixes: d86481e924a7 ("nvmet: use min of device_path and disk len") Signed-off-by: Arnd Bergmann --- drivers/nvme/target/trace.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/nvme/target/trace.h b/drivers/nvme/target/trace.h index 6109b3806b12..155334ddc13f 100644 --- a/drivers/nvme/target/trace.h +++ b/drivers/nvme/target/trace.h @@ -53,8 +53,7 @@ static inline void __assign_req_name(char *name, struct nvmet_req *req) return; } - strncpy(name, req->ns->device_path, - min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path))); + strscpy_pad(name, req->ns->device_path, DISK_NAME_LEN); } #endif -- 2.39.2