lkml.org 
[lkml]   [2016]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
    From
    Date
    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...



    \
     
     \ /
      Last update: 2016-01-03 03:01    [W:4.700 / U:0.048 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site