[Intel-gfx] [PATCH i-g-t] tools/null_state_gen: fix various compiler warnings

Mika Kuoppala mika.kuoppala at linux.intel.com
Fri Aug 28 07:38:47 PDT 2015


Thomas Wood <thomas.wood at intel.com> writes:

> Add the debug and warning flags to cflags and fix the resulting issues.
>
> Signed-off-by: Thomas Wood <thomas.wood at intel.com>

Much better now,

Reviewed-by: Mika Kuoppala <mika.kuoppala at intel.com>


> ---
>  tools/null_state_gen/Makefile.am              |  2 ++
>  tools/null_state_gen/intel_batchbuffer.c      |  7 +++---
>  tools/null_state_gen/intel_batchbuffer.h      |  4 +++-
>  tools/null_state_gen/intel_null_state_gen.c   |  8 ++-----
>  tools/null_state_gen/intel_renderstate.h      | 34 +++++++++++++++++++++++++++
>  tools/null_state_gen/intel_renderstate_gen6.c |  2 +-
>  tools/null_state_gen/intel_renderstate_gen7.c |  4 +---
>  tools/null_state_gen/intel_renderstate_gen8.c |  6 ++---
>  tools/null_state_gen/intel_renderstate_gen9.c |  7 ++----
>  9 files changed, 51 insertions(+), 23 deletions(-)
>  create mode 100644 tools/null_state_gen/intel_renderstate.h
>
> diff --git a/tools/null_state_gen/Makefile.am b/tools/null_state_gen/Makefile.am
> index bf8cbdb..24884a7 100644
> --- a/tools/null_state_gen/Makefile.am
> +++ b/tools/null_state_gen/Makefile.am
> @@ -1,11 +1,13 @@
>  GPU_TOOLS_PATH := $(top_srcdir)
>  AM_CPPFLAGS = -I$(top_srcdir)
> +AM_CFLAGS = $(DEBUG_CFLAGS) $(CWARNFLAGS)
>  
>  noinst_PROGRAMS = intel_null_state_gen
>  
>  intel_null_state_gen_SOURCES = 	\
>  	intel_batchbuffer.c \
>  	intel_batchbuffer.h \
> +	intel_renderstate.h \
>  	intel_renderstate_gen6.c \
>  	intel_renderstate_gen7.c \
>  	intel_renderstate_gen8.c \
> diff --git a/tools/null_state_gen/intel_batchbuffer.c b/tools/null_state_gen/intel_batchbuffer.c
> index a31ea38..5aa980e 100644
> --- a/tools/null_state_gen/intel_batchbuffer.c
> +++ b/tools/null_state_gen/intel_batchbuffer.c
> @@ -3,7 +3,7 @@
>   * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
>   * All Rights Reserved.
>   *
> - * Copyright 2014 Intel Corporation
> + * Copyright 2014, 2015 Intel Corporation
>   * All Rights Reserved.
>   *
>   * Permission is hereby granted, free of charge, to any person obtaining a
> @@ -164,7 +164,7 @@ unsigned intel_batch_num_cmds(struct intel_batchbuffer *batch)
>  	return bb_area_items(batch->cmds);
>  }
>  
> -static unsigned intel_batch_num_state(struct intel_batchbuffer *batch)
> +unsigned intel_batch_num_state(struct intel_batchbuffer *batch)
>  {
>  	return bb_area_items(batch->state);
>  }
> @@ -217,9 +217,10 @@ uint32_t intel_batch_state_copy(struct intel_batchbuffer *batch,
>  
>  	for (i = 0; i < dwords; i++) {
>  		char offsetinside[80];
> +		uint32_t *s;
>  		sprintf(offsetinside, "%s: 0x%x", str, i * 4);
>  
> -		uint32_t *s = (uint32_t *)(uint8_t *)d + i;
> +		s = (uint32_t *)(uint8_t *)d + i;
>  		bb_area_emit(batch->state, *s, STATE, offsetinside);
>  	}
>  
> diff --git a/tools/null_state_gen/intel_batchbuffer.h b/tools/null_state_gen/intel_batchbuffer.h
> index 8b87c02..2919e87 100644
> --- a/tools/null_state_gen/intel_batchbuffer.h
> +++ b/tools/null_state_gen/intel_batchbuffer.h
> @@ -3,7 +3,7 @@
>   * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
>   * All Rights Reserved.
>   *
> - * Copyright 2014 Intel Corporation
> + * Copyright 2014, 2015 Intel Corporation
>   * All Rights Reserved.
>   *
>   * Permission is hereby granted, free of charge, to any person obtaining a
> @@ -86,6 +86,8 @@ uint32_t intel_batch_state_alloc(struct intel_batchbuffer *batch, unsigned bytes
>  				 const char *name);
>  uint32_t intel_batch_state_offset(struct intel_batchbuffer *batch, unsigned align);
>  unsigned intel_batch_num_cmds(struct intel_batchbuffer *batch);
> +struct bb_item *intel_batch_state_get(struct intel_batchbuffer *batch, unsigned i);
> +unsigned intel_batch_num_state(struct intel_batchbuffer *batch);
>  
>  struct bb_item *intel_batch_cmd_get(struct intel_batchbuffer *batch, unsigned i);
>  int intel_batch_is_reloc(struct intel_batchbuffer *batch, unsigned i);
> diff --git a/tools/null_state_gen/intel_null_state_gen.c b/tools/null_state_gen/intel_null_state_gen.c
> index 8024ac3..7d5887e 100644
> --- a/tools/null_state_gen/intel_null_state_gen.c
> +++ b/tools/null_state_gen/intel_null_state_gen.c
> @@ -30,13 +30,9 @@
>  #include <errno.h>
>  #include <assert.h>
>  
> +#include "intel_renderstate.h"
>  #include "intel_batchbuffer.h"
>  
> -extern int gen6_setup_null_render_state(struct intel_batchbuffer *batch);
> -extern int gen7_setup_null_render_state(struct intel_batchbuffer *batch);
> -extern int gen8_setup_null_render_state(struct intel_batchbuffer *batch);
> -extern int gen9_setup_null_render_state(struct intel_batchbuffer *batch);
> -
>  static int debug = 0;
>  
>  static void print_usage(char *s)
> @@ -115,7 +111,7 @@ static int do_generate(int gen)
>  {
>  	struct intel_batchbuffer *batch;
>  	int ret = -EINVAL;
> -	int (*null_state_gen)(struct intel_batchbuffer *batch) = NULL;
> +	void (*null_state_gen)(struct intel_batchbuffer *batch) = NULL;
>  
>  	batch = intel_batchbuffer_create();
>  	if (batch == NULL)
> diff --git a/tools/null_state_gen/intel_renderstate.h b/tools/null_state_gen/intel_renderstate.h
> new file mode 100644
> index 0000000..b27b434
> --- /dev/null
> +++ b/tools/null_state_gen/intel_renderstate.h
> @@ -0,0 +1,34 @@
> +/*
> + * Copyright © 2015 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> + * DEALINGS IN THE SOFTWARE.
> + */
> +
> +#ifndef __INTEL_RENDERSTATE_H__
> +#define __INTEL_RENDERSTATE_H__
> +
> +#include "intel_batchbuffer.h"
> +
> +void gen6_setup_null_render_state(struct intel_batchbuffer *batch);
> +void gen7_setup_null_render_state(struct intel_batchbuffer *batch);
> +void gen8_setup_null_render_state(struct intel_batchbuffer *batch);
> +void gen9_setup_null_render_state(struct intel_batchbuffer *batch);
> +
> +#endif /* __INTEL_RENDERSTATE_H__ */
> diff --git a/tools/null_state_gen/intel_renderstate_gen6.c b/tools/null_state_gen/intel_renderstate_gen6.c
> index f18bb12..5c1b7f9 100644
> --- a/tools/null_state_gen/intel_renderstate_gen6.c
> +++ b/tools/null_state_gen/intel_renderstate_gen6.c
> @@ -24,7 +24,7 @@
>   *	Mika Kuoppala <mika.kuoppala at intel.com>
>   */
>  
> -#include "intel_batchbuffer.h"
> +#include "intel_renderstate.h"
>  #include <lib/gen6_render.h>
>  #include <lib/intel_reg.h>
>  #include <string.h>
> diff --git a/tools/null_state_gen/intel_renderstate_gen7.c b/tools/null_state_gen/intel_renderstate_gen7.c
> index a48fb27..df20bc2 100644
> --- a/tools/null_state_gen/intel_renderstate_gen7.c
> +++ b/tools/null_state_gen/intel_renderstate_gen7.c
> @@ -24,7 +24,7 @@
>   *	Mika Kuoppala <mika.kuoppala at intel.com>
>   */
>  
> -#include "intel_batchbuffer.h"
> +#include "intel_renderstate.h"
>  #include <lib/gen7_render.h>
>  #include <lib/intel_reg.h>
>  #include <string.h>
> @@ -417,8 +417,6 @@ gen7_emit_null_depth_buffer(struct intel_batchbuffer *batch)
>  
>  void gen7_setup_null_render_state(struct intel_batchbuffer *batch)
>  {
> -	int ret;
> -
>  	OUT_BATCH(GEN7_PIPELINE_SELECT | PIPELINE_SELECT_3D);
>  
>  	gen7_emit_state_base_address(batch);
> diff --git a/tools/null_state_gen/intel_renderstate_gen8.c b/tools/null_state_gen/intel_renderstate_gen8.c
> index 2d7a4b0..6a309d4 100644
> --- a/tools/null_state_gen/intel_renderstate_gen8.c
> +++ b/tools/null_state_gen/intel_renderstate_gen8.c
> @@ -24,6 +24,7 @@
>   *	Mika Kuoppala <mika.kuoppala at intel.com>
>   */
>  
> +#include "intel_renderstate.h"
>  #include "intel_batchbuffer.h"
>  #include <lib/gen8_render.h>
>  #include <lib/intel_reg.h>
> @@ -322,11 +323,8 @@ static void gen8_emit_primitive(struct intel_batchbuffer *batch)
>          OUT_BATCH(0);   /* index buffer offset, ignored */
>  }
>  
> -int gen8_setup_null_render_state(struct intel_batchbuffer *batch)
> +void gen8_setup_null_render_state(struct intel_batchbuffer *batch)
>  {
> -	int ret;
> -	int i;
> -
>  #define GEN8_PIPE_CONTROL_GLOBAL_GTT   (1 << 24)
>  
>  	OUT_BATCH(GEN6_PIPE_CONTROL | (6 - 2));
> diff --git a/tools/null_state_gen/intel_renderstate_gen9.c b/tools/null_state_gen/intel_renderstate_gen9.c
> index 37bc675..a0b7d8a 100644
> --- a/tools/null_state_gen/intel_renderstate_gen9.c
> +++ b/tools/null_state_gen/intel_renderstate_gen9.c
> @@ -25,7 +25,7 @@
>   *	Mika Kuoppala <mika.kuoppala at intel.com>
>   */
>  
> -#include "intel_batchbuffer.h"
> +#include "intel_renderstate.h"
>  #include <lib/gen9_render.h>
>  #include <lib/intel_reg.h>
>  
> @@ -342,9 +342,8 @@ static void gen9_emit_state_base_address(struct intel_batchbuffer *batch) {
>   * Generate the batch buffer commands needed to initialize the 3D engine
>   * to its "golden state".
>   */
> -int gen9_setup_null_render_state(struct intel_batchbuffer *batch)
> +void gen9_setup_null_render_state(struct intel_batchbuffer *batch)
>  {
> -	int ret;
>  	int i;
>  
>  #define GEN8_PIPE_CONTROL_GLOBAL_GTT   (1 << 24)
> @@ -477,6 +476,4 @@ int gen9_setup_null_render_state(struct intel_batchbuffer *batch)
>  	gen8_emit_primitive(batch);
>  
>  	OUT_BATCH(MI_BATCH_BUFFER_END);
> -
> -	return ret;
>  }
> -- 
> 1.9.1


More information about the Intel-gfx mailing list