Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1300165

Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
Date 2016-01-03 02:40 +0100
Message-ID <qMFOi-7gt-5@gated-at.bofh.it> (permalink)
References <qEuGl-43C-5@gated-at.bofh.it> <qMyD7-2In-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, 2016-01-02 at 18:50 +0100, SF Markus Elfring wrote:
> A few update suggestions were taken into account
> from static source code analysis.

While static analysis can be useful, I don't think these
specific conversions are generally useful.

Perhaps it would be more useful to convert the string
duplication or snprintf logic to kstrdup/kasprintf

This:

	if (num_queues == 1) {
		xspath = kzalloc(strlen(dev->otherend) + 1, GFP_KERNEL);
		if (!xspath) {
			xenbus_dev_fatal(dev, -ENOMEM,
					 "reading ring references");
			return -ENOMEM;
		}
		strcpy(xspath, dev->otherend);
	} else {
		xspathsize = strlen(dev->otherend) + xenstore_path_ext_size;
		xspath = kzalloc(xspathsize, GFP_KERNEL);
		if (!xspath) {
			xenbus_dev_fatal(dev, -ENOMEM,
					 "reading ring references");
			return -ENOMEM;
		}
		snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend,
			 queue->id);
	}

could be simplified to something like:

	if (num_queues == 1)
		xspath = kstrdup(dev->otherend, GFP_KERNEL);
	else
		xspath = kasprintf(GFP_KERNEL, "%s/queue-%u",
				   dev->otherend, queue->id);
	if (!xspath)
		etc...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/5] xen-netback: Fine-tuning for three function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-02 19:00 +0100
  [PATCH 2/5] xen-netback: Delete an unnecessary goto statement in  connect_rings() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-02 19:00 +0100
  [PATCH 5/5] xen-netback: Delete an unnecessary variable  initialisation in xen_register_watchers() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-01-02 19:10 +0100
  Re: [PATCH 0/5] xen-netback: Fine-tuning for three function  implementations Joe Perches <joe@perches.com> - 2016-01-03 02:40 +0100
  Re: [PATCH 0/5] xen-netback: Fine-tuning for three function  implementations Dan Carpenter <dan.carpenter@oracle.com> - 2016-01-04 10:50 +0100
  Re: [PATCH 0/5] xen-netback: Fine-tuning for three function  implementations Wei Liu <wei.liu2@citrix.com> - 2016-01-04 12:10 +0100

csiph-web