linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Joe Perches <joe@perches.com>,
	Dennis Dalessandro <dennis.dalessandro@intel.com>
Cc: Doug Ledford <dledford@redhat.com>,
	Potnuri Bharat Teja <bharat@chelsio.com>,
	Mike Marciniszyn <mike.marciniszyn@intel.com>,
	"Yishai Hadas" <yishaih@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	"Christian Benvenuti" <benve@cisco.com>,
	Nelson Escobar <neescoba@cisco.com>,
	"Parvi Kaustubhi" <pkaustub@cisco.com>,
	Danil Kipnis <danil.kipnis@cloud.ionos.com>,
	Jack Wang <jinpu.wang@cloud.ionos.com>,
	Bart Van Assche <bvanassche@acm.org>,
	<linux-rdma@vger.kernel.org>
Subject: Re: [PATCH 3/4] RDMA: manual changes for sysfs_emit and neatening
Date: Fri, 30 Oct 2020 21:04:07 -0300	[thread overview]
Message-ID: <20201031000407.GS2620339@nvidia.com> (raw)
In-Reply-To: <d045c9c63b5ba9535314d9af823607d0659758c0.camel@perches.com>

On Thu, Oct 29, 2020 at 10:16:46AM -0700, Joe Perches wrote:
> On Wed, 2020-10-28 at 10:54 -0700, Joe Perches wrote:
> > On Wed, 2020-10-28 at 14:25 -0300, Jason Gunthorpe wrote:
> > > On Wed, Oct 07, 2020 at 07:36:26PM -0700, Joe Perches wrote:
> > > 
> > > > @@ -653,10 +651,7 @@ static ssize_t serial_show(struct device *device,
> > > >  		rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
> > > >  	struct qib_devdata *dd = dd_from_dev(dev);
> > > >  
> > > > 
> > > > -	buf[sizeof(dd->serial)] = '\0';
> > > > -	memcpy(buf, dd->serial, sizeof(dd->serial));
> > > > -	strcat(buf, "\n");
> > > > -	return strlen(buf);
> > > > +	return sysfs_emit(buf, "%s\n", dd->serial);
> > > >  }
> > > 
> > > This is not the same thing? dd->serial does not look null terminated,
> > > eg it is filled like this:
> > > 
> > > 		memcpy(dd->serial, ifp->if_serial, sizeof(ifp->if_serial));
> > > 
> > > From data read off the flash
> > 
> > It seems you are correct.
> > 
> > Maybe instead:
> > static ssize_t serial_show(struct device *device,
> > 			   struct device_attribute *attr, char *buf)
> > {
> > 	struct qib_ibdev *dev =
> > 		rdma_device_to_drv_device(device, struct qib_ibdev, rdi.ibdev);
> > 	struct qib_devdata *dd = dd_from_dev(dev);
> > 	const u8 *end = memchr(dd->serial, 0, ARRAY_SIZE(dd->serial));
> > 	int size = end ? end - dd->serial : ARRAY_SIZE(dd->serial);
> > 
> > 	return sysfs_emit(buf, "%*s\n", size, dd->serial);
> 
> I believe for this to actually be correct, this should be:
> 
> 	return sysfs_emit(buf, "%.*s\n", size, dd->serial);

Yes, I think so, I squished it in

Maybe Dennis can check it in the wip/jgg/for-next branch?

Thanks,
Jason

  reply	other threads:[~2020-10-31  0:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08  2:36 [PATCH-next 0/4] RDMA: sprintf to sysfs_emit conversions Joe Perches
2020-10-08  2:36 ` [PATCH 1/4] RDMA: Convert sysfs device * show functions to use sysfs_emit() Joe Perches
2020-10-09 14:07   ` Jason Gunthorpe
2020-10-08  2:36 ` [PATCH 2/4] RDMA: Convert sysfs kobject " Joe Perches
2020-10-09 14:09   ` Jason Gunthorpe
2020-10-09 16:25     ` Joe Perches
2020-10-12  5:21   ` Jinpu Wang
2020-10-08  2:36 ` [PATCH 3/4] RDMA: manual changes for sysfs_emit and neatening Joe Perches
2020-10-09 15:20   ` Jason Gunthorpe
2020-10-12  5:30   ` Jinpu Wang
2020-10-28 17:25   ` Jason Gunthorpe
2020-10-28 17:54     ` Joe Perches
2020-10-28 18:23       ` Jason Gunthorpe
2020-10-29 17:16       ` Joe Perches
2020-10-31  0:04         ` Jason Gunthorpe [this message]
2020-10-08  2:36 ` [PATCH 4/4] RDMA: Convert various random sprintf sysfs _show uses to sysfs_emit Joe Perches
2020-10-09 15:27   ` Jason Gunthorpe
2020-10-12  5:25   ` Jinpu Wang
2020-10-28 18:12   ` Jason Gunthorpe
2020-10-28 18:22     ` Joe Perches
2020-10-08  5:41 ` [PATCH-next 0/4] RDMA: sprintf to sysfs_emit conversions Leon Romanovsky
2020-10-08  5:52   ` Joe Perches
2020-10-08  7:02     ` Leon Romanovsky
2020-10-15  5:29   ` Joe Perches
2020-10-26 22:54 ` Jason Gunthorpe
2020-10-28 18:27 ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201031000407.GS2620339@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=benve@cisco.com \
    --cc=bharat@chelsio.com \
    --cc=bvanassche@acm.org \
    --cc=danil.kipnis@cloud.ionos.com \
    --cc=dennis.dalessandro@intel.com \
    --cc=dledford@redhat.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=joe@perches.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mike.marciniszyn@intel.com \
    --cc=neescoba@cisco.com \
    --cc=pkaustub@cisco.com \
    --cc=yishaih@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).