[PATCH 04/18] nvme: add a vendor field to struct nvme_dev

Busch, Keith keith.busch at intel.com
Wed Oct 21 12:10:55 PDT 2015

On Wed, Oct 21, 2015 at 11:58:11AM -0700, J Freyensee wrote:
> On Fri, 2015-10-16 at 07:58 +0200, Christoph Hellwig wrote:
> > -		sprintf(&inq_response[8], "%04x", to_pci_dev(dev
> > ->dev)->vendor);
> > +		sprintf(&inq_response[8], "%04x", dev->vendor);
> I'm ok with this patch, but I wanted to ask the question for my own
> benefit, what is the Linux kernel open-source practice of using
> sprintf() and string settings?  I typically try to use snprintf().

Generally yes, snprintf is preferred, though the usage in this specific
example is more similar to a memcpy. We know the buffer size and the
length being copied into it is fixed; sprintf is just convenient.

More information about the Linux-nvme mailing list