summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorlum <lum@cvs.openbsd.org>2011-08-31 08:58:30 +0000
committerlum <lum@cvs.openbsd.org>2011-08-31 08:58:30 +0000
commitd447484181c8a0caab0c41465a089b622ae32deb (patch)
tree6d810b712f981a21a93850ad4107cc72d4d0fd7c /usr.bin
parent173502af83b27f7a05a672480065cab2eddfade6 (diff)
On a file write fail:
1. return an error value 2. show an error message From Loganaden Velvindron with suggestion from millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/file.c10
-rw-r--r--usr.bin/mg/fileio.c10
2 files changed, 11 insertions, 9 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index df1c81fadb8..210c404b23b 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.75 2011/01/23 00:45:03 kjell Exp $ */
+/* $OpenBSD: file.c,v 1.76 2011/08/31 08:58:29 lum Exp $ */
/* This file is in the public domain. */
@@ -414,7 +414,7 @@ retry:
}
endoffile:
/* ignore errors */
- ffclose(NULL);
+ (void)ffclose(NULL);
/* don't zap an error */
if (s == FIOEOF) {
if (nline == 1)
@@ -635,9 +635,11 @@ writeout(struct buffer *bp, char *fn)
s = ffclose(bp);
if (s == FIOSUC)
ewprintf("Wrote %s", fn);
- } else
- /* ignore close error if it is a write error */
+ } else {
+ /* print a message indicating write error */
(void)ffclose(bp);
+ ewprintf("Unable to write %s", fn);
+ }
(void)fupdstat(bp);
return (s == FIOSUC);
}
diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c
index 58febf4ce75..747eed69fd3 100644
--- a/usr.bin/mg/fileio.c
+++ b/usr.bin/mg/fileio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fileio.c,v 1.84 2011/01/21 19:10:13 kjell Exp $ */
+/* $OpenBSD: fileio.c,v 1.85 2011/08/31 08:58:29 lum Exp $ */
/* This file is in the public domain. */
@@ -77,7 +77,7 @@ fupdstat(struct buffer *bp)
return (FIOERR);
}
ffstat(bp);
- ffclose(bp);
+ (void)ffclose(bp);
return (FIOSUC);
}
@@ -122,14 +122,14 @@ ffwopen(const char *fn, struct buffer *bp)
/*
* Close a file.
- * XXX - Should look at the status.
*/
/* ARGSUSED */
int
ffclose(struct buffer *bp)
{
- (void) fclose(ffp);
- return (FIOSUC);
+ if (fclose(ffp) == 0)
+ return (FIOSUC);
+ return (FIOERR);
}
/*