lint: make xasprintf simpler

No functional change.
This commit is contained in:
rillig 2021-08-01 18:13:53 +00:00
parent cd66f68dee
commit 86a595a37f
3 changed files with 14 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: externs.h,v 1.16 2021/08/01 18:07:35 rillig Exp $ */
/* $NetBSD: externs.h,v 1.17 2021/08/01 18:13:53 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -57,7 +57,7 @@ extern void *xmalloc(size_t);
extern void *xcalloc(size_t, size_t);
extern void *xrealloc(void *, size_t);
extern char *xstrdup(const char *);
extern void xasprintf(char **, const char *, ...) __printflike(2, 3);
extern char *xasprintf(const char *, ...) __printflike(1, 2);
/*
* emit.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $ */
/* $NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $");
__RCSID("$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $");
#endif
#include <stdarg.h>
@ -82,8 +82,7 @@ xrealloc(void *p, size_t s)
free(p);
nomem();
}
p = n;
return p;
return n;
}
char *
@ -96,15 +95,17 @@ xstrdup(const char *s)
return s2;
}
void
xasprintf(char **buf, const char *fmt, ...)
char *
xasprintf(const char *fmt, ...)
{
char *str;
int e;
va_list ap;
va_start(ap, fmt);
e = vasprintf(buf, fmt, ap);
e = vasprintf(&str, fmt, ap);
va_end(ap);
if (e < 0)
nomem();
return str;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: xlint.c,v 1.63 2021/05/02 21:05:42 rillig Exp $ */
/* $NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: xlint.c,v 1.63 2021/05/02 21:05:42 rillig Exp $");
__RCSID("$NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $");
#endif
#include <sys/param.h>
@ -696,9 +696,9 @@ fname(const char *name)
return;
}
len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn);
xasprintf(&ofn, "%.*s.ln", (int)len, bn);
ofn = xasprintf("%.*s.ln", (int)len, bn);
} else {
xasprintf(&ofn, "%slint1.XXXXXX", tmpdir);
ofn = xasprintf("%slint1.XXXXXX", tmpdir);
fd = mkstemp(ofn);
if (fd == -1) {
warn("can't make temp");