Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp214562rdb; Thu, 30 Nov 2023 02:56:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgh2/FQkMkLWIHNOjPVmR3CyXb9L+2T9JLvty9OSM/JLiWytL/uPdy9ybKXzc7E4RBrJQX X-Received: by 2002:a92:c534:0:b0:35d:3b79:7617 with SMTP id m20-20020a92c534000000b0035d3b797617mr1459015ili.0.1701341787541; Thu, 30 Nov 2023 02:56:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701341787; cv=none; d=google.com; s=arc-20160816; b=TpXK0vmleOPzarKK6rHIcWQR9jyPpksyv9TITmdyqt3heqSdgiANp6gOqR2Z+HMlI6 5GgZuNVFf4dRI5nHPPmAfTNygTvQM2MQ/jiMbXu1OtFlevdcAsP6cWWBoD7829seuqGt 3+iCwZTtKxCc6ca9Qbm7mhnOJ17vluXbIHbwBOHxd5aH1I7/p/UsbviKVH8f9aowD+lC TXQB5K4ggaBdtH+d6BKJXHH1Jro96caHDU8OmK/4+5vwsqC/4ufNNlVKTM2NyF2Yk7NW +gJ0wtvBGnEyeC98XdcUWrbsW4qHYCz4xHvtxpUHRd/WDEwRVTf4gHDad4PZWzfvIFYu WmYQ== 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=siZEx6QlTlU7yBJ95DA4dKRSNb5nQW98f3glB77bt4o=; fh=6lIH5Orw3Z32jZlgFsLTy/ys6XO2U2mTE3pq86XGXJ8=; b=ld0JG8zlzjBU8oxCCgUOIiwitURbQ68vNr/KBF744fNvaa4Qavv8R9J2PBSU+I95qe 8yo9BA3Tazfu5ezi9vUwLov9da1AjZ58YT2g/hnDxwg0gosiubr4i/M+VT26Kh4rWPSm mM8MoHgspvG0c4dQ8Ve2g9U05Zfk+/QEuAnfhlI/cmDiMNMG0wVCAa42xVHJhAxNs2fR 4sGHqAuthuVhrNGfA3i7mvMTBMlYvpSn82YsGkLO0s42To+KJ1D3aqhUZjGX7rkSXjot 0atIK4KBRH4BYInHa87IZt95jKFn7EotMfN52YdwgkzUk9yv8zorAwRzaMs6tyZW0dbj HTFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="M/7ElH+x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k190-20020a6384c7000000b005c25a1d3916si1052865pgd.651.2023.11.30.02.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:56:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="M/7ElH+x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id DB3AE8080C5B; Thu, 30 Nov 2023 02:55:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345135AbjK3KzR (ORCPT + 99 others); Thu, 30 Nov 2023 05:55:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345081AbjK3KzM (ORCPT ); Thu, 30 Nov 2023 05:55:12 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 100AB10FA for ; Thu, 30 Nov 2023 02:55:19 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A841AC433CA; Thu, 30 Nov 2023 10:55:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701341718; bh=/XOh9djbd1kRjRIJaFEo79gsQogKZILFqya3ZNX3dzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M/7ElH+xTwmRE/jQTEQPLVFtUUURsQO7RbtCR9vxOg5H7Gx4ArBGSB9MkUmH5CF5E szynq61yJlRo4ltLpVSCDAMrZQiXgH3j9/qyA5woBqJqjsVy/uNlp5VKKajiNyCKMZ PmuSoGJGgyI611UCzIabzZySOnX+87zpCgULh+zKjXnF2nIZ/BvI58pKkaOUWM8ick mvUGbVqUhRs7VMauF6ygzEG+4Evd0+RI9YYZKy8aEaVn6ng2JizzUyalZjjxkT5LYG ylBtp51MF9qOLB6skfhw2WPf5GU7v6YFGgPJTTiemGSiESLpG1GExPLuPpuFzsZXvR FQ7MWMmPFKteQ== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , linux-usb@vger.kernel.org Subject: [PATCH 4/5] usb: gadget: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Date: Thu, 30 Nov 2023 10:54:38 +0000 Message-ID: <20231130105459.3208986-5-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 30 Nov 2023 02:55:50 -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: linux-usb@vger.kernel.org Signed-off-by: Lee Jones --- drivers/usb/gadget/configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 4c639e9ddedc0..b7d2a1313a684 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -812,7 +812,7 @@ static ssize_t gadget_string_s_show(struct config_item *item, char *page) struct gadget_string *string = to_gadget_string(item); int ret; - ret = snprintf(page, sizeof(string->string), "%s\n", string->string); + ret = sysfs_emit(page, "%s\n", string->string); return ret; } -- 2.43.0.rc1.413.gea7ed67945-goog