]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Placate valgrind, wrt ./cp --sparse=always
authorJim Meyering <jim@meyering.net>
Thu, 22 Feb 2007 11:50:36 +0000 (12:50 +0100)
committerJim Meyering <jim@meyering.net>
Thu, 22 Feb 2007 11:50:36 +0000 (12:50 +0100)
* src/copy.c (copy_reg): Place the sentinel by setting a
full word's worth of bits, not just a single byte's worth.
This avoids a harmless (but distracting) case of memory being
used-uninitialized.

ChangeLog
src/copy.c

index d0d0fda947912cd750082b3e11c0d0926f08b23a..ec598a01193543067a735560d3641c3becba749f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-02-22  Jim Meyering  <jim@meyering.net>
+
+       Placate valgrind, wrt ./cp --sparse=always
+       * src/copy.c (copy_reg): Place the sentinel by setting a
+       full word's worth of bits, not just a single byte's worth.
+       This avoids a harmless (but distracting) case of memory being
+       used-uninitialized.
+
 2007-02-21  Jim Meyering  <jim@meyering.net>
 
        * tests/misc/date: Remove vestigial use of Data::Dumper.
index a3489c399b758fa8964a92b7322cded95a0b763c..f0c6539b7f50e42f97ce436fca8d8dfbae3cf9f6 100644 (file)
@@ -430,7 +430,8 @@ copy_reg (char const *src_name, char const *dst_name,
            {
              char *cp;
 
-             buf[n_read] = 1;  /* Sentinel to stop loop.  */
+             wp = (word *) (buf + n_read);
+             *wp = 1;  /* Sentinel to stop loop.  */
 
              /* Find first nonzero *word*, or the word with the sentinel.  */