[svn:parrot] r36802 - trunk/src/packfile

chromatic at svn.parrot.org chromatic at svn.parrot.org
Mon Feb 16 21:19:51 UTC 2009


Author: chromatic
Date: Mon Feb 16 21:19:50 2009
New Revision: 36802
URL: https://trac.parrot.org/parrot/changeset/36802

Log:
[src] Fixed compiler warnings about memory overflows during memcpy().  I'm not
sure these are correct, but they don't warn and all tests pass.  If they're
still wrong, that's because the code assumes too much.

Modified:
   trunk/src/packfile/pf_items.c

Modified: trunk/src/packfile/pf_items.c
==============================================================================
--- trunk/src/packfile/pf_items.c	Mon Feb 16 20:43:37 2009	(r36801)
+++ trunk/src/packfile/pf_items.c	Mon Feb 16 21:19:50 2009	(r36802)
@@ -358,7 +358,7 @@
 {
     ASSERT_ARGS(cvt_num16_num8)
     long double d;
-    memcpy(&d, src, 16);
+    memcpy(&d, src, sizeof (unsigned char));
     *dest = (double)d; /* TODO: test */
 }
 
@@ -379,7 +379,7 @@
 {
     ASSERT_ARGS(cvt_num8_num16)
     double d;
-    memcpy(&d, src, 8);
+    memcpy(&d, src, sizeof (unsigned char));
     *dest = (long double)d; /* TODO: test */
 }
 
@@ -400,7 +400,7 @@
 {
     ASSERT_ARGS(cvt_num8_num16)
     double d;
-    memcpy(&d, src, 8);
+    memcpy(&d, src, sizeof (unsigned char));
     *dest = (long double)d; /* TODO: test */
 }
 
@@ -946,14 +946,13 @@
 {
     ASSERT_ARGS(PF_fetch_number)
     /* When we have alignment all squared away we don't need
-     * to use memcpy() for native byteorder.
-     */
+     * to use memcpy() for native byteorder.  */
     FLOATVAL f;
     double d;
     if (!pf || !pf->fetch_nv) {
         TRACE_PRINTF(("PF_fetch_number: Native [%d bytes]\n",
                       sizeof (FLOATVAL)));
-        memcpy(&f, (const char*)*stream, sizeof (FLOATVAL));
+        memcpy(&f, (const char *)*stream, sizeof (FLOATVAL));
         TRACE_PRINTF_VAL(("PF_fetch_number: %f\n", f));
         (*stream) += (sizeof (FLOATVAL) + sizeof (opcode_t) - 1)/
             sizeof (opcode_t);


More information about the parrot-commits mailing list