Re: [PATCH v3] tests: Fix compilation error

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

 



> 
> Fix compilation error due to -Werror=maybe-uninitialized:
> 
>   CC       test-display-base.o
> test-display-base.c: In function 'do_wakeup':
> test-display-base.c:579:13: error: 'update' may be used uninitialized...
>              push_command(&update->ext);
> 
> Signed-off-by: Snir Sheriber <ssheribe@xxxxxxxxxx>
> ---
>  server/tests/test-display-base.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/server/tests/test-display-base.c
> b/server/tests/test-display-base.c
> index 8167df5..42ebd35 100644
> --- a/server/tests/test-display-base.c
> +++ b/server/tests/test-display-base.c
> @@ -574,6 +574,7 @@ static void produce_command(Test *test)
>                          command->solid.bbox, command->solid.color);
>                  break;
>              default: /* Just to shut up GCC warning (-Wswitch) */
> +                    g_assert_not_reached(); /* Just to shut up GCC warning
> (-Wmaybe-uninitialized) */
>                  break;
>              }
>              push_command(&update->ext);

If works for the -DAUTOMATED_TESTS code is fine.
However IMO the comments need some work.
Now "Just to shut up GCC warning (-Wswitch)" does not apply anymore as
some code is run for the default case.
About "Just to shut up GCC warning (-Wmaybe-uninitialized)" it would be
true if the line you added just make gcc ignore the warning but the code
you added change the flow of the program which now terminates on
unhandled cases, so perhaps a


                        command->solid.bbox, command->solid.color);
                break;
            default:
                /* terminate on unhandled cases */
                g_assert_not_reached();
                break;
            }
            push_command(&update->ext);


would do (not sure why my spell checker complaints about "unhandled").

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]