Re: [PATCH] miLineArc(): initialize edge1, edge2

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

 



> 
> When compiling spice-common with meson/ninja under "release" mode, I get
> the following compiler warnings:
> 
>     ../subprojects/spice-common/common/lines.c: In function ‘miLineArc’:
>     ../subprojects/spice-common/common/lines.c:2167:17: error: ‘edge2.dx’ may
>     be used uninitialized in this function [-Werror=maybe-uninitialized]
>              edge->e += edge->dx; \
>                      ^~
>     ../subprojects/spice-common/common/lines.c:2426:24: note: ‘edge2.dx’ was
>     declared here
>          PolyEdgeRec edge1, edge2;
>                             ^~~~~
>     ../subprojects/spice-common/common/lines.c:2167:17: error: ‘edge2.e’ may
>     be used uninitialized in this function [-Werror=maybe-uninitialized]
>              edge->e += edge->dx; \
>                      ^~
>     ../subprojects/spice-common/common/lines.c:2426:24: note: ‘edge2.e’ was
>     declared here
>          PolyEdgeRec edge1, edge2;
>                             ^~~~~
>     ../subprojects/spice-common/common/lines.c:2170:21: error: ‘edge2.signdx’
>     may be used uninitialized in this function [-Werror=maybe-uninitialized]
>                  edge->x += edge->signdx; \
>                          ^~
>     ../subprojects/spice-common/common/lines.c:2426:24: note: ‘edge2.signdx’
>     was declared here
>          PolyEdgeRec edge1, edge2;
>                             ^~~~~
>     ../subprojects/spice-common/common/lines.c:2166:17: error: ‘edge2.stepx’
>     may be used uninitialized in this function [-Werror=maybe-uninitialized]
>              edge->x += edge->stepx; \
>                      ^~
>     ../subprojects/spice-common/common/lines.c:2426:24: note: ‘edge2.stepx’
>     was declared here
>          PolyEdgeRec edge1, edge2;
>                             ^~~~~
>     ../subprojects/spice-common/common/lines.c:2167:17: error: ‘edge1.dx’ may
>     be used uninitialized in this function [-Werror=maybe-uninitialized]
>              edge->e += edge->dx; \
>                      ^~
>     ../subprojects/spice-common/common/lines.c:2426:17: note: ‘edge1.dx’ was
>     declared here
>          PolyEdgeRec edge1, edge2;
>                      ^~~~~
>     ../subprojects/spice-common/common/lines.c:2167:17: error: ‘edge1.e’ may
>     be used uninitialized in this function [-Werror=maybe-uninitialized]
>              edge->e += edge->dx; \
>                      ^~
>     ../subprojects/spice-common/common/lines.c:2426:17: note: ‘edge1.e’ was
>     declared here
>          PolyEdgeRec edge1, edge2;
>                      ^~~~~
>     ../subprojects/spice-common/common/lines.c:2170:21: error: ‘edge1.signdx’
>     may be used uninitialized in this function [-Werror=maybe-uninitialized]
>                  edge->x += edge->signdx; \
>                          ^~
>     ../subprojects/spice-common/common/lines.c:2426:17: note: ‘edge1.signdx’
>     was declared here
>          PolyEdgeRec edge1, edge2;
>                      ^~~~~
>     ../subprojects/spice-common/common/lines.c:2166:17: error: ‘edge1.stepx’
>     may be used uninitialized in this function [-Werror=maybe-uninitialized]
>              edge->x += edge->stepx; \
>                      ^~
>     ../subprojects/spice-common/common/lines.c:2426:17: note: ‘edge1.stepx’
>     was declared here
>          PolyEdgeRec edge1, edge2;
>                      ^~~~~
>     cc1: all warnings being treated as errors
> 
> Initializing these structures to zero silences the warnings.

Can you remove some errors/warning and keep only the top of them ?

> ---
>  common/lines.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/lines.c b/common/lines.c
> index e5097c4..7d30a03 100644
> --- a/common/lines.c
> +++ b/common/lines.c
> @@ -2423,7 +2423,7 @@ miLineArc (GCPtr pGC,
>      int xorgi = 0, yorgi = 0;
>      Spans spanRec;
>      int n;
> -    PolyEdgeRec edge1, edge2;
> +    PolyEdgeRec edge1 = {0}, edge2 = {0};
>      int edgey1, edgey2;
>      Boolean edgeleft1, edgeleft2;
>  

Looking at the code I realized this came from Xorg source.
You can find an updated mywideline.c on Internet.
One of the change is the above (thousands of other are mostly syntax,
didn't find other issues but file was imported on git on 2003),
as

   PolyEdgeRec edge1 = { 0 }, edge2 = { 0 };

could you respect same spacing so a future diff will be easier to
do?

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]