Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp214137rdb; Thu, 30 Nov 2023 02:55:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1Kf+DKwO3XVTA3n3yQ7Lk0BAQrZx1+s1E67HOnpueL11NV2qa6CwlfNnrvDE6MlzRseBR X-Received: by 2002:aa7:98dd:0:b0:6cd:e189:c0f4 with SMTP id e29-20020aa798dd000000b006cde189c0f4mr2842619pfm.12.1701341731969; Thu, 30 Nov 2023 02:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701341731; cv=none; d=google.com; s=arc-20160816; b=tpkTClyiHH2DqMHdThBhQ6z6yEmLG7inR9bq0kzzWl02nIQnBCiP8KFI1MhGXVNkl0 Abv/nOcQW/tZXW6E6DpopXVrn542sWuZSPVdQk+uWXsqaWZbeSow5Gi4JnT16nlLPUdk iOv2/rdiayXrn4Nfhe33aabyu+hC7qfliy4e+XN8bf+/nyOqklh/KV57oug27U8zoBrR QRRDCw4Te1SP5xv7jJYfTpOdyZ/QUwBcEWkg/LQeYjNBRrk29iQlEsEzgkPUUzyYWaLP Y1ucc/6GY157WS83pTQ2UtHkIA1lV3bl8pNrnebOH0b+8xCptYwz0yhMBJ29AdTEwFp7 0iXw== 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=VLwTtJWmN4G39FiWmL6DTI0zdof5+wP+piFp/bmjmVU=; fh=K180i7Utjm91ZkCftYWd90ROZiYZSUbGHP6NYYfPBzE=; b=ZjRVFPBTlVjE8Qo9dgy5OxFqjQ77hECfoaWpamE3aysoGdY0/q83R2DfRFOO3XZFV6 wMXfoWrJ6OB07gRSaHto13dfeyu5+viyGfAtPswZw1ByIPTldulcJUSCBy016x0OILsl l9hZfL2a30r/CPj1nMAfePGD+upE9q7fsDGxkP6Vy3q/3roEj2Bf+w8z5ZDzlocB6YU1 kB79mcGVx2EBfYYXbSAPojtumk+PTWB4oQy/2UJ3eHsPeC58Sup774+kKd06HWX+I+Ed kJeK6xJ/AJlEdHL7KZA8liVV7qk/gT/iMal9f+IRj/Qm65wqqTfOa8PFufAvQyLmybiy SkeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EOBnh8dQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id n189-20020a6327c6000000b005bd42f65dc5si1014867pgn.285.2023.11.30.02.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EOBnh8dQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id C1B018080ED2; Thu, 30 Nov 2023 02:55:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345100AbjK3KzK (ORCPT + 99 others); Thu, 30 Nov 2023 05:55:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345084AbjK3KzH (ORCPT ); Thu, 30 Nov 2023 05:55:07 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C299510F4 for ; Thu, 30 Nov 2023 02:55:13 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E26CFC433CA; Thu, 30 Nov 2023 10:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701341713; bh=5UqF6R+sWlvabSQcifcTgrUGPsaALtx849UaV5ZfAKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EOBnh8dQw28r6W0KPBw5vHS0NSBkkMQADsIb+Ve3s5U/7V/iBgkdOyaSMTt6ijwzj 6Ov39DhGrVN/xtHRUygR0xpAkRjnXxyWBY4uBB/iS+11vAe2+40UEvgD8xqgcUzd+e HM/otnXIKQTW5mBIvxY9MjH7704FN4JMwb67INriEKjmFuVF0dlyXiPKRxABvydoB4 b1H8w4EnGqE2tD/rrI2SfwQLzNCEORoKyOFeo+dTDhdcx0/aqwFc1tgMmqXbygHXo2 EVo7qW7D7BGO2ZoO34GganL2z0nMzryMQU+WdCfCGr9+UQcU4eZdUgJhCTkivgPOl/ h9e2lzRBWT6Gg== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, Matthieu CASTET , Stanislaw Gruszka , Greg Kroah-Hartman , Damien Bergamini , linux-usb@vger.kernel.org Subject: [PATCH 1/5] usb: atm: Remove snprintf() from sysfs call-backs and replace with sysfs_emit() Date: Thu, 30 Nov 2023 10:54:35 +0000 Message-ID: <20231130105459.3208986-2-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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 30 Nov 2023 02:55:29 -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 the 2 uses of snprintf() found in the sysfs .show() call-backs with the new sysfs_emit() helpers. Whist we're at it, let's replace the sprintf()s as well. For no other reason than consistency. Link: https://lwn.net/Articles/69419/ Link: https://github.com/KSPP/linux/issues/105 Cc: Matthieu CASTET Cc: Stanislaw Gruszka Cc: Greg Kroah-Hartman Cc: Damien Bergamini Cc: linux-usb@vger.kernel.org Signed-off-by: Lee Jones --- drivers/usb/atm/ueagle-atm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 5812f7ea7f902..8d5580d8d20a8 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -2252,7 +2252,7 @@ static ssize_t stat_status_show(struct device *dev, struct device_attribute *att sc = dev_to_uea(dev); if (!sc) goto out; - ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); + ret = sysfs_emit(buf, "%08x\n", sc->stats.phy.state); out: mutex_unlock(&uea_mutex); return ret; @@ -2318,19 +2318,19 @@ static ssize_t stat_human_status_show(struct device *dev, switch (modem_state) { case 0: - ret = sprintf(buf, "Modem is booting\n"); + ret = sysfs_emit(buf, "Modem is booting\n"); break; case 1: - ret = sprintf(buf, "Modem is initializing\n"); + ret = sysfs_emit(buf, "Modem is initializing\n"); break; case 2: - ret = sprintf(buf, "Modem is operational\n"); + ret = sysfs_emit(buf, "Modem is operational\n"); break; case 3: - ret = sprintf(buf, "Modem synchronization failed\n"); + ret = sysfs_emit(buf, "Modem synchronization failed\n"); break; default: - ret = sprintf(buf, "Modem state is unknown\n"); + ret = sysfs_emit(buf, "Modem state is unknown\n"); break; } out: @@ -2364,7 +2364,7 @@ static ssize_t stat_delin_show(struct device *dev, struct device_attribute *attr delin = "LOSS"; } - ret = sprintf(buf, "%s\n", delin); + ret = sysfs_emit(buf, "%s\n", delin); out: mutex_unlock(&uea_mutex); return ret; @@ -2384,7 +2384,7 @@ static ssize_t stat_##name##_show(struct device *dev, \ sc = dev_to_uea(dev); \ if (!sc) \ goto out; \ - ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \ + ret = sysfs_emit(buf, "%08x\n", sc->stats.phy.name); \ if (reset) \ sc->stats.phy.name = 0; \ out: \ -- 2.43.0.rc1.413.gea7ed67945-goog