Author: chromatic
Date: Thu Dec  4 23:54:23 2008
New Revision: 33501

Modified:
   trunk/src/io/buffer.c

Log:
[IO] Made one more attempt (this time more verbose) to avoid signedness
assignment problems in Parrot_io_peek_buffer(), reported by Coverity Scan as
CID #148.

Modified: trunk/src/io/buffer.c
==============================================================================
--- trunk/src/io/buffer.c       (original)
+++ trunk/src/io/buffer.c       Thu Dec  4 23:54:23 2008
@@ -423,9 +423,14 @@
 
         /* Parrot_io_fill_readbuf() can return -1, but len should be positive 
*/
         got = Parrot_io_fill_readbuf(interp, filehandle);
-        len = (len < got)
-            ? len
-            : (got > 0) ? got : 0;
+
+        /* avoid signedness problems between size_t got and UINTVAL len */
+        if (len > got) {
+            if (got > 0)
+                len = (UINTVAL)got;
+            else
+                len = 0;
+        }
     }
 
     /* if we got any data, then copy out the next byte */

Reply via email to