Message ID | 20240116045151.3940401-13-lizhijian@fujitsu.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-26973-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp52783dye; Mon, 15 Jan 2024 20:58:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwpYu5nJoVlseNoZ9QZBJKvgWP0i+ljCBSOFEK1Q47jgXmmW+DOsfADeiNqVI13vfKFxXs X-Received: by 2002:a17:902:d485:b0:1d4:dddc:d38d with SMTP id c5-20020a170902d48500b001d4dddcd38dmr9184848plg.57.1705381136392; Mon, 15 Jan 2024 20:58:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705381136; cv=none; d=google.com; s=arc-20160816; b=ZFWAfUMljQkeJTB1shLv154iKLSl8mhpgCsnqlMalHZXesNdUQXdnL71iIXE2uoZKR gTjBw0TlM/WbrYxGooPxxAZWMb+H0jOEdvepiwdKk7K9U4HPHtKBKKfvARXqxzSBGoqu TdPooYVh7gtY14jGi/h5IygntrTv68i4v7U3fOcEpv+BkUc7EAHihvTkMp/axMNEH+KU pQi+MTDPhJXDJxrfbBHnlyGgj/Zf5XW+nr0v50BcRtFbDD7RUeVK/Ts/ki6U7CkqH5Kf v+H53v/oY95vl/5aem6M/2KE23SUNZ266Vxlyqg5xR6VeMCqWv0s4HPxF7tVH5+15R4V 4P1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=f5d10gYOx01V+DnvVeJmr1QOu1LZ89kcx4BtFBd12NA=; fh=YRusqflTXdqpeSb07c8sbCIGNGU3KAGKNQbQpKjHpUA=; b=k5P/2u6I48uRrukxOOhWg3k95UwdArtc9APrKc194q2S8a5SlI3P0cSJZLqhWRiGac W4sVAHDvJjepyzS0Gfj2N6fiUAlRYVmiQB9AExfFdZUQT3LUpPe5d1YSueKcjf1kgl8j CPJpHFwDDKIh4RSY493N1aPHI8yDykD4aeyOlb0QFRn9T2R/YD4VTQJilaFhQzREzddc 9471xG0YdZLnoAIYEVob0/pGzHKtuUB7IFzxVgLsBVZznkCac3TBBDqK79lxTNhag3ci pNuLxVidB1MrA7D+/C8LhFX3rI/7dcY03Wiz8zgF1NJB0zqETjoghni1Jp13YA6gtB0n WvLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26973-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z6-20020a170902d54600b001d4dff2c4desi10895349plf.24.2024.01.15.20.58.56 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 20:58:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26973-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26973-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fujitsu.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 98218B23213 for <ouuuleilei@gmail.com>; Tue, 16 Jan 2024 04:57:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B6EB1BC36; Tue, 16 Jan 2024 04:52:33 +0000 (UTC) Received: from esa7.hc1455-7.c3s2.iphmx.com (esa7.hc1455-7.c3s2.iphmx.com [139.138.61.252]) (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 68ADF11184; Tue, 16 Jan 2024 04:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com X-IronPort-AV: E=McAfee;i="6600,9927,10954"; a="125018769" X-IronPort-AV: E=Sophos;i="6.04,198,1695654000"; d="scan'208";a="125018769" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa7.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 13:52:21 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 6865BD6186; Tue, 16 Jan 2024 13:52:19 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 9E067E399D; Tue, 16 Jan 2024 13:52:18 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 3CAFC6B4C9; Tue, 16 Jan 2024 13:52:18 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by edo.cn.fujitsu.com (Postfix) with ESMTP id C83DE1A0160; Tue, 16 Jan 2024 12:52:17 +0800 (CST) From: Li Zhijian <lizhijian@fujitsu.com> To: linux-kernel@vger.kernel.org Cc: Li Zhijian <lizhijian@fujitsu.com>, Richard Cochran <richardcochran@gmail.com>, netdev@vger.kernel.org Subject: [PATCH 15/42] drivers/ptp: Convert snprintf to sysfs_emit Date: Tue, 16 Jan 2024 12:51:24 +0800 Message-Id: <20240116045151.3940401-13-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240116045151.3940401-1-lizhijian@fujitsu.com> References: <20240116041129.3937800-1-lizhijian@fujitsu.com> <20240116045151.3940401-1-lizhijian@fujitsu.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28122.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28122.005 X-TMASE-Result: 10--8.370000-10.000000 X-TMASE-MatchedRID: 6SYb29c3rTQ4ibokZ3+Q0CoiRKlBVkYIBXngI6jFvpfvd49YGReckE1N J2MN+nPkgxCMf8A0YpR5sRK06wHV4TBF7stuNMMxTuctSpiuWyUUi4Ehat05499RlPzeVuQQrI7 SkweN/esJ//Y+eUvH+c4WYLmQfXYmpoPHQXywp1dv+ggm5QAi4X0tCKdnhB58I/9UW5M5dRM+8F JNGdxYq46HM5rqDwqtcqB4bMvgKHUVNZz2PtKgH4DCmzb1E89ZCX01fDM/ueYwzO0EhsSbLA== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788221730139891265 X-GMAIL-MSGID: 1788221730139891265 |
Series |
[01/42] coccinelle: device_attr_show.cocci: update description and warning message
|
|
Commit Message
Zhijian Li (Fujitsu)
Jan. 16, 2024, 4:51 a.m. UTC
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. coccinelle complains that there are still a couple of functions that use snprintf(). Convert them to sysfs_emit(). > ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit No functional change intended CC: Richard Cochran <richardcochran@gmail.com> CC: netdev@vger.kernel.org Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> --- drivers/ptp/ptp_sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Comments
On Tue, 16 Jan, 2024 12:51:24 +0800 Li Zhijian <lizhijian@fujitsu.com> wrote: > Per filesystems/sysfs.rst, show() should only use sysfs_emit() > or sysfs_emit_at() when formatting the value to be returned to user space. > > coccinelle complains that there are still a couple of functions that use > snprintf(). Convert them to sysfs_emit(). > >> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit > > No functional change intended > > CC: Richard Cochran <richardcochran@gmail.com> > CC: netdev@vger.kernel.org > Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> > --- > drivers/ptp/ptp_sysfs.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c > index f7a499a1bd39..49737ed6ef5f 100644 > --- a/drivers/ptp/ptp_sysfs.c > +++ b/drivers/ptp/ptp_sysfs.c > @@ -24,8 +24,7 @@ static ssize_t max_phase_adjustment_show(struct device *dev, > { > struct ptp_clock *ptp = dev_get_drvdata(dev); > > - return snprintf(page, PAGE_SIZE - 1, "%d\n", > - ptp->info->getmaxphase(ptp->info)); > + return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info)); > } > static DEVICE_ATTR_RO(max_phase_adjustment); I authored the lines that are being changed here, so figured I should provide my review. Doesn't PTP_SHOW_INT in the same file also use snprintf in the same manner and should be changed to sysfs_emit? -- Thanks, Rahul Rameshbabu
On 16/01/2024 13:01, Rahul Rameshbabu wrote: > On Tue, 16 Jan, 2024 12:51:24 +0800 Li Zhijian <lizhijian@fujitsu.com> wrote: >> Per filesystems/sysfs.rst, show() should only use sysfs_emit() >> or sysfs_emit_at() when formatting the value to be returned to user space. >> >> coccinelle complains that there are still a couple of functions that use >> snprintf(). Convert them to sysfs_emit(). >> >>> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit >> >> No functional change intended >> >> CC: Richard Cochran <richardcochran@gmail.com> >> CC: netdev@vger.kernel.org >> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com> >> --- >> drivers/ptp/ptp_sysfs.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c >> index f7a499a1bd39..49737ed6ef5f 100644 >> --- a/drivers/ptp/ptp_sysfs.c >> +++ b/drivers/ptp/ptp_sysfs.c >> @@ -24,8 +24,7 @@ static ssize_t max_phase_adjustment_show(struct device *dev, >> { >> struct ptp_clock *ptp = dev_get_drvdata(dev); >> >> - return snprintf(page, PAGE_SIZE - 1, "%d\n", >> - ptp->info->getmaxphase(ptp->info)); >> + return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info)); >> } >> static DEVICE_ATTR_RO(max_phase_adjustment); > > I authored the lines that are being changed here, so figured I should > provide my review. Doesn't PTP_SHOW_INT in the same file also use > snprintf in the same manner and should be changed to sysfs_emit? Thanks for you review. Yes, i think so, beside PTP_SHOW_INT, there are 3 other places not detected by coccinelle should be fixed. I will update it in V2. $ grep snprintf drivers/ptp/ptp_sysfs.c return snprintf(page, PAGE_SIZE-1, "%d\n", ptp->info->var); \ cnt = snprintf(page, PAGE_SIZE, "%u %lld %u\n", size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->n_vclocks); size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->max_vclocks); Thanks Zhijian > > -- > Thanks, > > Rahul Rameshbabu
On Tue, 16 Jan 2024 12:51:24 +0800 Li Zhijian wrote: > Per filesystems/sysfs.rst, show() should only use sysfs_emit() > or sysfs_emit_at() when formatting the value to be returned to user space. > > coccinelle complains that there are still a couple of functions that use > snprintf(). Convert them to sysfs_emit(). > > > ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit If the patches don't depend on each other please post them separately. Series should only be used if there are dependencies and the same maintainer is expected to apply all patches. The ptp change should be reposted after the merge window, we don't take cleanups during the merge window.
Jakub, On 16/01/2024 23:33, Jakub Kicinski wrote: > On Tue, 16 Jan 2024 12:51:24 +0800 Li Zhijian wrote: >> Per filesystems/sysfs.rst, show() should only use sysfs_emit() >> or sysfs_emit_at() when formatting the value to be returned to user space. >> >> coccinelle complains that there are still a couple of functions that use >> snprintf(). Convert them to sysfs_emit(). >> >>> ./drivers/ptp/ptp_sysfs.c:27:8-16: WARNING: please use sysfs_emit > > If the patches don't depend on each other please post them separately. > Series should only be used if there are dependencies and the same > maintainer is expected to apply all patches> > The ptp change should be reposted after the merge window, we don't take > cleanups during the merge window. Understood. i will split them per subsystem/maintainer and repost them separately after the merge window. Thanks Zhijian (Grouping them into the same set helped us have an overview of this warning.)
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c index f7a499a1bd39..49737ed6ef5f 100644 --- a/drivers/ptp/ptp_sysfs.c +++ b/drivers/ptp/ptp_sysfs.c @@ -24,8 +24,7 @@ static ssize_t max_phase_adjustment_show(struct device *dev, { struct ptp_clock *ptp = dev_get_drvdata(dev); - return snprintf(page, PAGE_SIZE - 1, "%d\n", - ptp->info->getmaxphase(ptp->info)); + return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info)); } static DEVICE_ATTR_RO(max_phase_adjustment);