From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtprelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) (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 16BAA2C80 for ; Sun, 17 Oct 2021 07:39:00 +0000 (UTC) Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave05.hostedemail.com (Postfix) with ESMTP id EA50E1801A83C for ; Sat, 16 Oct 2021 15:13:12 +0000 (UTC) Received: from omf14.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id E02D01018D5AF; Sat, 16 Oct 2021 15:13:05 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf14.hostedemail.com (Postfix) with ESMTPA id 2F15D268E46; Sat, 16 Oct 2021 15:13:04 +0000 (UTC) Message-ID: <400d3fe720e336d5dba6e9b95c75baadf22a6a58.camel@perches.com> Subject: Re: [PATCH 3/3] bus: mhi: replace snprintf in show functions with sysfs_emit From: Joe Perches To: Greg KH , Linus Torvalds Cc: Manivannan Sadhasivam , hemantk@codeaurora.org, bbhatt@codeaurora.org, loic.poulain@linaro.org, wangqing@vivo.com, mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Date: Sat, 16 Oct 2021 08:13:03 -0700 In-Reply-To: References: <20211016065734.28802-1-manivannan.sadhasivam@linaro.org> <20211016065734.28802-4-manivannan.sadhasivam@linaro.org> <6ddc01b24b1c72f7e92174a037043b5cfffa3431.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.4-1 Precedence: bulk X-Mailing-List: mhi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.89 X-Stat-Signature: 9uhebz6odwgnyap79pzfzw94x7mhn8a1 X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: 2F15D268E46 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/lF+a3yNodCoxdxWj3to9HFbSG6J4S2Fs= X-HE-Tag: 1634397184-28310 On Sat, 2021-10-16 at 17:07 +0200, Greg KH wrote: > On Sat, Oct 16, 2021 at 03:24:17AM -0700, Joe Perches wrote: > > On Sat, 2021-10-16 at 09:37 +0200, Greg KH wrote: > > > On Sat, Oct 16, 2021 at 12:27:34PM +0530, Manivannan Sadhasivam wrote: > > > > From: Qing Wang > > > > coccicheck complains about the use of snprintf() in sysfs show functions. > > [] > > > > diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c > > [] > > > > @@ -94,7 +94,7 @@ static ssize_t serial_number_show(struct device *dev, > > > > struct mhi_device *mhi_dev = to_mhi_device(dev); > > > > struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; > > > > > > > > - return snprintf(buf, PAGE_SIZE, "Serial Number: %u\n", > > > > + return sysfs_emit(buf, "Serial Number: %u\n", > > > > mhi_cntrl->serial_number); > > > > > > The text "Serial Number: " should not be in here, right? It's obvious > > > this is a serial number, that's what the documentation and file name > > > says. Userspace should not have to parse sysfs files. > > > > sysfs is ABI right? Parsing or not, it's what's already there. > > If no tools rely on this, and we can change it, we should at least try. > > We can not change ABI if something breaks. If nothing relies on it, > then it is fine to do so. That's a quite bad way to think of an ABI. All that does is tempt fate as you don't know if something already uses it until someone complains and by that time something else may be written to depend on the new behavior.