qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] net/socket: fix coverity issue


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] net/socket: fix coverity issue
Date: Mon, 6 Nov 2017 13:58:04 +0000

On 6 November 2017 at 13:48, Jens Freimann <address@hidden> wrote:
> On Mon, Nov 06, 2017 at 01:29:42PM +0000, Peter Maydell wrote:
>> Do we really need the initialization here? With the two if()
>> conditions aligned we should be properly initializing it
>> in all the cases we use it, or have I missed one?
>
>
> We don't need it. I added it not to have the same problem again if
> the code changes in the future. I think it shouldn't hurt
> because this code is only run once during initialization.

The idea is that we want the compiler to tell us if we use
this state when it hasn't been properly initialized. Zeroing
the variable means that the compiler won't warn, but we'll
use zero data, which is unlikely to be the right thing.
Occasionally we have to resort to zeroing variables if the
compiler can't figure out that we always initialize it if
we use it (older gcc versions sometimes produce spurious
maybe-used-uninitialized warnings), but we only do that when
we have to.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]