[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fwrite.c bugfix




Fwrite is supposed to return the number of items written.
The original version returned -1 on complete success.
If I read the man page correctly, the following patch should fix it.

--- /tmp/yaboot-1.99.x/lib/libc/stdio/fwrite.c	2003-03-08 22:57:37.000000000 
-0800
+++ stdio/fwrite.c	2003-07-10 17:30:26.000000000 -0700
@@ -32,14 +32,14 @@
 	  ret = write(fileno(fp), buf, size);
 	  if (ret == -1) {
 	       fp->error |= _STDIO_ERROR;
-	       return count-bwrote;
+	       return bwrote;
 	  } else if ((size_t)ret != size) {
 	       fp->error |= _STDIO_EOF;
-	       return count-bwrote;
+	       return bwrote;
 	  } else {
 	       bwrote++;
 	       buf += ret;
 	  }
      }
-     return count;
+     return bwrote;
 }

-- 
Remco Treffkorn (RT445)
HAM DC2XT
remco@rvt.com   (831) 685-1201