[Mesa-dev] [PATCH 1/3] freedreno/a2xx: Fix sign compare warnings

Francesco Ansanelli francians at gmail.com
Fri Jul 29 05:55:31 UTC 2016


Before my patch, gcc warned about:

src/gallium/drivers/freedreno/a2xx/fd2_screen.c:64:30: warning: comparison
between signed and unsigned integer expressions [-Wsign-compare]

The change suggested:

          (fd2_pipe2surface(format) != (enum a2xx_sq_surfaceformat)~0)) {

makes both compiler happy.
Cheers,
Francesco

2016-07-29 2:20 GMT+02:00 Rob Herring <robh at kernel.org>:

> On Thu, Jul 28, 2016 at 6:55 PM, Rob Clark <robdclark at gmail.com> wrote:
> > On Thu, Jul 28, 2016 at 6:36 PM, Rob Herring <robh at kernel.org> wrote:
> >> On Thu, Jun 30, 2016 at 12:16 PM, Francesco Ansanelli
> >> <francians at gmail.com> wrote:
> >>> ---
> >>>  src/gallium/drivers/freedreno/a2xx/fd2_screen.c |    8 ++++----
> >>>  1 file changed, 4 insertions(+), 4 deletions(-)
> >>>
> >>> diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c
> b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c
> >>> index c2baa6f..fe4849b 100644
> >>> --- a/src/gallium/drivers/freedreno/a2xx/fd2_screen.c
> >>> +++ b/src/gallium/drivers/freedreno/a2xx/fd2_screen.c
> >>> @@ -61,7 +61,7 @@ fd2_screen_is_format_supported(struct pipe_screen
> *pscreen,
> >>>
> >>>         if ((usage & (PIPE_BIND_SAMPLER_VIEW |
> >>>                                 PIPE_BIND_VERTEX_BUFFER)) &&
> >>> -                       (fd2_pipe2surface(format) != ~0)) {
> >>> +                       (fd2_pipe2surface(format) != ~0u)) {
> >>
> >> FYI, all these still warn with LLVM, but now the warning is about
> >> being out of range:
> >>
> >> external/mesa3d/src/gallium/drivers/freedreno/a2xx/fd2_screen.c:64:30:
> >> warning: comparison of constant 4294967295 with expression of type
> >> 'enum a2xx_sq_surfaceformat' is always true
> >> [-Wtautological-constant-out-of-range-compare]
> >>                         (fd2_pipe2surface(format) != ~0u)) {
> >>                          ~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~
> >
> > bleh.. I guess it depends on whether enums are signed or unsigned?
> >
> > maybe (enum a2xx_sq_surfaceformat)~0 then?
>
> Or add the error value to the enums.
>
> Rob
>
> P.S. This is why I hate enums.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160729/8ab55deb/attachment.html>


More information about the mesa-dev mailing list