Re: [PATCH 3/3] checks: Use source position information for check failures

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



On Wed, Nov 21, 2018 at 03:53:59PM -0600, Rob Herring wrote:
> Now that we retain source position information of nodes and properties,
> make that the preferred file name (and position) to print out in check
> failures. This will greatly simplify finding and fixing check errors
> because most errors are in included source .dtsi files and they get
> duplicated every time the source file is included.
> 
> Signed-off-by: Rob Herring <robh@xxxxxxxxxx>

Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>

but will need a rebase for the respin of 2/3 I've requested.

> ---
>  checks.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/checks.c b/checks.c
> index e60940d2af86..77b75bf54d34 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -19,6 +19,7 @@
>   */
>  
>  #include "dtc.h"
> +#include "srcpos.h"
>  
>  #ifdef TRACE_CHECKS
>  #define TRACE(c, ...) \
> @@ -83,12 +84,30 @@ static inline void  PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti,
>  	char buffer[MAX_MSG_LEN];
>  	char *str = buffer;
>  	char *end = str + MAX_MSG_LEN;
> +	struct srcpos *pos = NULL;
> +	char *file_str;
>  
>  	if (!(c->warn && (quiet < 1)) && !(c->error && (quiet < 2)))
>  		return;
>  
> -	str += snprintf(str, end - str, "%s: %s (%s): ",
> -			strcmp(dti->outname, "-") ? dti->outname : "<stdout>",
> +	if (prop && prop->srcpos)
> +		pos = prop->srcpos;
> +	else if (node && node->srcpos)
> +		pos = node->srcpos;
> +
> +	if (pos) {
> +		file_str = srcpos_string(pos);
> +		strncpy(str, file_str, end - str);
> +		free(file_str);
> +	} else if (streq(dti->outname, "-")) {
> +		strncpy(str, "<stdout>", end - str);
> +	} else {
> +		strncpy(str, dti->outname, end - str);
> +	}
> +	str += strlen(str);
> +	assert(str < end);
> +
> +	str += snprintf(str, end - str, ": %s (%s): ",
>  			(c->error) ? "ERROR" : "Warning", c->name);
>  	assert(str < end);
>  
> @@ -107,6 +126,18 @@ static inline void  PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti,
>  
>  	strcpy(str, "\n");
>  
> +	if (!prop && pos) {
> +		pos = node->srcpos;
> +		while (pos->next) {
> +			pos = pos->next;
> +
> +			file_str = srcpos_string(pos);
> +			str += snprintf(str, end - str, "  also defined at %s\n", file_str);
> +			free(file_str);
> +			assert(str < end);
> +		}
> +	}
> +
>  	fputs(buffer, stderr);
>  }
>  

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux