lkml.org 
[lkml]   [2005]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH] net, ipv6: remove redundant NULL checks before kfree in ip6_flowlabel.c
From
In article <Pine.LNX.4.62.0503170027390.2558@dragon.hyggekrogen.localhost> (at Thu, 17 Mar 2005 00:36:35 +0100 (CET)), Jesper Juhl <juhl-lkml@dif.dk> says:

> I considered also rewriting the
> if (fl)
> fl_free(fl);
> bit as simply fl_free(fl) as well, but that if() potentially saves two
> calls to kfree() inside fl_free as well as the call to fl_free itself, so
> I guess that's worth the if().

I don't mind calling kfree twice itself (because that function is not
so performance critical), but fl_free(NULL) is out because
if fl is NULL, kfree(fl->opt) is out.

So, what do you think of checking fl inside fl_free like this?

We can even make fl_free inline and check as following:
if (fl) {
kfree(fl->opt);
kfree(fl);
}

Based on patch from Jesper Juhl <juhl-lkml@dif.dk>.

David?

Signed-off-by: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>

===== net/ipv6/ip6_flowlabel.c 1.18 vs edited =====
--- 1.18/net/ipv6/ip6_flowlabel.c 2005-01-14 13:41:06 +09:00
+++ edited/net/ipv6/ip6_flowlabel.c 2005-03-17 11:23:32 +09:00
@@ -87,7 +87,7 @@

static void fl_free(struct ip6_flowlabel *fl)
{
- if (fl->opt)
+ if (fl)
kfree(fl->opt);
kfree(fl);
}
@@ -351,8 +351,7 @@
return fl;

done:
- if (fl)
- fl_free(fl);
+ fl_free(fl);
*err_p = err;
return NULL;
}
@@ -551,10 +550,8 @@
}

done:
- if (fl)
- fl_free(fl);
- if (sfl1)
- kfree(sfl1);
+ fl_free(fl);
+ kfree(sfl1);
return err;
}

--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
-
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/

\
 
 \ /
  Last update: 2005-03-22 14:11    [W:0.031 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site