DragonFly submit List (threaded) for 2004-03
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: set errno for fvprintf, fvwrite (wbuf)
me wrote:
> attached patch fixes this for a few more more libc functions.
> i added a comment, that indicates, why this errno and not a more logical
> one is chosen. (according to followup of [1])
i really dont know, why i missed #include <errno.h> in wbuf.c...
well, updated diff attached.
~ibotty
Index: lib/libc/stdio/fvwrite.c
===================================================================
RCS file: /home/src/dcvs/src/lib/libc/stdio/fvwrite.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 fvwrite.c
--- lib/libc/stdio/fvwrite.c 17 Jun 2003 04:26:46 -0000 1.2
+++ lib/libc/stdio/fvwrite.c 3 Mar 2004 16:48:46 -0000
@@ -41,6 +41,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "local.h"
#include "fvwrite.h"
@@ -51,22 +52,23 @@
* to the three different kinds of output buffering is handled here.
*/
int
-__sfvwrite(fp, uio)
- register FILE *fp;
- register struct __suio *uio;
+__sfvwrite(FILE *fp, struct __suio *uio)
{
- register size_t len;
- register char *p;
- register struct __siov *iov;
- register int w, s;
+ size_t len;
+ char *p;
+ struct __siov *iov;
+ int w, s;
char *nl;
int nlknown, nldist;
if ((len = uio->uio_resid) == 0)
return (0);
/* make sure we can write */
- if (cantwrite(fp))
+ if (cantwrite(fp)) {
+ /* use EBADF, not EACCES, because of POSIX */
+ errno = EBADF;
return (EOF);
+ }
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
Index: lib/libc/stdio/vfprintf.c
===================================================================
RCS file: /home/src/dcvs/src/lib/libc/stdio/vfprintf.c,v
retrieving revision 1.3
diff -u -3 -p -r1.3 vfprintf.c
--- lib/libc/stdio/vfprintf.c 12 Nov 2003 20:21:25 -0000 1.3
+++ lib/libc/stdio/vfprintf.c 3 Mar 2004 16:48:10 -0000
@@ -50,6 +50,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#if __STDC__
#include <stdarg.h>
@@ -408,6 +409,8 @@ vfprintf(FILE *fp, const char *fmt0, va_
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
if (cantwrite(fp)) {
FUNLOCKFILE(fp);
+ /* EBADF instead of EACCES because of POSIX */
+ errno = EBADF;
return (EOF);
}
Index: lib/libc/stdio/wbuf.c
===================================================================
RCS file: /home/src/dcvs/src/lib/libc/stdio/wbuf.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 wbuf.c
--- lib/libc/stdio/wbuf.c 17 Jun 2003 04:26:46 -0000 1.2
+++ lib/libc/stdio/wbuf.c 3 Mar 2004 23:21:02 -0000
@@ -39,6 +39,7 @@
*/
#include <stdio.h>
+#include <errno.h>
#include "local.h"
/*
@@ -47,11 +48,9 @@
* or if c=='\n' and the file is line buffered.
*/
int
-__swbuf(c, fp)
- register int c;
- register FILE *fp;
+__swbuf(int c, FILE *fp)
{
- register int n;
+ int n;
/*
* In case we cannot write, or longjmp takes us out early,
@@ -61,8 +60,11 @@ __swbuf(c, fp)
* calls might wrap _w from negative to positive.
*/
fp->_w = fp->_lbfsize;
- if (cantwrite(fp))
+ if (cantwrite(fp)) {
+ /* EBADF instead of EACCES because of POSIX */
+ errno = EBADF;
return (EOF);
+ }
c = (unsigned char)c;
/*
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]