Re: [PATCH 1/4] as-name: add and use show_as()

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

 




On 08/12/2018 22:03, Luc Van Oostenryck wrote:
> Use a function to display the address spaces.
> This will allow to display a real name instead of '<asn:1>'.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  evaluate.c   |  6 +++---
>  show-parse.c | 13 ++++++++++++-
>  symbol.h     |  1 +
>  3 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/evaluate.c b/evaluate.c
> index 9c2304a7e..f4d49a678 100644
> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -3018,13 +3018,13 @@ static struct symbol *evaluate_cast(struct expression *expr)
>  	}
>  
>  	if (!tas && sas > 0)
> -		warning(expr->pos, "cast removes address space of expression (<asn:%d>)", sas);
> +		warning(expr->pos, "cast removes address space '%s' from expression", show_as(sas));
>  	if (tas > 0 && sas > 0 && tas != sas)
> -		warning(expr->pos, "cast between address spaces (<asn:%d>-><asn:%d>)", sas, tas);
> +		warning(expr->pos, "cast between address spaces (%s - %s)", show_as(sas), show_as(tas));

s/-/->/ ?

ATB,
Ramsay Jones

>  	if (tas > 0 && !sas &&
>  	    !is_null_pointer_constant(source) && Wcast_to_as)
>  		warning(expr->pos,
> -			"cast adds address space to expression (<asn:%d>)", tas);
> +			"cast adds address space '%s' to expression", show_as(tas));
>  
>  	if (!(ttype->ctype.modifiers & MOD_PTRINHERIT) && tclass == TYPE_PTR &&
>  	    !tas && (source->flags & CEF_ICE)) {
> diff --git a/show-parse.c b/show-parse.c
> index 6328439c9..89afdb5f4 100644
> --- a/show-parse.c
> +++ b/show-parse.c
> @@ -182,6 +182,17 @@ void show_symbol_list(struct symbol_list *list, const char *sep)
>  	} END_FOR_EACH_PTR(sym);
>  }
>  
> +const char *show_as(unsigned int as)
> +{
> +	static char buffer[2][32];
> +	static int n;
> +	char *buff;
> +
> +	buff = buffer[2 & ++n];
> +	sprintf(buff, "<asn:%u>", as);
> +	return buff;
> +}
> +
>  struct type_name {
>  	char *start;
>  	char *end;
> @@ -288,7 +299,7 @@ deeper:
>  		size_t len;
>  
>  		if (as)
> -			prepend(name, "<asn:%d>", as);
> +			prepend(name, "%s ", show_as(as));
>  
>  		s = modifier_string(mod);
>  		len = strlen(s);
> diff --git a/symbol.h b/symbol.h
> index 5a3d7cef5..b8e0cac82 100644
> --- a/symbol.h
> +++ b/symbol.h
> @@ -315,6 +315,7 @@ extern void bind_symbol(struct symbol *, struct ident *, enum namespace);
>  
>  extern struct symbol *examine_symbol_type(struct symbol *);
>  extern struct symbol *examine_pointer_target(struct symbol *);
> +extern const char *show_as(unsigned int as);
>  extern const char *show_typename(struct symbol *sym);
>  extern const char *builtin_typename(struct symbol *sym);
>  extern const char *builtin_ctypename(struct ctype *ctype);
> 



[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