Thomas Huth, on Wed 10 Feb 2016 11:47:05 +0100, wrote: > > + ip = mtod(m, struct ip *); > > + ip6 = mtod(m, struct ip6 *); > > + save_ip = *ip; > > + save_ip6 = *ip6; > > Could you do the "save_ip = *ip" within the "case AF_INET" below, and > the "save_ip6 = *ip6" within the case AF_INET6 ? That would avoid to > copy bytes that are not required.
The issue is that when save_ip is used later on in another switch/case, the compiler will warn that save_ip may be used uninitialized, because the compiler is not smart enough to realize that the two codes are under the same conditions. It seems to happen that my current version of gcc doesn't warn about save_ip, but it does warn about ip if I moved that too for instance. So we can move the assignment indeed, but there will probably be some compilers which will emit a warning here, I don't know what we prefer. Samuel