Usermode/libc - Fixed fflush not handling errors
authorJohn Hodge <[email protected]>
Sat, 7 Sep 2013 15:02:41 +0000 (23:02 +0800)
committerJohn Hodge <[email protected]>
Sat, 7 Sep 2013 15:02:41 +0000 (23:02 +0800)
Usermode/Libraries/libc.so_src/stdio.c

index 7082f23..315f698 100644 (file)
@@ -300,9 +300,12 @@ int _fflush_int(FILE *fp)
        case FILE_FLAG_MODE_APPEND:\r
                _SysSeek(fp->FD, fp->BufferOfs, SEEK_SET);\r
                len = _SysWrite(fp->FD, fp->Buffer, fp->BufferPos);\r
-               if( len < fp->BufferPos )\r
+               if( len != fp->BufferPos )\r
                        ret = 1;\r
-               fp->BufferPos -= len;\r
+               if( len <= fp->BufferPos )\r
+               {\r
+                       fp->BufferPos -= len;\r
+               }\r
                fp->BufferOfs = _SysTell(fp->FD);\r
                break;\r
                \r
@@ -312,7 +315,13 @@ int _fflush_int(FILE *fp)
                len = _SysWrite(fp->FD, fp->Buffer, fp->BufferPos);\r
                if( len != fp->BufferPos )\r
                        ret = 1;\r
-               fp->BufferPos -= len;\r
+               if( len <= fp->BufferPos )\r
+               {\r
+                       fp->BufferPos -= len;\r
+               }\r
+               //else {\r
+               //      _SysDebug("Flush of %i failed, %s", fp->FD, strerror(errno));\r
+               //}\r
                break;\r
        default:\r
                break;\r

UCC git Repository :: git.ucc.asn.au