lkml.org 
[lkml]   [2011]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] include/net/genetlink.h: Allow genlmsg_cancel to accept a NULL argument
On Tue, 1 Feb 2011, David Miller wrote:

> From: Julia Lawall <julia@diku.dk>
> Date: Fri, 28 Jan 2011 16:43:40 +0100 (CET)
>
> > nlmsg_cancel can accept NULL as its second argument, so for similarity,
> > this patch extends genlmsg_cancel to be able to accept a NULL second
> > argument as well.
> >
> > Signed-off-by: Julia Lawall <julia@diku.dk>
>
> I did a scan of all of the cases where this interface is used, and
> I cannot find a situation where this capability would even be useful.
>
> The use pattern is always:
>
> hdr = genlmsg_put(skb, ...);
> if (!hdr)
> goto out;
>
> NLA_PUT_*();
> NLA_PUT_*();
> ....
>
> return genlmsg_end(skb, hdr);
>
> nla_put_failure:
> genlmsg_cancel(skb, hdr);
> out:
> return -EWHATEVER;
>
> Always, hdr will be non-NULL.
>
> We have to allocate the header first, then put the netlink
> attributes.
>
> Looking over users of nlmsg_cancel(), the situation seems to
> match identically.
>
> Therefore, it seems to me that it makes more sense to remove
> the NULL check from nlmsg_cancel() than to add the NULL check
> to genlmsg_cancel().

I saw lots of cases that could be done like this, but were not; they had
goto nla_put_failure instead.

I will double check.

julia


\
 
 \ /
  Last update: 2011-02-02 06:55    [W:0.062 / U:0.776 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site