Netdev List
 help / color / mirror / Atom feed
* question about nla_nest_cancel
@ 2011-01-27 17:08 Julia Lawall
  2011-01-27 17:21 ` Kurt Van Dijck
  2011-01-27 17:52 ` Ben Pfaff
  0 siblings, 2 replies; 5+ messages in thread
From: Julia Lawall @ 2011-01-27 17:08 UTC (permalink / raw)
  To: hadi, netdev

I find numerous occurrences of code like the following, in which nest ends 
up with the value NULL and then nla_nest_cancel is called with nest as the 
second argument.  But nla_nest_cancel just calls nlmsg_trim with the same 
second argument, and nlmsg_trim does nothing if its second argument is 
NULL.  Is there any reason to keep these calls?

thanks,
julia



static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
{
	struct tbf_sched_data *q = qdisc_priv(sch);
	struct nlattr *nest;
	struct tc_tbf_qopt opt;

	nest = nla_nest_start(skb, TCA_OPTIONS);
	if (nest == NULL)
		goto nla_put_failure;

	opt.limit = q->limit;
	opt.rate = q->R_tab->rate;
	if (q->P_tab)
		opt.peakrate = q->P_tab->rate;
	else
		memset(&opt.peakrate, 0, sizeof(opt.peakrate));
	opt.mtu = q->mtu;
	opt.buffer = q->buffer;
	NLA_PUT(skb, TCA_TBF_PARMS, sizeof(opt), &opt);

	nla_nest_end(skb, nest);
	return skb->len;

nla_put_failure:
	nla_nest_cancel(skb, nest);
	return -1;
}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-01-27 18:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-27 17:08 question about nla_nest_cancel Julia Lawall
2011-01-27 17:21 ` Kurt Van Dijck
2011-01-27 17:25   ` Julia Lawall
2011-01-27 17:52 ` Ben Pfaff
2011-01-27 18:18   ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox