From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbcACBe0 (ORCPT ); Sat, 2 Jan 2016 20:34:26 -0500 Received: from smtprelay0037.hostedemail.com ([216.40.44.37]:36058 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751744AbcACBeV (ORCPT ); Sat, 2 Jan 2016 20:34:21 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2890:2895:3138:3139:3140:3141:3142:3352:3622:3865:3867:3872:4042:4321:5007:6261:10004:10400:10848:11026:11232:11658:11914:12048:12109:12438:12517:12519:12740:13069:13311:13357:13894:14659:21080:30001:30012:30054:30070:30080:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: aunt68_7d0da217ca432 X-Filterd-Recvd-Size: 2189 Message-ID: <1451784858.4334.12.camel@perches.com> Subject: Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations From: Joe Perches To: SF Markus Elfring , xen-devel@lists.xenproject.org, netdev@vger.kernel.org, Ian Campbell , Wei Liu Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Date: Sat, 02 Jan 2016 17:34:18 -0800 In-Reply-To: <56880DD4.2090806@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <56880DD4.2090806@users.sourceforge.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.3-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...