summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2005-12-27 04:31:07 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2005-12-27 04:31:07 +0000
commit8e3ad14e29a475bb677e961000c400b1a59ab9f1 (patch)
tree74c1260bd0ac5dd5f1c9383cb9adb2c448c4db6c
parentcacce888d68a00565b85a2cb5f1f7fa03eae9de0 (diff)
close can't really fail, don't bother checking
-rw-r--r--usr.bin/sdiff/edit.c17
-rw-r--r--usr.bin/sdiff/sdiff.c20
2 files changed, 11 insertions, 26 deletions
diff --git a/usr.bin/sdiff/edit.c b/usr.bin/sdiff/edit.c
index ce050846d91..5fe975be442 100644
--- a/usr.bin/sdiff/edit.c
+++ b/usr.bin/sdiff/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.4 2005/12/27 04:28:08 tedu Exp $ */
+/* $OpenBSD: edit.c,v 1.5 2005/12/27 04:31:06 tedu Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
@@ -100,11 +100,7 @@ xmktemp(const char *s)
/* If we don't write anything to the file, just close. */
if (s == NULL) {
- if (close(fd)) {
- warn("could not close %s", filename);
- cleanup(filename);
- /* NOTREACHED */
- }
+ close(fd);
return (filename);
}
@@ -124,11 +120,7 @@ xmktemp(const char *s)
}
/* Close temp file. */
- if (fclose(file)) {
- warn("could not close %s", filename);
- cleanup(filename);
- /* NOTREACHED */
- }
+ fclose(file);
return (filename);
}
@@ -240,8 +232,7 @@ RIGHT:
/* We've reached the end of the temporary file, so remove it. */
if (unlink(filename))
warn("could not delete: %s", filename);
- if (fclose(file))
- warn("could not close: %s", filename);
+ fclose(file);
/* filename was malloc()ed in xmktemp(). */
free((void *)filename);
diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c
index 57d26dcc558..b2525c2e47f 100644
--- a/usr.bin/sdiff/sdiff.c
+++ b/usr.bin/sdiff/sdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdiff.c,v 1.4 2005/12/27 04:28:08 tedu Exp $ */
+/* $OpenBSD: sdiff.c,v 1.5 2005/12/27 04:31:06 tedu Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
@@ -214,13 +214,11 @@ main(int argc, char **argv)
case 0:
/* child */
/* We don't read from the pipe. */
- if (close(fd[0]))
- err(2, "child could not close pipe input");
+ close(fd[0]);
if (dup2(fd[1], STDOUT_FILENO) == -1)
err(2, "child could not duplicate descriptor");
/* Free unused descriptor. */
- if (close(fd[1]))
- err(2, "child could not close pipe output");
+ close(fd[1]);
execvp(diffprog, (char *const *)diffargv);
err(2, "could not execute diff: %s", diffprog);
@@ -230,8 +228,7 @@ main(int argc, char **argv)
/* parent */
/* We don't write to the pipe. */
- if (close(fd[1]))
- err(2, "could not close pipe output");
+ close(fd[1]);
/* Open pipe to diff command. */
if ((difffile = fdopen(fd[0], "r")) == NULL)
@@ -249,8 +246,7 @@ main(int argc, char **argv)
/* Read and parse diff output. */
while (parsecmd(difffile, origfile) != EOF)
;
- if (fclose(difffile))
- err(2, "could not close diff pipe");
+ fclose(difffile);
/* Wait for diff to exit. */
if (waitpid(pid, &status, 0) == -1 || !WIFEXITED(status) ||
@@ -260,8 +256,7 @@ main(int argc, char **argv)
/* No more diffs, so print common lines. */
while ((cmd = xfgets(origfile)))
enqueue(cmd, ' ', lflag ? NULL : cmd);
- if (fclose(origfile))
- err(2, "could not close file1: %s", argv[0]);
+ fclose(origfile);
/* Process unmodified lines. */
processq();
@@ -430,8 +425,7 @@ PROMPT:
* should quit.
*/
QUIT:
- if (fclose(outfile))
- err(2, "could not close output file");
+ fclose(outfile);
exit(0);
}