Skip to contentSkip to conversation

gfs2: Silence gcc format-truncation warning

PATCH New Andreas Gruenbacher 2 participants 2 messages Aug 22, 2017 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Silence gcc format-truncation warning

Enlarge sd_fsname to be big enough for the longest long lock table name and an arbitrary journal number. This silences two -Wformat-truncation warnings with gcc 7.1.1.

---
 fs/gfs2/incore.h     | 2 +-
 fs/gfs2/ops_fstype.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/gfs2/incore.h +1 -1
index a7b0331c549d..2e2573182147 100644
@@ -832,7 +832,7 @@ struct gfs2_sbd {
 	atomic_t sd_freeze_state;
 	struct mutex sd_freeze_mutex;
 
-	char sd_fsname[GFS2_FSNAME_LEN];
+	char sd_fsname[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2];
 	char sd_table_name[GFS2_FSNAME_LEN];
 	char sd_proto_name[GFS2_FSNAME_LEN];
 
fs/gfs2/ops_fstype.c +3 -3
index 51752de54f11..c0a4b3778f3f 100644
@@ -1113,7 +1113,7 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
 		return error;
 	}
 
-	snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s", sdp->sd_table_name);
+	snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s", sdp->sd_table_name);
 
 	error = gfs2_sys_fs_add(sdp);
 	/*
@@ -1159,10 +1159,10 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
 	}
 
 	if (sdp->sd_args.ar_spectator)
-		snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.s",
+		snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.s",
 			 sdp->sd_table_name);
 	else
-		snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u",
+		snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.%u",
 			 sdp->sd_table_name, sdp->sd_lockstruct.ls_jid);
 
 	error = init_inodes(sdp, DO);
Signature · 1 line
2.13.3
#1 lore raw

PATCH 1/1 gfs2: Silence gcc format-truncation warning

----- Original Message -----

| Enlarge sd_fsname to be big enough for the longest long lock table name
| and an arbitrary journal number.  This silences two -Wformat-truncation
| warnings with gcc 7.1.1.
| 
| Signed-off-by: Andreas Gruenbacher <[email protected]>
| ---

Hi,

Thanks. This is now pushed to the for-next branch of the linux-gfs2 tree:
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2/incore.h?h=for-next&id=d0b23945bd5e3220b20b475e049296173bd0a184

Regards,

Bob Peterson
Red Hat File Systems