diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-02-27 18:10:06 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-02-27 18:10:06 +0000 |
commit | b8441ef08365d11d33c7829aebc41d18df6cbfc7 (patch) | |
tree | a83a975a892aea908036f96ca1e8a1877d443742 /usr.bin | |
parent | 6ac474f2e3ec1fc1f1d1d567c13c2e7085d06a5d (diff) |
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')
-rw-r--r-- | usr.bin/diff3/diff3prog.c | 12 |
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(); |