[svn:parrot] r44712 - trunk/src/io

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Mar 6 22:38:39 UTC 2010


Author: chromatic
Date: Sat Mar  6 22:38:34 2010
New Revision: 44712
URL: https://trac.parrot.org/parrot/changeset/44712

Log:
[IO] Worked around a flaw in the way we use C's type system to tell static
analysis tools that "Yes, this parameter cannot be negative here at all in any
fashion, don't worry!"  This should finally fix Coverity CID #169.

Modified:
   trunk/src/io/buffer.c

Modified: trunk/src/io/buffer.c
==============================================================================
--- trunk/src/io/buffer.c	Sat Mar  6 22:28:25 2010	(r44711)
+++ trunk/src/io/buffer.c	Sat Mar  6 22:38:34 2010	(r44712)
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 2001-2009, Parrot Foundation.
+Copyright (C) 2001-2010, Parrot Foundation.
 $Id$
 
 =head1 NAME
@@ -357,9 +357,12 @@
         }
 
         got = Parrot_io_fill_readbuf(interp, filehandle);
-        len = (len < got)
-            ? len
-            : (got > 0) ? got : 0;
+
+        /* got is never < 0, but C's type system can't tell */
+        if (got < 0)
+            got = 0;
+
+        len = (len < got) ? len : got;
     }
 
     /* read from the read_buffer */


More information about the parrot-commits mailing list