Skip to contentSkip to conversation

xfs: Silence bounds checking compiler warning

PATCH Superseded Maarten Lankhorst 1 participant 2 messages Jun 23, 2011 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: Silence bounds checking compiler warning

gcc with -Warray-bounds generates a false positive on this since xfs defines the struct with u8 name[1]; to be able to add a tag at the end.

---
 fs/xfs/xfs_dir2_block.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/xfs/xfs_dir2_block.c +1 -1
index 580d99c..09b4aed 100644
@@ -1148,7 +1148,7 @@ xfs_dir2_sf_to_block(
 		((char *)block + XFS_DIR2_DATA_DOTDOT_OFFSET);
 	dep->inumber = cpu_to_be64(xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent));
 	dep->namelen = 2;
-	dep->name[0] = dep->name[1] = '.';
+	dep->name[0] = ((__u8 *)dep->name)[1] = '.';
 	tagp = xfs_dir2_data_entry_tag_p(dep);
 	*tagp = cpu_to_be16((char *)dep - (char *)block);
 	xfs_dir2_data_log_entry(tp, bp, dep);
Signature · 8 lines
1.7.5.4



_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 14 lines · Maarten Lankhorst

gcc with -Warray-bounds generates a false positive on this since xfs defines the struct with u8 name[1]; to be able to add a tag at the end.

---
 fs/xfs/xfs_dir2_block.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/xfs/xfs_dir2_block.c +0 -0
index 580d99c..09b4aed 100644

fs/xfs/xfs_dir2_block.c xfs_dir2_sf_to_block( · line 1154

Quoted 8 lines
fs/xfs/xfs_dir2_block.c +1 -1
@@ -1148,7 +1148,7 @@ xfs_dir2_sf_to_block(
 		((char *)block + XFS_DIR2_DATA_DOTDOT_OFFSET);
 	dep->inumber = cpu_to_be64(xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent));
 	dep->namelen = 2;
-	dep->name[0] = dep->name[1] = '.';
+	dep->name[0] = ((__u8 *)dep->name)[1] = '.';
 	tagp = xfs_dir2_data_entry_tag_p(dep);
 	*tagp = cpu_to_be16((char *)dep - (char *)block);
 	xfs_dir2_data_log_entry(tp, bp, dep);

Oops, that still gives a warning, I used (u8*) first which works, but it seems the type conversion was what made it shut up. Is there any type I can cast __u8 to safely, or is memset preferred? gcc was too smart and saw through my __u8 cast.

~Maarten

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs