[virglrenderer-devel] [PATCH 18/21] testvirgl_encode.c: Fix warnings

Gert Wollny gert.wollny at collabora.com
Fri Jun 1 08:48:05 UTC 2018


testvirgl_encode.c: In function »virgl_emit_shader_streamout«:
testvirgl_encode.c:219:21: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
       for (i = 0; i < so_info->num_outputs; i++) {
                     ^
testvirgl_encode.c: In function »virgl_encode_clear«:
testvirgl_encode.c:315:4: Warning: Dereferenzierung eines Type-Pun-
Zeigers verletzt strict-aliasing-Regeln [-Wstrict-aliasing]
    virgl_encoder_write_qword(ctx->cbuf, *(uint64_t *)&depth);
    ^~~~~~~~~~~~~~~~~~~~~~~~~
testvirgl_encode.c: In function »virgl_encoder_set_framebuffer_state«:
testvirgl_encode.c:329:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
    for (i = 0; i < state->nr_cbufs; i++) {
                  ^
testvirgl_encode.c: In function »virgl_encoder_create_vertex_elements«:
testvirgl_encode.c:362:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
    for (i = 0; i < num_elements; i++) {
                  ^
testvirgl_encode.c: In function »virgl_encoder_set_vertex_buffers«:
testvirgl_encode.c:377:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
    for (i = 0; i < num_buffers; i++) {
                  ^
testvirgl_encode.c: In function »virgl_encoder_inline_write«:
testvirgl_encode.c:531:26: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
    for (layer = 0; layer < box->depth; layer++) {
                          ^
testvirgl_encode.c:537:24: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
      for (row = 0; row < box->height; row++) {
                        ^
testvirgl_encode.c: In function »virgl_encoder_flush_frontbuffer«:
testvirgl_encode.c:566:59: Warning: unused parameter »ctx« [-Wunused-
parameter]
 int virgl_encoder_flush_frontbuffer(struct virgl_context *ctx,
                                                           ^~~
testvirgl_encode.c:567:59: Warning: unused parameter »res« [-Wunused-
parameter]
                                    struct virgl_resource *res)
                                                           ^~~
testvirgl_encode.c: In function »virgl_encode_set_sampler_views«:
testvirgl_encode.c:637:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
    for (i = 0; i < num_views; i++) {
                  ^
testvirgl_encode.c: In function »virgl_encode_bind_sampler_states«:
testvirgl_encode.c:654:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
    for (i = 0; i < num_handles; i++)
                  ^
testvirgl_encode.c: In function »virgl_encoder_set_so_targets«:
testvirgl_encode.c:872:18: Warning: comparison between signed and unsigned
integer expressions [-Wsign-
compare]
    for (i = 0; i < num_targets; i++) {

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 tests/testvirgl_encode.c | 20 +++++++++++---------
 tests/testvirgl_encode.h |  7 +++++++
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/tests/testvirgl_encode.c b/tests/testvirgl_encode.c
index ce62ecc..94f1a02 100644
--- a/tests/testvirgl_encode.c
+++ b/tests/testvirgl_encode.c
@@ -205,7 +205,7 @@ static void virgl_emit_shader_streamout(struct virgl_context *ctx,
                                         const struct pipe_stream_output_info *so_info)
 {
    int num_outputs = 0;
-   int i;
+   uint i;
    uint32_t tmp;
 
    if (so_info)
@@ -312,7 +312,7 @@ int virgl_encode_clear(struct virgl_context *ctx,
    virgl_encoder_write_dword(ctx->cbuf, buffers);
    for (i = 0; i < 4; i++)
       virgl_encoder_write_dword(ctx->cbuf, color->ui[i]);
-   virgl_encoder_write_qword(ctx->cbuf, *(uint64_t *)&depth);
+   virgl_encoder_write_double(ctx->cbuf, depth);
    virgl_encoder_write_dword(ctx->cbuf, stencil);
    return 0;
 }
@@ -321,7 +321,7 @@ int virgl_encoder_set_framebuffer_state(struct virgl_context *ctx,
 				       const struct pipe_framebuffer_state *state)
 {
    struct virgl_surface *zsurf = (struct virgl_surface *)state->zsbuf;
-   int i;
+   uint i;
 
    virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_FRAMEBUFFER_STATE, 0, VIRGL_SET_FRAMEBUFFER_STATE_SIZE(state->nr_cbufs)));
    virgl_encoder_write_dword(ctx->cbuf, state->nr_cbufs);
@@ -356,7 +356,7 @@ int virgl_encoder_create_vertex_elements(struct virgl_context *ctx,
                                         unsigned num_elements,
                                         const struct pipe_vertex_element *element)
 {
-   int i;
+   uint i;
    virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_CREATE_OBJECT, VIRGL_OBJECT_VERTEX_ELEMENTS, VIRGL_OBJ_VERTEX_ELEMENTS_SIZE(num_elements)));
    virgl_encoder_write_dword(ctx->cbuf, handle);
    for (i = 0; i < num_elements; i++) {
@@ -372,7 +372,7 @@ int virgl_encoder_set_vertex_buffers(struct virgl_context *ctx,
                                     unsigned num_buffers,
                                     const struct pipe_vertex_buffer *buffers)
 {
-   int i;
+   uint i;
    virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_VERTEX_BUFFERS, 0, VIRGL_SET_VERTEX_BUFFERS_SIZE(num_buffers)));
    for (i = 0; i < num_buffers; i++) {
       struct virgl_resource *res = (struct virgl_resource *)buffers[i].buffer;
@@ -500,7 +500,7 @@ int virgl_encoder_inline_write(struct virgl_context *ctx,
    unsigned layer_size;
    unsigned stride_internal = stride;
    unsigned layer_stride_internal = layer_stride;
-   unsigned layer, row;
+   int layer, row;
    elsize = util_format_get_blocksize(res->base.format);
 
    /* total size of data to transfer */
@@ -566,6 +566,8 @@ int virgl_encoder_inline_write(struct virgl_context *ctx,
 int virgl_encoder_flush_frontbuffer(struct virgl_context *ctx,
                                    struct virgl_resource *res)
 {
+   VREND_UNUSED(ctx);
+   VREND_UNUSED(res);
 //   virgl_encoder_write_dword(ctx->cbuf, VIRGL_CMD0(VIRGL_CCMD_FLUSH_FRONTUBFFER, 0, 1));
 //   virgl_encoder_write_dword(ctx->cbuf, res_handle);
    return 0;
@@ -630,7 +632,7 @@ int virgl_encode_set_sampler_views(struct virgl_context *ctx,
                                   uint32_t num_views,
                                   struct virgl_sampler_view **views)
 {
-   int i;
+   uint i;
    virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_SAMPLER_VIEWS, 0, VIRGL_SET_SAMPLER_VIEWS_SIZE(num_views)));
    virgl_encoder_write_dword(ctx->cbuf, shader_type);
    virgl_encoder_write_dword(ctx->cbuf, start_slot);
@@ -647,7 +649,7 @@ int virgl_encode_bind_sampler_states(struct virgl_context *ctx,
                                     uint32_t num_handles,
                                     uint32_t *handles)
 {
-   int i;
+   uint i;
    virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_BIND_SAMPLER_STATES, 0, VIRGL_BIND_SAMPLER_STATES(num_handles)));
    virgl_encoder_write_dword(ctx->cbuf, shader_type);
    virgl_encoder_write_dword(ctx->cbuf, start_slot);
@@ -865,7 +867,7 @@ int virgl_encoder_set_so_targets(struct virgl_context *ctx,
                                 struct pipe_stream_output_target **targets,
                                 unsigned append_bitmask)
 {
-   int i;
+   uint i;
 
    virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_STREAMOUT_TARGETS, 0, num_targets + 1));
    virgl_encoder_write_dword(ctx->cbuf, append_bitmask);
diff --git a/tests/testvirgl_encode.h b/tests/testvirgl_encode.h
index 310cb14..82b7acb 100644
--- a/tests/testvirgl_encode.h
+++ b/tests/testvirgl_encode.h
@@ -46,6 +46,13 @@ static inline void virgl_encoder_write_qword(struct virgl_cmd_buf *state,
    state->cdw += 2;
 }
 
+static inline void virgl_encoder_write_double(struct virgl_cmd_buf *state,
+                                              double qword)
+{
+   memcpy(state->buf + state->cdw, &qword, sizeof(double));
+   state->cdw += 2;
+}
+
 static inline void virgl_encoder_write_block(struct virgl_cmd_buf *state,
 					    const uint8_t *ptr, uint32_t len)
 {
-- 
2.17.0



More information about the virglrenderer-devel mailing list