[Top][All Lists]

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

Re: [PATCH] device_tree: Fix compiler error

From: Stefan Weil
Subject: Re: [PATCH] device_tree: Fix compiler error
Date: Tue, 9 Nov 2021 08:58:04 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

Am 08.11.21 um 23:43 schrieb Alistair Francis:

On Tue, Nov 9, 2021 at 6:08 AM Stefan Weil <sw@weilnetz.de> wrote:
A build with gcc (Debian 10.2.1-6) 10.2.1 20210110 fails:

../../../softmmu/device_tree.c: In function ‘qemu_fdt_add_path’:
../../../softmmu/device_tree.c:560:18: error: ‘retval’ may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
   560 |     int namelen, retval;
       |                  ^~~~~~

This is not a real error, but the compiler can be satisfied with a small change.
Why don't we just initalise retval?


retval is already set in the do ... while loop and was also set in the former while loop.

If we set it in the declaration (int retval = 0), a clever compiler might complain that we assign a value which is never used.

And changing from the while loop to the do ... while loop also avoids one compare statement, so depending on the compiler optimizations could make the code a little bit faster.


reply via email to

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