summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2005-12-27 04:33:31 +0000
committertedu <tedu@openbsd.org>2005-12-27 04:33:31 +0000
commita9ba38d6f22772a3c30e3c2cefee3b6349badea9 (patch)
tree5f4496f3edb1a413d8adc3d481aadeed57860542
parentclose can't really fail, don't bother checking (diff)
downloadwireguard-openbsd-a9ba38d6f22772a3c30e3c2cefee3b6349badea9.tar.xz
wireguard-openbsd-a9ba38d6f22772a3c30e3c2cefee3b6349badea9.zip
if an allocation function fails, err will print "cannot allocate memory"
for us, just add the name of the function
-rw-r--r--usr.bin/sdiff/edit.c4
-rw-r--r--usr.bin/sdiff/sdiff.c12
2 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/sdiff/edit.c b/usr.bin/sdiff/edit.c
index 5fe975be442..25b0db80904 100644
--- a/usr.bin/sdiff/edit.c
+++ b/usr.bin/sdiff/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.5 2005/12/27 04:31:06 tedu Exp $ */
+/* $OpenBSD: edit.c,v 1.6 2005/12/27 04:33:31 tedu Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
@@ -92,7 +92,7 @@ xmktemp(const char *s)
if (!(tmpdir = getenv("TMPDIR")))
tmpdir = "/tmp";
if (asprintf(&filename, "%s/sdiff.XXXXXXXXXX", tmpdir) == -1)
- err(2, "could not allocate memory");
+ err(2, "xmktemp");
/* Create temp file. */
if ((fd = mkstemp(filename)) == -1)
diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c
index b2525c2e47f..f7dbab64551 100644
--- a/usr.bin/sdiff/sdiff.c
+++ b/usr.bin/sdiff/sdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdiff.c,v 1.5 2005/12/27 04:31:06 tedu Exp $ */
+/* $OpenBSD: sdiff.c,v 1.6 2005/12/27 04:33:31 tedu Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
@@ -111,7 +111,7 @@ main(int argc, char **argv)
*/
argc_max = argc * 2;
if (!(diffargv = malloc(sizeof(char **) * argc_max)))
- err(2, "out of memory");
+ err(2, "main");
/* Add first argument, the program name. */
diffargv[diffargc++] = diffprog;
@@ -679,7 +679,7 @@ enqueue(const char *left, const char div, const char *right)
struct diffline *diffp;
if (!(diffp = malloc(sizeof(struct diffline))))
- err(2, "could not allocate memory");
+ err(2, "enqueue");
diffp->left = left;
diffp->div = div;
diffp->right = right;
@@ -730,7 +730,7 @@ astrcat(char **s, const char *append)
*/
if (!*s) {
if (!(*s = strdup(append)))
- err(2, "could not allocate memory");
+ err(2, "astrcat");
/* Keep track of string. */
offset = strlen(*s);
@@ -764,7 +764,7 @@ astrcat(char **s, const char *append)
/* Resize *s to fit new string. */
newstr = realloc(*s, newlen);
if (newstr == NULL)
- err(2, "could not allocate memory");
+ err(2, "astrcat");
*s = newstr;
/* Concatenate. */
@@ -949,7 +949,7 @@ printc(FILE *file1, size_t file1end, FILE *file2, size_t file2end)
/* Add to delete queue. */
if (!(linep = malloc(sizeof(struct fileline))))
- err(2, "could not allocate memory");
+ err(2, "printc");
linep->line = line1;
SIMPLEQ_INSERT_TAIL(&delqhead, linep, fileentries);
}