qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] migration/qemu-file: Fix maybe uninitialized on qemu_get_buf


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] migration/qemu-file: Fix maybe uninitialized on qemu_get_buffer_in_place()
Date: Thu, 28 Jan 2021 19:07:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 1/28/21 6:16 PM, Dr. David Alan Gilbert wrote:
> * Wainer dos Santos Moschetta (wainersm@redhat.com) wrote:
>> Fixed error when compiling migration/qemu-file.c with 
>> -Werror=maybe-uninitialized
>> as shown here:
>>
>> ../migration/qemu-file.c: In function 'qemu_get_buffer_in_place':
>> ../migration/qemu-file.c:604:18: error: 'src' may be used uninitialized in 
>> this function [-Werror=maybe-uninitialized]
>>   604 |             *buf = src;
>>       |             ~~~~~^~~~~
>> cc1: all warnings being treated as errors
>>
>> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
> 
> Yes, I think I had a discussion with someone about this recently but
> can't find it;

Maybe with Thomas, he reported that 2 years ago when building with -O3:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg599522.html

> the compiler is technically correct, but the only time
> it's unitialised is the case where it's result doesn't matter.
> 
> Still, to shut the compiler up:
> 
> 
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> 
>> ---
>> Passed on CI: https://gitlab.com/wainersm/qemu/-/pipelines/247801576
>>
>>  migration/qemu-file.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
>> index be21518c57..d6e03dbc0e 100644
>> --- a/migration/qemu-file.c
>> +++ b/migration/qemu-file.c
>> @@ -595,7 +595,7 @@ size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t 
>> **buf, size_t size)
>>  {
>>      if (size < IO_BUF_SIZE) {
>>          size_t res;
>> -        uint8_t *src;
>> +        uint8_t *src = NULL;
>>  
>>          res = qemu_peek_buffer(f, &src, size, 0);
>>  
>> -- 
>> 2.28.0
>>




reply via email to

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