[virglrenderer-devel] [PATCH 05/21] vrend_renderer.c: Fix warnings and clean code

Gert Wollny gert.wollny at collabora.com
Fri Jun 1 08:47:52 UTC 2018


vrend_renderer.c: In function »set_stream_out_varyings«:
vrend_renderer.c:867:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
    for (i = 0; i < n_outputs; i++)
                  ^
vrend_renderer.c: In function »vrend_set_framebuffer_state«:
vrend_renderer.c:1636:38: Warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
       for (i = ctx->sub->nr_cbufs; i < old_num; i++) {
                                      ^
vrend_renderer.c:1652:21: Warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
       for (i = 0; i < ctx->sub->nr_cbufs; i++) {
                     ^
vrend_renderer.c: In function »vrend_set_viewport_states«:
vrend_renderer.c:1707:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
    for (i = 0; i < num_viewports; i++) {
                  ^
vrend_renderer.c: In function »vrend_create_vertex_elements_state«:
vrend_renderer.c:1778:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
    for (i = 0; i < num_elements; i++) {
                  ^
vrend_renderer.c:1844:21: Warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
       for (i = 0; i < num_elements; i++) {
                     ^
vrend_renderer.c: In function »vrend_set_constants«:
rend_renderer.c:1902:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-compare]
    for (i = 0; i < num_constant; i++)
                  ^
vrend_renderer.c:1887:35: Warning: unused parameter »index« [-Wunused-
parameter]
                          uint32_t index,
                                   ^~~~~
vrend_renderer.c: In function »vrend_set_num_sampler_views«:
vrend_renderer.c:2118:39: Warning: comparison between signed and unsigned
integer expressions [-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.

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 src/vrend_renderer.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 0f74d80..5c33b41 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -1589,7 +1589,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;
@@ -1615,7 +1615,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) {
@@ -1695,7 +1695,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)) {
@@ -1763,7 +1763,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)
@@ -1888,7 +1888,8 @@ void vrend_set_constants(struct vrend_context *ctx,
                          float *data)
 {
    struct vrend_constants *consts;
-   int i;
+   uint i;
+   VREND_UNUSED(index);
 
    consts = &ctx->sub->consts[shader];
    ctx->sub->const_dirty[shader] = true;
@@ -2114,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)
-- 
2.17.0



More information about the virglrenderer-devel mailing list