From: Kristian Høgsberg Kristensen Date: Sun, 14 Feb 2016 22:17:08 +0000 (-0800) Subject: anv: Fix warning 3DSTATE_VERTEX_ELEMENTS setup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=53eaa0a6b8486ff82e7d2e68c3d491866ad5a12f;p=mesa.git anv: Fix warning 3DSTATE_VERTEX_ELEMENTS setup This is a little more subtle. If elem_count is 0, nothing else happens in this function, so we return early to avoid warning about uninitialized 'p'. --- diff --git a/src/vulkan/genX_pipeline_util.h b/src/vulkan/genX_pipeline_util.h index 077281d2f56..696e2be7c3f 100644 --- a/src/vulkan/genX_pipeline_util.h +++ b/src/vulkan/genX_pipeline_util.h @@ -85,14 +85,15 @@ emit_vertex_input(struct anv_pipeline *pipeline, #endif uint32_t elem_count = __builtin_popcount(elements) + needs_svgs_elem; + if (elem_count == 0) + return; uint32_t *p; - if (elem_count > 0) { - const uint32_t num_dwords = 1 + elem_count * 2; - p = anv_batch_emitn(&pipeline->batch, num_dwords, - GENX(3DSTATE_VERTEX_ELEMENTS)); - memset(p + 1, 0, (num_dwords - 1) * 4); - } + + const uint32_t num_dwords = 1 + elem_count * 2; + p = anv_batch_emitn(&pipeline->batch, num_dwords, + GENX(3DSTATE_VERTEX_ELEMENTS)); + memset(p + 1, 0, (num_dwords - 1) * 4); for (uint32_t i = 0; i < info->vertexAttributeDescriptionCount; i++) { const VkVertexInputAttributeDescription *desc =