Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint lint: make xasprintf simpler
details: https://anonhg.NetBSD.org/src/rev/c8700b9b361f
branches: trunk
changeset: 984956:c8700b9b361f
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Aug 01 18:13:53 2021 +0000
description:
lint: make xasprintf simpler
No functional change.
diffstat:
usr.bin/xlint/common/externs.h | 4 ++--
usr.bin/xlint/common/mem.c | 15 ++++++++-------
usr.bin/xlint/xlint/xlint.c | 8 ++++----
3 files changed, 14 insertions(+), 13 deletions(-)
diffs (97 lines):
diff -r fc3215ca2687 -r c8700b9b361f usr.bin/xlint/common/externs.h
--- a/usr.bin/xlint/common/externs.h Sun Aug 01 18:07:35 2021 +0000
+++ b/usr.bin/xlint/common/externs.h Sun Aug 01 18:13:53 2021 +0000
@@ -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 *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
diff -r fc3215ca2687 -r c8700b9b361f usr.bin/xlint/common/mem.c
--- a/usr.bin/xlint/common/mem.c Sun Aug 01 18:07:35 2021 +0000
+++ b/usr.bin/xlint/common/mem.c Sun Aug 01 18:13:53 2021 +0000
@@ -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 @@
free(p);
nomem();
}
- p = n;
- return p;
+ return n;
}
char *
@@ -96,15 +95,17 @@
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;
}
diff -r fc3215ca2687 -r c8700b9b361f usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c Sun Aug 01 18:07:35 2021 +0000
+++ b/usr.bin/xlint/xlint/xlint.c Sun Aug 01 18:13:53 2021 +0000
@@ -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 @@
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");
Home |
Main Index |
Thread Index |
Old Index