summaryrefslogtreecommitdiff
path: root/usr.bin/sort
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2015-03-30 19:59:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2015-03-30 19:59:08 +0000
commit717bd37ece5cbd0618be9d3849b315176c775c5f (patch)
tree2e64531b31c89da9655f86913eca65f6c4289872 /usr.bin/sort
parent372431faaf47acdffd7f206b484d73aba84bcafb (diff)
Use sort_asprintf()
Diffstat (limited to 'usr.bin/sort')
-rw-r--r--usr.bin/sort/file.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c
index a70b2fa3e53..36d261ee893 100644
--- a/usr.bin/sort/file.c
+++ b/usr.bin/sort/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.3 2015/03/20 00:26:38 millert Exp $ */
+/* $OpenBSD: file.c,v 1.4 2015/03/30 19:59:07 millert Exp $ */
/*-
* Copyright (C) 2009 Gabor Kovesdan <gabor@FreeBSD.org>
@@ -172,10 +172,8 @@ new_tmp_file_name(void)
char *ret;
int len;
- len = asprintf(&ret, "%s/%s%d.%lu", tmpdir, fn, (int)getpid(),
+ len = sort_asprintf(&ret, "%s/%s%d.%lu", tmpdir, fn, (int)getpid(),
(unsigned long)(tfcounter++));
- if (len == -1)
- err(2, NULL);
tmp_file_atexit(ret);
return ret;
}
@@ -528,17 +526,14 @@ openfile(const char *fn, const char *mode)
fflush(stdout);
if (mode[0] == 'r')
- len = asprintf(&cmd, "cat %s | %s -d",
+ len = sort_asprintf(&cmd, "cat %s | %s -d",
fn, compress_program);
else if (mode[0] == 'w')
- len = asprintf(&cmd, "%s > %s",
+ len = sort_asprintf(&cmd, "%s > %s",
compress_program, fn);
else
err(2, "Wrong file mode");
- if (len == -1)
- err(2, NULL);
-
if ((file = popen(cmd, mode)) == NULL)
err(2, NULL);