summaryrefslogtreecommitdiffstats
path: root/usr.bin/diff3/diff3prog.c
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2008-02-27 18:10:05 +0000
committertobias <tobias@openbsd.org>2008-02-27 18:10:05 +0000
commit2e6633a8ffcb18d5d77f5bbe43cfaabaa81cd9c0 (patch)
tree604f67ea96972ae7a61b278f563cf7a9507c079d /usr.bin/diff3/diff3prog.c
parentreturn from tda_attach before registering the sensor task (diff)
downloadwireguard-openbsd-2e6633a8ffcb18d5d77f5bbe43cfaabaa81cd9c0.tar.xz
wireguard-openbsd-2e6633a8ffcb18d5d77f5bbe43cfaabaa81cd9c0.zip
Properly check if temporary files have been successfully opened. If not,
print error message on stderr (instead of stdout). ok millert, ray, tedu
Diffstat (limited to 'usr.bin/diff3/diff3prog.c')
-rw-r--r--usr.bin/diff3/diff3prog.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/diff3/diff3prog.c b/usr.bin/diff3/diff3prog.c
index c7456c52c74..73054824a5a 100644
--- a/usr.bin/diff3/diff3prog.c
+++ b/usr.bin/diff3/diff3prog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff3prog.c,v 1.9 2007/09/10 14:29:53 tobias Exp $ */
+/* $OpenBSD: diff3prog.c,v 1.10 2008/02/27 18:10:05 tobias Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -71,7 +71,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.9 2007/09/10 14:29:53 tobias Exp $";
+static const char rcsid[] = "$OpenBSD: diff3prog.c,v 1.10 2008/02/27 18:10:05 tobias Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -193,10 +193,8 @@ main(int argc, char **argv)
m = readin(argv[0], &d13);
n = readin(argv[1], &d23);
for (i = 0; i <= 2; i++) {
- if ((fp[i] = fopen(argv[i + 2], "r")) == NULL) {
- printf("diff3: can't open %s\n", argv[i + 2]);
- exit(EXIT_FAILURE);
- }
+ if ((fp[i] = fopen(argv[i + 2], "r")) == NULL)
+ err(EXIT_FAILURE, "can't open %s", argv[i + 2]);
}
merge(m, n);
exit(EXIT_SUCCESS);
@@ -215,6 +213,8 @@ readin(char *name, struct diff **dd)
char kind, *p;
fp[0] = fopen(name, "r");
+ if (fp[0] == NULL)
+ err(EXIT_FAILURE, "can't open %s", name);
for (i=0; (p = getchange(fp[0])); i++) {
if (i >= szchanges - 1)
increase();