aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-03-23 11:06:13 -0400
committerJan Kara <jack@suse.cz>2017-03-23 14:22:15 -0400
commitab4949640d6674b617b314ad3c2c00353304bab9 (patch)
treeef43d1918e6244b6cb0737f3e44a15384dc37d52
parent093b995e3b55a0ae0670226ddfcb05bfbf0099ae (diff)
reiserfs: avoid a -Wmaybe-uninitialized warning
The latest gcc-7.0.1 snapshot warns about an unintialized variable use: In file included from fs/reiserfs/lbalance.c:8:0: fs/reiserfs/lbalance.c: In function 'leaf_item_bottle.isra.3': fs/reiserfs/reiserfs.h:1279:13: error: '*((void *)&n_ih+8).v' may be used uninitialized in this function [-Werror=maybe-uninitialized] v2->v = (v2->v & cpu_to_le64(15ULL << 60)) | cpu_to_le64(offset); ~~^~~ fs/reiserfs/reiserfs.h:1279:13: error: '*((void *)&n_ih+8).v' may be used uninitialized in this function [-Werror=maybe-uninitialized] v2->v = (v2->v & cpu_to_le64(15ULL << 60)) | cpu_to_le64(offset); This happens because the offset/type pair that is stored in ih.key.u.k_offset_v2 is actually uninitialized when we call set_le_ih_k_offset() and set_le_ih_k_type(). After we have called both, all data is correct, but the first of the two reads uninitialized data for the type field and writes it back before it gets overwritten. This works around the warning by initializing the k_offset_v2 through the slightly larger memcpy(). [JK: Remove now unused define and make it obvious we initialize the key] Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/reiserfs/lbalance.c2
-rw-r--r--fs/reiserfs/reiserfs.h1
2 files changed, 1 insertions, 2 deletions
diff --git a/fs/reiserfs/lbalance.c b/fs/reiserfs/lbalance.c
index 249594a821e0..f5cebd70d903 100644
--- a/fs/reiserfs/lbalance.c
+++ b/fs/reiserfs/lbalance.c
@@ -475,7 +475,7 @@ static void leaf_item_bottle(struct buffer_info *dest_bi,
475 * 'cpy_bytes'; create new item header; 475 * 'cpy_bytes'; create new item header;
476 * n_ih = new item_header; 476 * n_ih = new item_header;
477 */ 477 */
478 memcpy(&n_ih, ih, SHORT_KEY_SIZE); 478 memcpy(&n_ih.ih_key, &ih->ih_key, KEY_SIZE);
479 479
480 /* Endian safe, both le */ 480 /* Endian safe, both le */
481 n_ih.ih_version = ih->ih_version; 481 n_ih.ih_version = ih->ih_version;
diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
index 2adcde137c3f..5dcf3ab83886 100644
--- a/fs/reiserfs/reiserfs.h
+++ b/fs/reiserfs/reiserfs.h
@@ -1326,7 +1326,6 @@ struct cpu_key {
1326#define KEY_NOT_FOUND 0 1326#define KEY_NOT_FOUND 0
1327 1327
1328#define KEY_SIZE (sizeof(struct reiserfs_key)) 1328#define KEY_SIZE (sizeof(struct reiserfs_key))
1329#define SHORT_KEY_SIZE (sizeof (__u32) + sizeof (__u32))
1330 1329
1331/* return values for search_by_key and clones */ 1330/* return values for search_by_key and clones */
1332#define ITEM_FOUND 1 1331#define ITEM_FOUND 1