diff options
author | Jim Meyering <jim@meyering.net> | 2007-02-22 16:32:45 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-02-22 16:32:45 +0100 |
commit | c450b625b4351aa5ab87a4334f95b6a24f3a0022 (patch) | |
tree | feb4f2467437fc33c3c8e8ea3c539b106208ca25 /src | |
parent | f48ca7f500cd55e88f9fa24ec8ef74d6bed25a69 (diff) | |
download | coreutils-c450b625b4351aa5ab87a4334f95b6a24f3a0022.tar.xz |
Adjust preceding change not to perform an unaligned access.
* src/copy.c (copy_reg): Undo previous change. Instead, make
it clearer that we're using a single-byte sentinel, and
[lint]: Initialize uintptr_t-1 bytes after the sentinel.
Reported by Andreas Schwab.
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/copy.c b/src/copy.c index f0c6539b7..99e2ca40c 100644 --- a/src/copy.c +++ b/src/copy.c @@ -430,8 +430,17 @@ copy_reg (char const *src_name, char const *dst_name, { char *cp; - wp = (word *) (buf + n_read); - *wp = 1; /* Sentinel to stop loop. */ + /* Sentinel to stop loop. */ + buf[n_read] = '\1'; +#ifdef lint + /* Usually, buf[n_read] is not the byte just before a "word" + (aka uintptr_t) boundary. In that case, the word-oriented + test below (*wp++ == 0) would read some uninitialized bytes + after the sentinel. To avoid false-positive reports about + this condition (e.g., from a tool like valgrind), set the + remaining bytes -- to any value. */ + memset (buf + n_read + 1, 0, sizeof (word) - 1); +#endif /* Find first nonzero *word*, or the word with the sentinel. */ |