Bug 777292 - netwerk/: Don't treat number of bytes as an nsresult; r=bz
authorAryeh Gregor <ayg@aryeh.name>
Fri, 27 Jul 2012 17:03:25 +0300
changeset 100886 20549037ff3dcd7b1c5ef892bbad584939c460db
parent 100885 d64f195e9c43f2b0de92b2b0d1daa04f4e6077aa
child 100887 bc901f8f47324875886d6a1027dfa0c67340ab80
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbz
bugs777292
milestone17.0a1
Bug 777292 - netwerk/: Don't treat number of bytes as an nsresult; r=bz
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -149,20 +149,18 @@ nsHTTPCompressConv::OnDataAvailable(nsIR
                 mInpBuffer = (unsigned char *) nsMemory::Alloc(mInpBufferLen = streamLen);
 
             if (mOutBuffer == NULL)
                 mOutBuffer = (unsigned char *) nsMemory::Alloc(mOutBufferLen = streamLen * 3);
 
             if (mInpBuffer == NULL || mOutBuffer == NULL)
                 return NS_ERROR_OUT_OF_MEMORY;
 
-            iStr->Read((char *)mInpBuffer, streamLen, &rv);
-
-            if (NS_FAILED(rv))
-                return rv;
+            PRUint32 unused;
+            iStr->Read((char *)mInpBuffer, streamLen, &unused);
 
             if (mMode == HTTP_COMPRESS_DEFLATE)
             {
                 if (!mStreamInitialized)
                 {
                     memset(&d_stream, 0, sizeof (d_stream));
                 
                     if (inflateInit(&d_stream) != Z_OK)
@@ -358,31 +356,31 @@ nsHTTPCompressConv::do_OnDataAvailable(n
 #define COMMENT      0x10 /* bit 4 set: file comment present */
 #define RESERVED     0xE0 /* bits 5..7: reserved */
 
 static unsigned gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
 
 PRUint32
 nsHTTPCompressConv::check_header(nsIInputStream *iStr, PRUint32 streamLen, nsresult *rs)
 {
-    nsresult rv;
     enum  { GZIP_INIT = 0, GZIP_OS, GZIP_EXTRA0, GZIP_EXTRA1, GZIP_EXTRA2, GZIP_ORIG, GZIP_COMMENT, GZIP_CRC };
     char c;
 
     *rs = NS_OK;
 
     if (mCheckHeaderDone)
         return streamLen;
 
     while (streamLen)
     {
         switch (hMode)
         {
             case GZIP_INIT:
-                iStr->Read (&c, 1, &rv);
+                PRUint32 unused;
+                iStr->Read(&c, 1, &unused);
                 streamLen--;
                 
                 if (mSkipCount == 0 && ((unsigned)c & 0377) != gz_magic[0])
                 {
                     *rs = NS_ERROR_INVALID_CONTENT_ENCODING;
                     return 0;
                 }
 
@@ -408,71 +406,71 @@ nsHTTPCompressConv::check_header(nsIInpu
                         return 0;
                     }
                     hMode = GZIP_OS;
                     mSkipCount = 0;
                 }
                 break;
 
             case GZIP_OS:
-                iStr->Read(&c, 1, &rv);
+                iStr->Read(&c, 1, &unused);
                 streamLen--;
                 mSkipCount++;
 
                 if (mSkipCount == 6)
                     hMode = GZIP_EXTRA0;
                 break;
         
             case GZIP_EXTRA0:
                 if (mFlags & EXTRA_FIELD)
                 {
-                    iStr->Read(&c, 1, &rv);
+                    iStr->Read(&c, 1, &unused);
                     streamLen--;
                     mLen = (uInt) c & 0377;
                     hMode = GZIP_EXTRA1;
                 }
                 else
                     hMode = GZIP_ORIG;
                 break;
 
             case GZIP_EXTRA1:
-                iStr->Read(&c, 1, &rv);
+                iStr->Read(&c, 1, &unused);
                 streamLen--;
                 mLen = ((uInt) c & 0377) << 8;
                 mSkipCount = 0;
                 hMode = GZIP_EXTRA2;
                 break;
 
             case GZIP_EXTRA2:
                 if (mSkipCount == mLen)
                     hMode = GZIP_ORIG;
                 else
                 {
-                    iStr->Read(&c, 1, &rv);
+                    iStr->Read(&c, 1, &unused);
                     streamLen--;
                     mSkipCount++;
                 }
                 break;
 
             case GZIP_ORIG:
                 if (mFlags & ORIG_NAME)
                 {
-                    iStr->Read(&c, 1, &rv);
+                    iStr->Read(&c, 1, &unused);
                     streamLen--;
                     if (c == 0)
                         hMode = GZIP_COMMENT;
                 }
                 else
                     hMode = GZIP_COMMENT;
                 break;
 
             case GZIP_COMMENT:
                 if (mFlags & COMMENT)
                 {
-                    iStr->Read(&c, 1, &rv);
+                    iStr->Read(&c, 1, &unused);
                     streamLen--;
                     if (c == 0)
                     {
                         hMode = GZIP_CRC;
                         mSkipCount = 0;
                     }
                 }
                 else
@@ -480,17 +478,17 @@ nsHTTPCompressConv::check_header(nsIInpu
                     hMode = GZIP_CRC;
                     mSkipCount = 0;
                 }
                 break;
 
             case GZIP_CRC:
                 if (mFlags & HEAD_CRC)
                 {
-                    iStr->Read(&c, 1, &rv);
+                    iStr->Read(&c, 1, &unused);
                     streamLen--;
                     mSkipCount++;
                     if (mSkipCount == 2)
                     {
                         mCheckHeaderDone = true;
                         return streamLen;
                     }
                 }