[Mesa-dev] [PATCH] gallium, utils: Fix trivial sign compare warnings

Jose Fonseca jfonseca at vmware.com
Tue May 3 12:50:33 UTC 2016


On 02/05/16 06:15, Jan Vesely wrote:
> From: Jan Vesely <jan.vesely at rutgers.edu>
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>   src/gallium/auxiliary/util/u_blitter.c        | 10 +++++-----
>   src/gallium/auxiliary/util/u_cpu_detect.c     |  2 +-
>   src/gallium/auxiliary/util/u_format.c         |  4 ++--
>   src/gallium/auxiliary/util/u_framebuffer.c    |  2 +-
>   src/gallium/auxiliary/util/u_linear.c         |  8 ++++----
>   src/gallium/auxiliary/util/u_simple_shaders.c |  4 ++--
>   src/gallium/auxiliary/util/u_tests.c          |  4 ++--
>   src/gallium/auxiliary/util/u_vbuf.c           |  8 ++++----
>   8 files changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
> index 958d2ab..2a44d6b 100644
> --- a/src/gallium/auxiliary/util/u_blitter.c
> +++ b/src/gallium/auxiliary/util/u_blitter.c
> @@ -422,7 +422,7 @@ void util_blitter_destroy(struct blitter_context *blitter)
>   {
>      struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
>      struct pipe_context *pipe = blitter->pipe;
> -   int i, j, f;
> +   unsigned i, j, f;
>
>      for (i = 0; i <= PIPE_MASK_RGBA; i++)
>         for (j = 0; j < 2; j++)
> @@ -551,7 +551,7 @@ static void blitter_check_saved_vertex_states(struct blitter_context_priv *ctx)
>      assert(!ctx->has_geometry_shader || ctx->base.saved_gs != INVALID_PTR);
>      assert(!ctx->has_tessellation || ctx->base.saved_tcs != INVALID_PTR);
>      assert(!ctx->has_tessellation || ctx->base.saved_tes != INVALID_PTR);
> -   assert(!ctx->has_stream_out || ctx->base.saved_num_so_targets != ~0);
> +   assert(!ctx->has_stream_out || ctx->base.saved_num_so_targets != ~0u);
>      assert(ctx->base.saved_rs_state != INVALID_PTR);
>   }
>
> @@ -644,7 +644,7 @@ static void blitter_restore_fragment_states(struct blitter_context_priv *ctx)
>
>   static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx)
>   {
> -   assert(ctx->base.saved_fb_state.nr_cbufs != ~0);
> +   assert(ctx->base.saved_fb_state.nr_cbufs != ~0u);
>   }
>
>   static void blitter_disable_render_cond(struct blitter_context_priv *ctx)
> @@ -678,8 +678,8 @@ static void blitter_restore_fb_state(struct blitter_context_priv *ctx)
>
>   static void blitter_check_saved_textures(struct blitter_context_priv *ctx)
>   {
> -   assert(ctx->base.saved_num_sampler_states != ~0);
> -   assert(ctx->base.saved_num_sampler_views != ~0);
> +   assert(ctx->base.saved_num_sampler_states != ~0u);
> +   assert(ctx->base.saved_num_sampler_views != ~0u);
>   }
>
>   static void blitter_restore_textures(struct blitter_context_priv *ctx)
> diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
> index 10b0902..aa3c30a 100644
> --- a/src/gallium/auxiliary/util/u_cpu_detect.c
> +++ b/src/gallium/auxiliary/util/u_cpu_detect.c
> @@ -313,7 +313,7 @@ util_cpu_detect(void)
>      }
>   #elif defined(PIPE_OS_UNIX) && defined(_SC_NPROCESSORS_ONLN)
>      util_cpu_caps.nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> -   if (util_cpu_caps.nr_cpus == -1)
> +   if (util_cpu_caps.nr_cpus == ~0u)
>         util_cpu_caps.nr_cpus = 1;
>   #elif defined(PIPE_OS_BSD)
>      {
> diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
> index 1be5c97..34df01d 100644
> --- a/src/gallium/auxiliary/util/u_format.c
> +++ b/src/gallium/auxiliary/util/u_format.c
> @@ -45,7 +45,7 @@ boolean
>   util_format_is_float(enum pipe_format format)
>   {
>      const struct util_format_description *desc = util_format_description(format);
> -   unsigned i;
> +   int i;
>
>      assert(desc);
>      if (!desc) {
> @@ -53,7 +53,7 @@ util_format_is_float(enum pipe_format format)
>      }
>
>      i = util_format_get_first_non_void_channel(format);
> -   if (i == -1) {
> +   if (i < 0) {
>         return FALSE;
>      }
>
> diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c
> index deaa058..f2108a1 100644
> --- a/src/gallium/auxiliary/util/u_framebuffer.c
> +++ b/src/gallium/auxiliary/util/u_framebuffer.c
> @@ -147,7 +147,7 @@ util_framebuffer_min_size(const struct pipe_framebuffer_state *fb,
>         h = MIN2(h, fb->zsbuf->height);
>      }
>
> -   if (w == ~0) {
> +   if (w == ~0u) {
>         *width = 0;
>         *height = 0;
>         return FALSE;
> diff --git a/src/gallium/auxiliary/util/u_linear.c b/src/gallium/auxiliary/util/u_linear.c
> index f1aef21..eed7df9 100644
> --- a/src/gallium/auxiliary/util/u_linear.c
> +++ b/src/gallium/auxiliary/util/u_linear.c
> @@ -37,14 +37,14 @@ void
>   pipe_linear_to_tile(size_t src_stride, const void *src_ptr,
>   		    struct pipe_tile_info *t, void *dst_ptr)
>   {
> -   int x, y, z;
> +   unsigned x, y, z;
>      char *ptr;
>      size_t bytes = t->cols * t->block.size;
>      char *dst_ptr2 = (char *) dst_ptr;
>
>      assert(pipe_linear_check_tile(t));
>
> -   /* lets write lineary to the tiled buffer */
> +   /* lets write linearly to the tiled buffer */
>      for (y = 0; y < t->tiles_y; y++) {
>         for (x = 0; x < t->tiles_x; x++) {
>   	 /* this inner loop could be replace with SSE magic */
> @@ -61,12 +61,12 @@ pipe_linear_to_tile(size_t src_stride, const void *src_ptr,
>   void pipe_linear_from_tile(struct pipe_tile_info *t, const void *src_ptr,
>   			   size_t dst_stride, void *dst_ptr)
>   {
> -   int x, y, z;
> +   unsigned x, y, z;
>      char *ptr;
>      size_t bytes = t->cols * t->block.size;
>      const char *src_ptr2 = (const char *) src_ptr;
>
> -   /* lets read lineary from the tiled buffer */
> +   /* lets read linearly from the tiled buffer */
>      for (y = 0; y < t->tiles_y; y++) {
>         for (x = 0; x < t->tiles_x; x++) {
>   	 /* this inner loop could be replace with SSE magic */
> diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
> index 8a32dbc..5b5c851 100644
> --- a/src/gallium/auxiliary/util/u_simple_shaders.c
> +++ b/src/gallium/auxiliary/util/u_simple_shaders.c
> @@ -686,7 +686,7 @@ util_make_fs_msaa_resolve(struct pipe_context *pipe,
>      struct ureg_program *ureg;
>      struct ureg_src sampler, coord;
>      struct ureg_dst out, tmp_sum, tmp_coord, tmp;
> -   int i;
> +   unsigned i;
>
>      ureg = ureg_create(PIPE_SHADER_FRAGMENT);
>      if (!ureg)
> @@ -747,7 +747,7 @@ util_make_fs_msaa_resolve_bilinear(struct pipe_context *pipe,
>      struct ureg_src sampler, coord;
>      struct ureg_dst out, tmp, top, bottom;
>      struct ureg_dst tmp_coord[4], tmp_sum[4];
> -   int i, c;
> +   unsigned i, c;
>
>      ureg = ureg_create(PIPE_SHADER_FRAGMENT);
>      if (!ureg)
> diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
> index e699828..5210290 100644
> --- a/src/gallium/auxiliary/util/u_tests.c
> +++ b/src/gallium/auxiliary/util/u_tests.c
> @@ -129,7 +129,7 @@ static void
>   util_set_interleaved_vertex_elements(struct cso_context *cso,
>                                        unsigned num_elements)
>   {
> -   int i;
> +   unsigned i;
>      struct pipe_vertex_element *velem =
>         calloc(1, num_elements * sizeof(struct pipe_vertex_element));
>
> @@ -205,7 +205,7 @@ util_probe_rect_rgba_multi(struct pipe_context *ctx, struct pipe_resource *tex,
>      struct pipe_transfer *transfer;
>      void *map;
>      float *pixels = malloc(w * h * 4 * sizeof(float));
> -   int x,y,e,c;
> +   unsigned x,y,e,c;
>      bool pass = true;
>
>      map = pipe_transfer_map(ctx, tex, 0, 0, PIPE_TRANSFER_READ,
> diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
> index c4c2694..5b4e527 100644
> --- a/src/gallium/auxiliary/util/u_vbuf.c
> +++ b/src/gallium/auxiliary/util/u_vbuf.c
> @@ -694,8 +694,8 @@ u_vbuf_translate_begin(struct u_vbuf *mgr,
>               mgr->fallback_velems[i].vertex_buffer_index = mgr->fallback_vbs[type];
>
>               /* elem_index[type][i] can only be set for one type. */
> -            assert(type > VB_INSTANCE || elem_index[type+1][i] == ~0);
> -            assert(type > VB_VERTEX   || elem_index[type+2][i] == ~0);
> +            assert(type > VB_INSTANCE || elem_index[type+1][i] == ~0u);
> +            assert(type > VB_VERTEX   || elem_index[type+2][i] == ~0u);
>               break;
>            }
>         }
> @@ -723,7 +723,7 @@ static void u_vbuf_translate_end(struct u_vbuf *mgr)
>      /* Unreference the now-unused VBOs. */
>      for (i = 0; i < VB_NUM; i++) {
>         unsigned vb = mgr->fallback_vbs[i];
> -      if (vb != ~0) {
> +      if (vb != ~0u) {
>            pipe_resource_reference(&mgr->real_vertex_buffer[vb].buffer, NULL);
>            mgr->fallback_vbs[i] = ~0;
>
> @@ -1197,7 +1197,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
>         if (u_vbuf_need_minmax_index(mgr)) {
>            int max_index;
>
> -         if (new_info.max_index != ~0) {
> +         if (new_info.max_index != ~0u) {
>               min_index = new_info.min_index;
>               max_index = new_info.max_index;
>            } else {
>

Looks good to me.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

Should I push it for you?


More information about the mesa-dev mailing list