From nobody Fri Dec 19 18:53:14 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C858EC4167B for ; Thu, 30 Nov 2023 10:55:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345153AbjK3Kz3 (ORCPT ); Thu, 30 Nov 2023 05:55:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345109AbjK3KzO (ORCPT ); Thu, 30 Nov 2023 05:55:14 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A7E170B for ; Thu, 30 Nov 2023 02:55:20 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 218E9C433CB; Thu, 30 Nov 2023 10:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701341720; bh=EqaFNvqa3Yaf2e/v2zXcPa+NF9mRVVDkSa+wDJv0Wc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lp7SZy0NUGDmnnSAUp1ak9WDeEeL2H3QZaY62S6szF6Uimt0rETKvW06GDU2UMBqQ PFL/Wh7mo6eDkzK+rlw0+VmJVokekplOWxPD1oSyUuIW989CUreK3vlsl+BBCT6UbD uakMX3Sbkyo4F04JXRzAmTVsKSgKDPaRBj0oYqCEFDPXNpNzXUQIwlMcnAtrihM/rM cPdP1c/uDBJHA2H0raR/lSYh01PlIFlAw71455l9Ux6r+GSDsl3wAVCHZ5foajhuvG 5aztBRabH35wVkn7sIFZ337MmNW9zM9JmeqqXWEsH2RapDKT9V8RETIbMUvHYZUt2D kkwP4OiYy0/KA== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Martin K. Petersen" , Dmitry Bogdanov , linux-usb@vger.kernel.org Subject: [PATCH 5/5] usb: gadget: f_tcm: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Date: Thu, 30 Nov 2023 10:54:39 +0000 Message-ID: <20231130105459.3208986-6-lee@kernel.org> X-Mailer: git-send-email 2.43.0.rc1.413.gea7ed67945-goog In-Reply-To: <20231130105459.3208986-1-lee@kernel.org> References: <20231130105459.3208986-1-lee@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since snprintf() has the documented, but still rather strange trait of returning the length of the data that *would have been* written to the array if space were available, rather than the arguably more useful length of data *actually* written, it is usually considered wise to use something else instead in order to avoid confusion. In the case of sysfs call-backs, new wrappers exist that do just that. This patch replaces just one use of snprintf() found in the sysfs .show() call-back with the new sysfs_emit() helper. Link: https://lwn.net/Articles/69419/ Link: https://github.com/KSPP/linux/issues/105 Cc: Greg Kroah-Hartman Cc: "Martin K. Petersen" Cc: Dmitry Bogdanov Cc: linux-usb@vger.kernel.org Signed-off-by: Lee Jones --- drivers/usb/gadget/function/f_tcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/funct= ion/f_tcm.c index ff33f31bcdf64..37befd6db001a 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -1504,8 +1504,8 @@ static ssize_t tcm_usbg_tpg_nexus_show(struct config_= item *item, char *page) ret =3D -ENODEV; goto out; } - ret =3D snprintf(page, PAGE_SIZE, "%s\n", - tv_nexus->tvn_se_sess->se_node_acl->initiatorname); + ret =3D sysfs_emit(page, "%s\n", + tv_nexus->tvn_se_sess->se_node_acl->initiatorname); out: mutex_unlock(&tpg->tpg_mutex); return ret; --=20 2.43.0.rc1.413.gea7ed67945-goog