From: Julia Lawall <Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Frank Rowand <frank.rowand-7U/KSKJipcs@public.gmane.org>
Subject: [PATCH 1/3 v4] annotations: check for NULL position
Date: Fri, 2 Feb 2018 21:41:48 +0100 [thread overview]
Message-ID: <1517604110-790-2-git-send-email-Julia.Lawall@lip6.fr> (raw)
In-Reply-To: <1517604110-790-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
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>
---
v4: no change
srcpos.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/srcpos.c b/srcpos.c
index cb6ed0e..9dd3297 100644
--- a/srcpos.c
+++ b/srcpos.c
@@ -244,12 +244,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,
--
2.7.4
next prev parent reply other threads:[~2018-02-02 20:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 20:41 [PATCH 0/3 v4] annotations Julia Lawall
[not found] ` <1517604110-790-1-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2018-02-02 20:41 ` Julia Lawall [this message]
2018-02-02 20:41 ` [PATCH 2/3 v4] annotations: add positions Julia Lawall
2018-02-02 20:41 ` [PATCH 3/3 v4] annotations: add the annotation functionality 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=1517604110-790-2-git-send-email-Julia.Lawall@lip6.fr \
--to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.