[Mesa-dev] [PATCH 11/19] anv: Use GNU C empty brace initializer
Eric Engestrom
eric.engestrom at imgtec.com
Tue Aug 29 10:11:28 UTC 2017
On Monday, 2017-08-28 14:57:13 -0700, Matt Turner wrote:
> Avoids Clang's warning about the current code:
>
> warning: suggest braces around initialization of subobject
I'm not sure about this patch [1], but everything else in this series is:
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
The "mark `UNUSED` because they are unused in some generations" patches
might be better to mark as `MAYBE_UNUSED`; they both resolve to the same
thing for compilers, but the latter is gives more information to humans
(ie. "this isn't always unused").
[1]
Can you test this with GCC 4.x and 7.x? If memory serves, this init format
caused warnings on either old GCC or new GCC.
I think `= {{0}};` was the only format that both compilers were happy with.
CC'ing Emil who might remember more/better than me.
> ---
> src/intel/vulkan/anv_formats.c | 2 +-
> src/intel/vulkan/anv_pipeline.c | 20 ++++++++++----------
> 2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
> index 9808508523..6ce609ae8d 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -739,7 +739,7 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR(
> * the implementation for use in vkCreateImage, then all members of
> * imageFormatProperties will be filled with zero.
> */
> - base_props->imageFormatProperties = (VkImageFormatProperties) {0};
> + base_props->imageFormatProperties = (VkImageFormatProperties) {};
> }
>
> return result;
> diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
> index 279d76561a..8306cd366a 100644
> --- a/src/intel/vulkan/anv_pipeline.c
> +++ b/src/intel/vulkan/anv_pipeline.c
> @@ -510,7 +510,7 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
> }
>
> if (bin == NULL) {
> - struct brw_vs_prog_data prog_data = { 0, };
> + struct brw_vs_prog_data prog_data = {};
> struct anv_pipeline_binding surface_to_descriptor[256];
> struct anv_pipeline_binding sampler_to_descriptor[256];
>
> @@ -617,8 +617,8 @@ anv_pipeline_compile_tcs_tes(struct anv_pipeline *pipeline,
> pipeline->device->instance->physicalDevice.compiler;
> struct anv_pipeline_bind_map tcs_map;
> struct anv_pipeline_bind_map tes_map;
> - struct brw_tcs_prog_key tcs_key = { 0, };
> - struct brw_tes_prog_key tes_key = { 0, };
> + struct brw_tcs_prog_key tcs_key = {};
> + struct brw_tes_prog_key tes_key = {};
> struct anv_shader_bin *tcs_bin = NULL;
> struct anv_shader_bin *tes_bin = NULL;
> unsigned char tcs_sha1[40];
> @@ -642,8 +642,8 @@ anv_pipeline_compile_tcs_tes(struct anv_pipeline *pipeline,
> }
>
> if (tcs_bin == NULL || tes_bin == NULL) {
> - struct brw_tcs_prog_data tcs_prog_data = { 0, };
> - struct brw_tes_prog_data tes_prog_data = { 0, };
> + struct brw_tcs_prog_data tcs_prog_data = {};
> + struct brw_tes_prog_data tes_prog_data = {};
> struct anv_pipeline_binding tcs_surface_to_descriptor[256];
> struct anv_pipeline_binding tcs_sampler_to_descriptor[256];
> struct anv_pipeline_binding tes_surface_to_descriptor[256];
> @@ -775,7 +775,7 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
> }
>
> if (bin == NULL) {
> - struct brw_gs_prog_data prog_data = { 0, };
> + struct brw_gs_prog_data prog_data = {};
> struct anv_pipeline_binding surface_to_descriptor[256];
> struct anv_pipeline_binding sampler_to_descriptor[256];
>
> @@ -853,7 +853,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
> }
>
> if (bin == NULL) {
> - struct brw_wm_prog_data prog_data = { 0, };
> + struct brw_wm_prog_data prog_data = {};
> struct anv_pipeline_binding surface_to_descriptor[256];
> struct anv_pipeline_binding sampler_to_descriptor[256];
>
> @@ -976,7 +976,7 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
> }
>
> if (bin == NULL) {
> - struct brw_cs_prog_data prog_data = { 0, };
> + struct brw_cs_prog_data prog_data = {};
> struct anv_pipeline_binding surface_to_descriptor[256];
> struct anv_pipeline_binding sampler_to_descriptor[256];
>
> @@ -1277,8 +1277,8 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
>
> pipeline->active_stages = 0;
>
> - const VkPipelineShaderStageCreateInfo *pStages[MESA_SHADER_STAGES] = { 0, };
> - struct anv_shader_module *modules[MESA_SHADER_STAGES] = { 0, };
> + const VkPipelineShaderStageCreateInfo *pStages[MESA_SHADER_STAGES] = {};
> + struct anv_shader_module *modules[MESA_SHADER_STAGES] = {};
> for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
> gl_shader_stage stage = ffs(pCreateInfo->pStages[i].stage) - 1;
> pStages[stage] = &pCreateInfo->pStages[i];
> --
> 2.13.5
>
More information about the mesa-dev
mailing list