Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp214553rdb; Thu, 30 Nov 2023 02:56:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFralY6wSSVe3sdpVJgLcfR5m7ClX/FzC9lFXTLGdJv8+hhcsD+aQ4x3aLO/1SGrE27hbuJ X-Received: by 2002:a17:90b:4c41:b0:285:9a34:5b40 with SMTP id np1-20020a17090b4c4100b002859a345b40mr17055305pjb.40.1701341786919; Thu, 30 Nov 2023 02:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701341786; cv=none; d=google.com; s=arc-20160816; b=NGfOYbCWsABEaa7us9X8lnwE5t4E5wD2j6qIIIPFlm6Gs+XBZ0x8kxCNACIGEaJYQr 5IdJgxMeHFNaOGP653Fz1nROBIAgjqvzAMZB/v2IgMsLZX/J4z/AETW89dBujnK/Cgbh zO573+UYXAnNrRm0JbtHyC8a1Ogkrz5U49mck7j5+EDIgfEMTsTBHwC6d2atMpkgyTSy 5JZ4BPlKF66db1aGz3cInTA3PwKPMP7CqzH95p06iTCI9jDRQokmwGRyS9QDJSryJ/vq PLFvQA0ZSbOO8YftztVwpVVrBpWstTmZBTfgsJUp6aSt/EnPEFznycBBW93532r66mGa ENng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zCmk8/OcV7sw4c3ZZfMY5TKn7fGPr7r0NUYbor1zk8I=; fh=O3ci86hEGM9w/3WcGCRLDrfzi3/r7flAYJO7qVsC0uY=; b=eNQhoQJwFMx9bQQkJKA4pZPJ6WN5Z+qFeoAxfK0SccLNnYAxtmKh7NLmuHQFJ14Hp+ UID2ryhPa+59Saewh9DKn7x0d2p9AzDfRNkFwlagHW6BYhiECfzENvYiDANEnv7lYrVS daF3ko8qj1huR4em7fH71LCe7Dmui/JU0OvcgaYVK5qb7eeS4rrr2h/pWJXaWuW3MbrU iO4S+6p/RjI1XM1q70euB27HiXDA8PYurA7qWZDDMi0Bjaty2ZQ2DxdsBae3YWkljxVP VpdPyOjqATQQgLlggoZG5m7JtU95yxv5jTwgpy6XANCLsNB/+9HR5UUQ0ct6OWV3kfN8 nTIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lp7SZy0N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id p7-20020a1709028a8700b001c383a64ebesi917129plo.319.2023.11.30.02.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:56:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lp7SZy0N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9934C8076669; Thu, 30 Nov 2023 02:55:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345140AbjK3Kz1 (ORCPT + 99 others); Thu, 30 Nov 2023 05:55:27 -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: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 30 Nov 2023 02:55:48 -0800 (PST) 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/function/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 = -ENODEV; goto out; } - ret = snprintf(page, PAGE_SIZE, "%s\n", - tv_nexus->tvn_se_sess->se_node_acl->initiatorname); + ret = sysfs_emit(page, "%s\n", + tv_nexus->tvn_se_sess->se_node_acl->initiatorname); out: mutex_unlock(&tpg->tpg_mutex); return ret; -- 2.43.0.rc1.413.gea7ed67945-goog