Skip to contentSkip to conversation

ntfs3: avoid another -Wmaybe-uninitialized warning

PATCH Applied Arnd Bergmann 2 participants 2 messages May 15 – May 28 NTFS3 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntfs3: avoid another -Wmaybe-uninitialized warning

From: Arnd Bergmann <[email protected]>

The ntfs3 specific -Wmaybe-uninitialized flag found one more false-postive, this time with gcc-10 on s390:

fs/ntfs3/frecord.c: In function 'ni_expand_list':
fs/ntfs3/frecord.c:1370:16: error: 'ins_attr' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Add an explicit NULL pointer check before using the pointer, and initialize it to NULL.

Fixes 48d9b57b169f ("fs/ntfs3: add a subset of W=1 warnings for stricter checks")
---
 fs/ntfs3/frecord.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ntfs3/frecord.c +2 -2
index 7b035da63c12..d2c0b836b1bd 100644
@@ -1330,7 +1330,7 @@ int ni_expand_list(struct ntfs_inode *ni)
 {
 	int err = 0;
 	u32 asize, done = 0;
-	struct ATTRIB *attr, *ins_attr;
+	struct ATTRIB *attr, *ins_attr = NULL;
 	struct ATTR_LIST_ENTRY *le;
 	bool is_mft = ni->mi.rno == MFT_REC_MFT;
 	struct MFT_REF ref;
@@ -1363,7 +1363,7 @@ int ni_expand_list(struct ntfs_inode *ni)
 				      le16_to_cpu(attr->name_off), true,
 				      &ins_attr, NULL, NULL);
 
-		if (err)
+		if (err || !ins_attr)
 			goto out;
 
 		memcpy(ins_attr, attr, asize);
Signature · 1 line
2.39.5
maintainer Applied
#1 lore raw
Quoted 31 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

The ntfs3 specific -Wmaybe-uninitialized flag found one more false-postive, this time with gcc-10 on s390:

fs/ntfs3/frecord.c: In function 'ni_expand_list':
fs/ntfs3/frecord.c:1370:16: error: 'ins_attr' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Add an explicit NULL pointer check before using the pointer, and initialize it to NULL.

Fixes 48d9b57b169f ("fs/ntfs3: add a subset of W=1 warnings for stricter checks")
---
  fs/ntfs3/frecord.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/ntfs3/frecord.c +1 -1
index 7b035da63c12..d2c0b836b1bd 100644
@@ -1330,7 +1330,7 @@ int ni_expand_list(struct ntfs_inode *ni)
  {
  	int err = 0;
  	u32 asize, done = 0;
-	struct ATTRIB *attr, *ins_attr;
+	struct ATTRIB *attr, *ins_attr = NULL;
  	struct ATTR_LIST_ENTRY *le;
  	bool is_mft = ni->mi.rno == MFT_REC_MFT;
  	struct MFT_REF ref;

fs/ntfs3/frecord.c int ni_expand_list(struct ntfs_inode *ni) · line 1369

Quoted 8 lines
fs/ntfs3/frecord.c +1 -1
@@ -1363,7 +1363,7 @@ int ni_expand_list(struct ntfs_inode *ni)
  				      le16_to_cpu(attr->name_off), true,
  				      &ins_attr, NULL, NULL);
 
-		if (err)
+		if (err || !ins_attr)
  			goto out;
 
  		memcpy(ins_attr, attr, asize);

Hello,

Applied, thanks for the patch.

Regards,
Konstantin