From patchwork Sat Jun 28 19:13:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 4113 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=216.40.44.136; helo=smtprelay.hostedemail.com; envelope-from=joe@perches.com; receiver=b.a.t.m.a.n@lists.open-mesh.org X-Greylist: delayed 371 seconds by postgrey-1.34 at open-mesh.org; Sat, 28 Jun 2014 21:19:18 CEST Received: from smtprelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by open-mesh.org (Postfix) with ESMTP id BF4DF600829 for ; Sat, 28 Jun 2014 21:19:18 +0200 (CEST) Received: from smtprelay.hostedemail.com (ff-bigip1 [10.5.19.254]) by smtpgrave08.hostedemail.com (Postfix) with ESMTP id 499EA2120B4 for ; Sat, 28 Jun 2014 19:13:07 +0000 (UTC) Received: from filter.hostedemail.com (ff-bigip1 [10.5.19.254]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 9454329DDE4; Sat, 28 Jun 2014 19:13:04 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 48, 2.914, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::::::::::, RULES_HIT:41:355:379:418:541:599:966:968:973:981:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3871:4250:4321:4385:5007:7652:8603:9592:10004:10400:10848:11026:11473:11658:11914:12043:12296:12438:12517:12519:12555:12663:12740:13069:13138:13231:13311:13357:21080, 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 X-HE-Tag: card41_71e24e681771e X-Filterd-Recvd-Size: 2660 Received: from [192.168.1.162] (pool-71-103-235-196.lsanca.fios.verizon.net [71.103.235.196]) (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA; Sat, 28 Jun 2014 19:13:02 +0000 (UTC) Message-ID: <1403982781.9064.33.camel@joe-AO725> From: Joe Perches To: Himangi Saraogi Date: Sat, 28 Jun 2014 12:13:01 -0700 In-Reply-To: <20140628183628.GA9946@himangi-Dell> References: <20140628183628.GA9946@himangi-Dell> X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 Cc: Marek Lindner , netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, linux-kernel@vger.kernel.org, julia.lawall@lip6.fr, Antonio Quartulli , "David S. Miller" Subject: Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Use kasprintf X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jun 2014 19:19:19 -0000 On Sun, 2014-06-29 at 00:06 +0530, Himangi Saraogi wrote: > kasprintf combines kmalloc and sprintf, and takes care of the size > calculation itself. Nice. A small conversion to remove unnecessary initializations, avoid calling kfree with known NULL pointers, and save a few bytes of code space woud be: --- net/batman-adv/sysfs.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index f40cb04..d6fba94 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c @@ -896,7 +896,7 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type, { int ret = -ENOMEM; struct kobject *bat_kobj; - char *uevent_env[4] = { NULL, NULL, NULL, NULL }; + char *uevent_env[3]; bat_kobj = &bat_priv->soft_iface->dev.kobj; @@ -910,22 +910,23 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type, "%s%s", BATADV_UEV_ACTION_VAR, batadv_uev_action_str[action]); if (!uevent_env[1]) - goto out; + goto out0; /* If the event is DEL, ignore the data field */ if (action != BATADV_UEV_DEL) { uevent_env[2] = kasprintf(GFP_ATOMIC, "%s%s", BATADV_UEV_DATA_VAR, data); if (!uevent_env[2]) - goto out; + goto out1; } ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env); -out: - kfree(uevent_env[0]); - kfree(uevent_env[1]); kfree(uevent_env[2]); - +out1: + kfree(uevent_env[1]); +out0: + kfree(uevent_env[0]); +out: if (ret) batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n",