From 951bb52fd5681151847a6d940bc27655aa163cd7 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 5 Jun 2018 22:11:03 +0200 Subject: [PATCH] vrend_renderer.c: Fix warnings and clean code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vrend_renderer.c: In Funktion »set_stream_out_varyings«: vrend_renderer.c:867:18: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] for (i = 0; i < n_outputs; i++) ^ vrend_renderer.c: In Funktion »vrend_set_framebuffer_state«: vrend_renderer.c:1636:38: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] for (i = ctx->sub->nr_cbufs; i < old_num; i++) { ^ vrend_renderer.c:1652:21: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] for (i = 0; i < ctx->sub->nr_cbufs; i++) { ^ vrend_renderer.c: In Funktion »vrend_set_viewport_states«: vrend_renderer.c:1707:18: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] for (i = 0; i < num_viewports; i++) { ^ vrend_renderer.c: In Funktion »vrend_create_vertex_elements_state«: vrend_renderer.c:1778:18: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] for (i = 0; i < num_elements; i++) { ^ vrend_renderer.c:1844:21: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] for (i = 0; i < num_elements; i++) { ^ vrend_renderer.c: In Funktion »vrend_set_constants«: rend_renderer.c:1902:18: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] for (i = 0; i < num_constant; i++) ^ vrend_renderer.c:1887:35: Warnung: unused parameter »index« [-Wunused- parameter] uint32_t index, ^~~~~ vrend_renderer.c: In Funktion »vrend_set_num_sampler_views«: vrend_renderer.c:2118:39: Warnung: Vergleich zwischen vorzeichenbehafteten und vorzeichenlosen Ganzzahlausdrücken [-Wsign- compare] if (start_slot + num_sampler_views < ctx->sub- >views[shader_type].num_views) { In this case the if-condition enclosing the for loop was removed because it was superfluous. v2: Use mesa-style UNUSED for unused parameters Reviewed-by: Gurchetan Singh Signed-off-by: Gert Wollny Signed-off-by: Jakob Bornecrantz --- src/vrend_renderer.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index f3bb700..d976e1f 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -1590,7 +1590,7 @@ void vrend_set_framebuffer_state(struct vrend_context *ctx, uint32_t zsurf_handle) { struct vrend_surface *surf, *zsurf; - uint i; + int i; int old_num; GLenum status; GLint new_height = -1; @@ -1616,7 +1616,7 @@ void vrend_set_framebuffer_state(struct vrend_context *ctx, ctx->sub->nr_cbufs = nr_cbufs; ctx->sub->old_nr_cbufs = old_num; - for (i = 0; i < nr_cbufs; i++) { + for (i = 0; i < (int)nr_cbufs; i++) { if (surf_handle[i] != 0) { surf = vrend_object_lookup(ctx->sub->object_hash, surf_handle[i], VIRGL_OBJECT_SURFACE); if (!surf) { @@ -1696,7 +1696,7 @@ void vrend_set_viewport_states(struct vrend_context *ctx, GLsizei width, height; GLclampd near_val, far_val; bool viewport_is_negative = (state[0].scale[1] < 0) ? true : false; - int i, idx; + uint i, idx; if (num_viewports > PIPE_MAX_VIEWPORTS || start_slot > (PIPE_MAX_VIEWPORTS - num_viewports)) { @@ -1764,7 +1764,7 @@ int vrend_create_vertex_elements_state(struct vrend_context *ctx, struct vrend_vertex_element_array *v; const struct util_format_description *desc; GLenum type; - int i; + uint i; uint32_t ret_handle; if (num_elements > PIPE_MAX_ATTRIBS) @@ -1884,12 +1884,12 @@ void vrend_bind_vertex_elements_state(struct vrend_context *ctx, void vrend_set_constants(struct vrend_context *ctx, uint32_t shader, - uint32_t index, + UNUSED uint32_t index, uint32_t num_constant, float *data) { struct vrend_constants *consts; - int i; + uint i; consts = &ctx->sub->consts[shader]; ctx->sub->const_dirty[shader] = true; @@ -2115,12 +2115,13 @@ void vrend_set_num_sampler_views(struct vrend_context *ctx, uint32_t start_slot, int num_sampler_views) { - if (start_slot + num_sampler_views < ctx->sub->views[shader_type].num_views) { - int i; - for (i = start_slot + num_sampler_views; i < ctx->sub->views[shader_type].num_views; i++) - vrend_sampler_view_reference(&ctx->sub->views[shader_type].views[i], NULL); - } - ctx->sub->views[shader_type].num_views = start_slot + num_sampler_views; + int last_slot = start_slot + num_sampler_views; + int i; + + for (i = last_slot; i < ctx->sub->views[shader_type].num_views; i++) + vrend_sampler_view_reference(&ctx->sub->views[shader_type].views[i], NULL); + + ctx->sub->views[shader_type].num_views = last_slot; } static void vrend_destroy_shader_object(void *obj_ptr)