[Crosstoolchain-logs] [device-tree-compiler] 180/198: Use xasprintf() in srcpos

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:07:07 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.4.x
in repository device-tree-compiler.

commit d71d25d76012896521f937bf0c69f27b1a37cdc2
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Wed May 25 15:15:36 2016 +1000

    Use xasprintf() in srcpos
    
    Now that we have an xasprintf() helper function, use it to simplify the
    srcpos_string() implementation.
    
    Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 srcpos.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/srcpos.c b/srcpos.c
index f534c22..af7fb3c 100644
--- a/srcpos.c
+++ b/srcpos.c
@@ -266,26 +266,22 @@ srcpos_string(struct srcpos *pos)
 {
 	const char *fname = "<no-file>";
 	char *pos_str;
-	int rc;
 
 	if (pos)
 		fname = pos->file->name;
 
 
 	if (pos->first_line != pos->last_line)
-		rc = asprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
-			      pos->first_line, pos->first_column,
-			      pos->last_line, pos->last_column);
+		xasprintf(&pos_str, "%s:%d.%d-%d.%d", fname,
+			  pos->first_line, pos->first_column,
+			  pos->last_line, pos->last_column);
 	else if (pos->first_column != pos->last_column)
-		rc = asprintf(&pos_str, "%s:%d.%d-%d", fname,
-			      pos->first_line, pos->first_column,
-			      pos->last_column);
+		xasprintf(&pos_str, "%s:%d.%d-%d", fname,
+			  pos->first_line, pos->first_column,
+			  pos->last_column);
 	else
-		rc = asprintf(&pos_str, "%s:%d.%d", fname,
-			      pos->first_line, pos->first_column);
-
-	if (rc == -1)
-		die("Couldn't allocate in srcpos string");
+		xasprintf(&pos_str, "%s:%d.%d", fname,
+			  pos->first_line, pos->first_column);
 
 	return pos_str;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list