[PATCH 1/4] block.c: fix compilation error on possible unitialized variable

Cleber Rosa posted 4 patches 4 years, 8 months ago
Maintainers: Eduardo Habkost <ehabkost@redhat.com>, Cleber Rosa <crosa@redhat.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, "Alex Bennée" <alex.bennee@linaro.org>, Wainer dos Santos Moschetta <wainersm@redhat.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Thomas Huth <thuth@redhat.com>, Max Reitz <mreitz@redhat.com>, John Snow <jsnow@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Willian Rampazzo <willianr@redhat.com>
There is a newer version of this series
[PATCH 1/4] block.c: fix compilation error on possible unitialized variable
Posted by Cleber Rosa 4 years, 8 months ago
GCC from CentOS Stream 8 is erroring out on a possibily unitialized
varible.

Full version info for the compiler used:

 gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-1)

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block.c b/block.c
index 3f456892d0..08f29e6b65 100644
--- a/block.c
+++ b/block.c
@@ -4866,7 +4866,7 @@ static int bdrv_replace_node_common(BlockDriverState *from,
     Transaction *tran = tran_new();
     g_autoptr(GHashTable) found = NULL;
     g_autoptr(GSList) refresh_list = NULL;
-    BlockDriverState *to_cow_parent;
+    BlockDriverState *to_cow_parent = NULL;
     int ret;
 
     if (detach_subchain) {
-- 
2.25.4


Re: [PATCH 1/4] block.c: fix compilation error on possible unitialized variable
Posted by Thomas Huth 4 years, 8 months ago
On 08/06/2021 16.09, Cleber Rosa wrote:
> GCC from CentOS Stream 8 is erroring out on a possibily unitialized
> varible.
> 
> Full version info for the compiler used:
> 
>   gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-1)
> 
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
>   block.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index 3f456892d0..08f29e6b65 100644
> --- a/block.c
> +++ b/block.c
> @@ -4866,7 +4866,7 @@ static int bdrv_replace_node_common(BlockDriverState *from,
>       Transaction *tran = tran_new();
>       g_autoptr(GHashTable) found = NULL;
>       g_autoptr(GSList) refresh_list = NULL;
> -    BlockDriverState *to_cow_parent;
> +    BlockDriverState *to_cow_parent = NULL;
>       int ret;

Already reported here:

  https://lists.gnu.org/archive/html/qemu-devel/2021-05/msg01229.html

  Thomas