Re: [PATCH 3/4] typeof: extract examine_typeof() from examine_symbol_type()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 15/12/2019 11:04, Luc Van Oostenryck wrote:
> No functional changes here, just moving the code for the
> conversion of SYM_TYPEOFs in its own function, in preparation
> for some further changes.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  symbol.c | 41 +++++++++++++++++++++--------------------
>  1 file changed, 21 insertions(+), 20 deletions(-)
> 
> diff --git a/symbol.c b/symbol.c
> index 3655cbb78913..46fe740b4cc1 100644
> --- a/symbol.c
> +++ b/symbol.c
> @@ -453,6 +453,25 @@ static struct symbol *examine_pointer_type(struct symbol *sym)
>  	return sym;
>  }
>  
> +static struct symbol *examine_typeof(struct symbol *sym)
> +{
> +	struct symbol *base = evaluate_expression(sym->initializer);
> +	unsigned long mod = 0;
> +
> +	if (!base)
> +		base = &bad_ctype;
> +	if (is_bitfield_type(base))
> +		warning(base->pos, "typeof applied to bitfield type");
> +	if (base->type == SYM_NODE) {
> +		mod |= base->ctype.modifiers & MOD_TYPEOF;
> +		base = base->ctype.base_type;
> +	}
> +	sym->type = SYM_NODE;
> +	sym->ctype.modifiers = mod;
> +	sym->ctype.base_type = base;
> +	return examine_node_type(sym);
> +}
> +
>  /*
>   * Fill in type size and alignment information for
>   * regular SYM_TYPE things.
> @@ -486,26 +505,8 @@ struct symbol *examine_symbol_type(struct symbol * sym)
>  	case SYM_BASETYPE:
>  		/* Size and alignment had better already be set up */
>  		return sym;
> -	case SYM_TYPEOF: {
> -		struct symbol *base = evaluate_expression(sym->initializer);
> -		if (base) {
> -			unsigned long mod = 0;
> -
> -			if (is_bitfield_type(base))
> -				warning(base->pos, "typeof applied to bitfield type");
> -			if (base->type == SYM_NODE) {
> -				mod |= base->ctype.modifiers & MOD_TYPEOF;
> -				base = base->ctype.base_type;
> -			}
> -			sym->type = SYM_NODE;
> -			sym->ctype.modifiers = mod;
> -			sym->ctype.base_type = base;
> -			return examine_node_type(sym);
> -		}
> -		sym->type = SYM_NODE;
> -		sym->ctype.base_type = &bad_ctype;
> -		return sym;

Hmm, it was not immediately clear that the '!base' path did not
introduce an (effective) functional change. I suspect that it
does not, but I wasn't sure if examine_node_type(sym) for the
above 'bad_ctype' symbol would add alignment, bit_size or rank
to the symbol (and even if it did, would it matter?).

ATB,
Ramsay Jones

> -	}
> +	case SYM_TYPEOF:
> +		return examine_typeof(sym);
>  	case SYM_PREPROCESSOR:
>  		sparse_error(sym->pos, "ctype on preprocessor command? (%s)", show_ident(sym->ident));
>  		return NULL;
> 



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux