From c3a2058a8f51560fa5cd6acd484e2659629479ad Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 5 Jun 2018 22:11:15 +0200 Subject: [PATCH] testvirgl_encode.c: Fix warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Dereferenzing a type-punned pointer violates strict-aliasing-rules [-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++) { v2: - use mesa style UNUSED annotation of unused parameters - correct language of warning messages Reviewed-by: Gurchetan Singh Signed-off-by: Gert Wollny Signed-off-by: Jakob Bornecrantz --- tests/testvirgl_encode.c | 22 +++++++++++----------- tests/testvirgl_encode.h | 7 +++++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tests/testvirgl_encode.c b/tests/testvirgl_encode.c index ce62ecc..d4ff0be 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 */ @@ -563,8 +563,8 @@ int virgl_encoder_inline_write(struct virgl_context *ctx, return 0; } -int virgl_encoder_flush_frontbuffer(struct virgl_context *ctx, - struct virgl_resource *res) +int virgl_encoder_flush_frontbuffer(UNUSED struct virgl_context *ctx, + UNUSED struct virgl_resource *res) { // virgl_encoder_write_dword(ctx->cbuf, VIRGL_CMD0(VIRGL_CCMD_FLUSH_FRONTUBFFER, 0, 1)); // virgl_encoder_write_dword(ctx->cbuf, res_handle); @@ -630,7 +630,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 +647,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 +865,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) {