[Mesa-dev] [PATCH] intel: aubinator_error_decode: fix segfault on missing register

Kenneth Graunke kenneth at whitecape.org
Thu Feb 22 17:14:55 UTC 2018


On Thursday, February 22, 2018 5:41:10 AM PST Lionel Landwerlin wrote:
> Some register might be missing in our genxmls. Don't try to decode
> them.
> 
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
> ---
>  src/intel/tools/aubinator_error_decode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c
> index 2331114b446..08ece771fde 100644
> --- a/src/intel/tools/aubinator_error_decode.c
> +++ b/src/intel/tools/aubinator_error_decode.c
> @@ -65,9 +65,9 @@ print_head(unsigned int reg)
>  static void
>  print_register(struct gen_spec *spec, const char *name, uint32_t reg)
>  {
> -   struct gen_group *reg_spec = gen_spec_find_register_by_name(spec, name);
> +   struct gen_group *reg_spec;
>  
> -   if (reg_spec) {
> +   if (name && (reg_spec = gen_spec_find_register_by_name(spec, name))) {
>        gen_print_group(stdout, reg_spec, 0, &reg, 0,
>                        option_color == COLOR_ALWAYS);
>     }
> 

Personally I would write this as:

   struct gen_group *reg_spec = !name ? NULL :
      gen_spec_find_register_by_name(spec, name);

or

   struct gen_group *reg_spec =
      name ? gen_spec_find_register_by_name(spec, name) : NULL;

because assignments in expressions, giving them side-effects, can be a
bit surprising, while ternaries are common and straightforward.

Either way,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180222/340f8b3e/attachment.sig>


More information about the mesa-dev mailing list