[PATCH] WaE: extensions warnings fixed

David Ostrovsky David.Ostrovsky at gmx.de
Sat Apr 21 05:29:14 PDT 2012


---
 extensions/source/nsplugin/source/npshell.cxx |    6 ++++-
 extensions/source/scanner/sane.cxx            |   27 ++++++++++++++++++++++--
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/extensions/source/nsplugin/source/npshell.cxx b/extensions/source/nsplugin/source/npshell.cxx
index 81ce8fb..f6b4ea4 100644
--- a/extensions/source/nsplugin/source/npshell.cxx
+++ b/extensions/source/nsplugin/source/npshell.cxx
@@ -772,7 +772,11 @@ NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
 
                     break;
             }
-            write(fdDst, buffer, ret);
+            ssize_t written_bytes = write(fdDst, buffer, ret);
+            if (written_bytes == -1)
+            {
+                return;
+            }
         }
         close(fdSrc);
         close(fdDst);
diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
index aaefbf4..ca2cec18 100644
--- a/extensions/source/scanner/sane.cxx
+++ b/extensions/source/scanner/sane.cxx
@@ -524,11 +524,24 @@ static inline sal_uInt8 _ReadValue( FILE* fp, int depth )
         // e.g. UMAX Astra 1200S delivers 16 bit but in BIGENDIAN
         // against SANE documentation (xscanimage gets the same result
         // as we do
-        fread( &nWord, 1, 2, fp );
+        size_t items_read = fread( &nWord, 1, 2, fp );
+
+        // fread() does not distinguish between end-of-file and error, and callers
+        //   must use feof(3) and ferror(3) to determine which occurred.
+        if (items_read == 0)
+        {
+             // nothing todo?
+             // WaE is happy!
+        }
         return (sal_uInt8)( nWord / 256 );
     }
     sal_uInt8 nByte;
-    fread( &nByte, 1, 1, fp );
+    size_t items_read = fread( &nByte, 1, 1, fp );
+    if (items_read == 0)
+    {
+         // nothing todo?
+         // WaE is happy!
+    }
     return nByte;
 }
 
@@ -814,7 +827,15 @@ sal_Bool Sane::Start( BitmapTransporter& rBitmap )
                     ( eType == FrameStyle_Gray && aParams.depth == 8 )
                     )
                 {
-                    fread( pBuffer, 1, aParams.bytes_per_line, pFrame );
+                    size_t items_read = fread( pBuffer, 1, aParams.bytes_per_line, pFrame );
+                    
+                    // fread() does not distinguish between end-of-file and error, and callers
+                    //   must use feof(3) and ferror(3) to determine which occurred.
+                    if (items_read == 0)
+                    {
+                        // nothing todo?
+                        // WaE is happy!
+                    }
                     aConverter.Write( pBuffer, aParams.bytes_per_line );
                 }
                 else if( eType == FrameStyle_Gray )
-- 
1.7.5.4


--------------060301040609030503020007--


More information about the LibreOffice mailing list