On Fri, Nov 9, 2012 at 3:40 AM, Ansis Atteka <aatt...@nicira.com> wrote:
> On Fri, Nov 9, 2012 at 3:30 AM, Jesse Gross <je...@nicira.com> wrote: > > On Thu, Nov 8, 2012 at 5:14 AM, Ansis Atteka <aatt...@nicira.com> wrote: > >> > >> diff --git a/datapath/actions.c b/datapath/actions.c > >> index 8ec692d..317aa4a 100644 > >> --- a/datapath/actions.c > >> +++ b/datapath/actions.c > >> +static void set_ipv6_addr(struct sk_buff *skb, u8 l4_proto, > >> + __be32 addr[4], const __be32 new_addr[4], > >> + bool recalculate_csum) > >> +{ > >> + if (recalculate_csum) > >> + update_ipv6_checksum(skb, l4_proto, addr, new_addr); > >> + > >> + skb_clear_rxhash(skb); > >> + memcpy(addr, new_addr, sizeof(__be32[4])); > > > > > > The sizeof(__be32[4]) seems a little overdone here - you could just use > > sizeof(addr). > My understanding is that in C/C++ arrays decay into pointers, if they > are passed as function arguments. Try: > > #include <stdio.h> > void fn(int a[4]) { > printf("%lu vs %lu vs %lu!\n", sizeof(a), sizeof(*a), sizeof(int[4])); > } > int main() { > int in[4]; > fn(in); > } > > Output is: > 8 vs 4 vs 16! > > Because sizeof(addr) would be system pointer size, but sizeof(*addr) > would be size of a single array element. You're right, sorry about that.
_______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev