[Mesa-dev] [PATCH] glsl: do not show locp information if it is not available

Timothy Arceri timothy.arceri at collabora.com
Wed Oct 26 08:32:51 UTC 2016


On Wed, 2016-10-26 at 09:13 +0200, Juan A. Suarez Romero wrote:
> Ignore source file, line number and column in glcpp_error() and
> glcpp_warning() if those are not available.
> 
> It fixes 4 piglit tests:
>   spec/glsl-1.10/compiler/version-0.frag: crash pass
>   spec/glsl-1.10/compiler/version-0.vert: crash pass
>   spec/glsl-es-3.00/compiler/version-0.frag: crash pass
>   spec/glsl-es-3.00/compiler/version-0.vert: crash pass
> ---
>  src/compiler/glsl/glcpp/pp.c | 41 +++++++++++++++++++++++++++-------
> -------
>  1 file changed, 27 insertions(+), 14 deletions(-)
> 
> diff --git a/src/compiler/glsl/glcpp/pp.c
> b/src/compiler/glsl/glcpp/pp.c
> index b591279..38f031a 100644
> --- a/src/compiler/glsl/glcpp/pp.c
> +++ b/src/compiler/glsl/glcpp/pp.c
> @@ -32,13 +32,20 @@ glcpp_error (YYLTYPE *locp, glcpp_parser_t
> *parser, const char *fmt, ...)
>  	va_list ap;
>  
>  	parser->error = 1;
> -	ralloc_asprintf_rewrite_tail(&parser->info_log,
> -				     &parser->info_log_length,
> -				     "%u:%u(%u): "
> -				     "preprocessor error: ",
> -				     locp->source,
> -				     locp->first_line,
> -				     locp->first_column);
> +
> +        if (locp)
> +           ralloc_asprintf_rewrite_tail(&parser->info_log,
> +                                        &parser->info_log_length,
> +                                        "%u:%u(%u): "
> +                                        "preprocessor error: ",
> +                                        locp->source,
> +                                        locp->first_line,
> +                                        locp->first_column);

Please use braces with if when there is on more than a single line in
the then/else blocks.

Also there seems to be tabs in here please remove them when adding new
code :)

> +        else
> +           ralloc_asprintf_rewrite_tail(&parser->info_log,
> +                                        &parser->info_log_length,
> +                                        "preprocessor error: ");
> +
>  	va_start(ap, fmt);
>  	ralloc_vasprintf_rewrite_tail(&parser->info_log,
>  				      &parser->info_log_length,
> @@ -53,13 +60,19 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t
> *parser, const char *fmt, ...)
>  {
>  	va_list ap;
>  
> -	ralloc_asprintf_rewrite_tail(&parser->info_log,
> -				     &parser->info_log_length,
> -				     "%u:%u(%u): "
> -				     "preprocessor warning: ",
> -				     locp->source,
> -				     locp->first_line,
> -				     locp->first_column);
> +        if (locp)
> +           ralloc_asprintf_rewrite_tail(&parser->info_log,
> +                                        &parser->info_log_length,
> +                                        "%u:%u(%u): "
> +                                        "preprocessor warning: ",
> +                                        locp->source,
> +                                        locp->first_line,
> +                                        locp->first_column);
> +        else
> +           ralloc_asprintf_rewrite_tail(&parser->info_log,
> +                                        &parser->info_log_length,
> +                                        "preprocesor warning: ");
> +
>  	va_start(ap, fmt);
>  	ralloc_vasprintf_rewrite_tail(&parser->info_log,
>  				      &parser->info_log_length,


More information about the mesa-dev mailing list