On Friday 2009-02-20 10:15, Giacomo wrote: > >Suppose we have a very little data structure - in kernel space - : > >typedef struct >{ > __u32 saddr, daddr; > __u16 sport, dport; > short int valid; >} net_quadruplet; Phew - http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/ >[case 1]: >net_quadruplet get_quad_from_skb(const struct sk_buff* skb) >{ > net_quadruplet netquad; > memset(&netquad, 0, sizeof(net_quadruplet)); > netquad.valid = 1; > ... > return netquad; >} > >Is it perfectly legal? That's a question for a C forum/channel, but yes, it is valid. >[code 2]: >Would it be more efficient > >int get_quad_from_skb(const struct sk_buff* skb, net_quadruplet* nquad) >{ > int return_value = 0; > /* modify nquad > ..... > */ > return return_value; >} > >? Depends on architecture and compiler. Usually it is said that the compiler will transparently transform the first case into variant 2. This need not always be the case however, returning an aggregate object such as a struct could also be accomplished by filling registers, where there are enough available to do so. This is all highly implementation-dependent though. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html