summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/buf.c
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2005-12-20 17:55:11 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2005-12-20 17:55:11 +0000
commit41284a9ec5c2b50b0db908cb2f5412d1b9f00662 (patch)
treeaf48a89fda76e4f610c1e1af15674c80a85dbce4 /usr.bin/cvs/buf.c
parentd1390a476986dd9c145fa918987f7bf68eb782c3 (diff)
fix use of fatal() from previous commit;
temporary files were left behind if cvs_buf_write_* functions failed; OK joris@.
Diffstat (limited to 'usr.bin/cvs/buf.c')
-rw-r--r--usr.bin/cvs/buf.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c
index 28f429e5381..069c11f4b7b 100644
--- a/usr.bin/cvs/buf.c
+++ b/usr.bin/cvs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.21 2005/12/20 17:11:48 xsa Exp $ */
+/* $OpenBSD: buf.c,v 1.22 2005/12/20 17:55:10 xsa Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -368,7 +368,7 @@ cvs_buf_write_fd(BUF *b, int fd)
if (ret == -1) {
if (errno == EINTR || errno == EAGAIN)
continue;
- fatal("cvs_buf_write_fd failed");
+ return (-1);
}
len -= (size_t)ret;
@@ -388,19 +388,18 @@ cvs_buf_write_fd(BUF *b, int fd)
int
cvs_buf_write(BUF *b, const char *path, mode_t mode)
{
- int ret, fd;
+ int fd;
if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1)
fatal("open: `%s': %s", path, strerror(errno));
- ret = cvs_buf_write_fd(b, fd);
- if (ret == -1) {
- cvs_log(LP_ERRNO, "failed to write to file `%s'", path);
+ if (cvs_buf_write_fd(b, fd) == -1) {
(void)unlink(path);
+ fatal("cvs_buf_write: cvs_buf_write_fd: `%s'", path);
}
(void)close(fd);
- return (ret);
+ return (0);
}
/*
@@ -414,20 +413,18 @@ cvs_buf_write(BUF *b, const char *path, mode_t mode)
int
cvs_buf_write_stmp(BUF *b, char *template, mode_t mode)
{
- int ret, fd;
+ int fd;
if ((fd = mkstemp(template)) == -1)
fatal("mkstemp: `%s': %s", template, strerror(errno));
- ret = cvs_buf_write_fd(b, fd);
- if (ret == -1) {
- cvs_log(LP_ERRNO, "failed to write to temp file `%s'",
- template);
+ if (cvs_buf_write_fd(b, fd) == -1) {
(void)unlink(template);
+ fatal("cvs_buf_write_stmp: cvs_buf_write_fd: `%s'", template);
}
(void)close(fd);
- return (ret);
+ return (0);
}
/*