From nobody Tue Dec 2 00:46:07 2025 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (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 32EEB26ACB for ; Sun, 23 Nov 2025 18:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763922132; cv=none; b=cksS9XzP2CwHyfDtz7i9AoPDZw8hGKnlq6Yri0kuxpF4MTiHpWkQgZH0Or1nHB+KjDLTX9DBpvJWq0TFRzIS4ZIgbZutk1U+vaDnyAy2gE8sups24dvK8K10uODz4wLvNvp/n5aOdKCMGy4QqeYUiuWRuMIz3+GHkqusRepMiEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763922132; c=relaxed/simple; bh=QgZNdSebZ0AwjGI5BlrkSAEPtE8ySVZmEGtO+ORF8ns=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=k8Shv8gO4lrzjzv27LDdkD621SKIYUH4ZU/wnfMKgNUBCbaqYmTkbwSV9jVnKbkui+ztm4zq4uUzPubuSbsX4sk8iZpdWYoHaxaaA3v93ku+ZghU/ThAgpRCSFMI+199OpwED+xeDlsFHOfK4YKTsDyleGbiEdY1ZfWr+BTMK1o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=n5PUgc53; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="n5PUgc53" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1763922127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3J9JjQtfgm8UYDdC2K3YVWzSmm5VOLmlGlWZR4kUgKM=; b=n5PUgc53IGZk7rnW45h7xIOX4WjCtu+cu6AagnyTbyCY1bY4GsEmn1VJYa6zBEQMAv2HAp +wE2qig8eRx9I/7f9cuRc5rS/h3piqzFC2exF8NdWMsACE4/NxcdXh4MfBgKlCavLu1zLq FTEh/MvHTRf+nndQwMdCdM1pqCoVzZY= From: Thorsten Blum To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Thorsten Blum , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mtd: sm_ftl: Replace deprecated strncpy with sysfs_emit in sm_attr_show Date: Sun, 23 Nov 2025 19:21:02 +0100 Message-ID: <20251123182102.548130-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" strncpy() is deprecated [1] for NUL-terminated destination buffers because it does not guarantee NUL termination. It also unnecessarily NUL-pads the destination buffer if the source is shorter. Replace it with sysfs_emit() using the "%.*s" format specifier and supply the length 'sm_attr->len' to improve sm_attr_show(). Return the number of characters actually written to 'buf' instead of 'sm_attr->len'. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncp= y-on-nul-terminated-strings [1] Signed-off-by: Thorsten Blum --- drivers/mtd/sm_ftl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c index abc7b186353f..987d481bf265 100644 --- a/drivers/mtd/sm_ftl.c +++ b/drivers/mtd/sm_ftl.c @@ -44,8 +44,7 @@ static ssize_t sm_attr_show(struct device *dev, struct de= vice_attribute *attr, struct sm_sysfs_attribute *sm_attr =3D container_of(attr, struct sm_sysfs_attribute, dev_attr); =20 - strncpy(buf, sm_attr->data, sm_attr->len); - return sm_attr->len; + return sysfs_emit(buf, "%.*s", sm_attr->len, sm_attr->data); } =20 =20 --=20 2.51.1