devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
Subject: Re: [PATCH 1/3 v2] annotations: check for NULL position
Date: Wed, 17 Jan 2018 12:10:44 +1100	[thread overview]
Message-ID: <20180117011044.GV30352@umbus.fritz.box> (raw)
In-Reply-To: <1516040650-9848-2-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]

On Mon, Jan 15, 2018 at 07:24:08PM +0100, Julia Lawall wrote:
> Check for NULL position and NULL filename.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
> Signed-off-by: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>

Reviewed-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>

> ---
> 
> v2: Use xasprintf without result check.  Only use fname when it is defined.
> 
>  srcpos.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/srcpos.c b/srcpos.c
> index e8fced9..9067ba3 100644
> --- a/srcpos.c
> +++ b/srcpos.c
> @@ -250,12 +250,20 @@ srcpos_copy(struct srcpos *pos)
>  char *
>  srcpos_string(struct srcpos *pos)
>  {
> -	const char *fname = "<no-file>";
> +	const char *fname;
>  	char *pos_str;
>  
> -	if (pos->file && pos->file->name)
> -		fname = pos->file->name;
> +	if (!pos) {
> +		xasprintf(&pos_str, "<no-file>:<no-line>");
> +		return pos_str;
> +	}
>  
> +	if (!pos->file)
> +		fname = "<no-file>";
> +	else if (!pos->file->name)
> +		fname = "<no-filename>";
> +	else
> +		fname = pos->file->name;
>  
>  	if (pos->first_line != pos->last_line)
>  		xasprintf(&pos_str, "%s:%d.%d-%d.%d", fname,

-- 
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2018-01-17  1:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15 18:24 [PATCH 0/3 v2] annotations Julia Lawall
     [not found] ` <1516040650-9848-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-15 18:24   ` [PATCH 1/3 v2] annotations: check for NULL position Julia Lawall
     [not found]     ` <1516040650-9848-2-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-17  1:10       ` David Gibson [this message]
2018-01-15 18:24   ` [PATCH 2/3 v2] annotations: add positions Julia Lawall
     [not found]     ` <1516040650-9848-3-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-17  0:50       ` David Gibson
2018-01-15 18:24   ` [PATCH 3/3 v2] annotations: add the annotation functionality Julia Lawall
     [not found]     ` <1516040650-9848-4-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-01-17  1:13       ` David Gibson
     [not found]         ` <20180117011322.GW30352-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2018-01-17  4:13           ` Frank Rowand
     [not found]             ` <4f3eda57-e50b-922b-0b02-d5859aedda71-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-17  4:17               ` Frank Rowand
     [not found]                 ` <3ba34256-9442-5177-90db-0a180728e05b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-17  5:50                   ` Julia Lawall
2018-01-17  6:11                     ` Frank Rowand
     [not found]                       ` <5fefdac4-87f7-de50-ff39-1911337a2a2e-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-01-17  6:13                         ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180117011044.GV30352@umbus.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=Julia.Lawall-L2FTfq7BK8M@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frank.rowand-7U/KSKJipcs@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).