[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv7 7/9] slirp: Handle IPv6 in TCP functions
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] [PATCHv7 7/9] slirp: Handle IPv6 in TCP functions |
Date: |
Wed, 10 Feb 2016 13:41:59 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 10.02.2016 13:30, Samuel Thibault wrote:
> 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.
If current compilers only complain about the "ip = ..." statement, then
I'd suggest to give it a try to only move the "save_ip = ..." statements
into the switch cases (I think it's worth a try since this is the more
expensive operation). If that causes trouble later, we can still move
the statements back (or maybe fix the warnings by other means).
Thomas
- Re: [Qemu-devel] [PATCHv7 6/9] slirp: Reindent after refactoring, (continued)
[Qemu-devel] [PATCHv7 8/9] slirp: Adding IPv6 address for DNS relay, Samuel Thibault, 2016/02/08
[Qemu-devel] [PATCHv7 7/9] slirp: Handle IPv6 in TCP functions, Samuel Thibault, 2016/02/08
[Qemu-devel] [PATCHv7 5/9] slirp: Generalizing and neutralizing various TCP functions before adding IPv6 stuff, Samuel Thibault, 2016/02/08
[Qemu-devel] [PATCHv7 9/9] qapi-schema, qemu-options & slirp: Adding Qemu options for IPv6 addresses, Samuel Thibault, 2016/02/08
[Qemu-devel] [PATCHv7 3/9] slirp: Adding IPv6 UDP support, Samuel Thibault, 2016/02/08