Skip to content

Commit 561b796

Browse files
Andreas GruenbacherAstralBob
authored andcommitted
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. Signed-off-by: Andreas Gruenbacher <[email protected]> Signed-off-by: Bob Peterson <[email protected]>
1 parent 942b0cd commit 561b796

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/gfs2/incore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ struct gfs2_sbd {
833833
atomic_t sd_freeze_state;
834834
struct mutex sd_freeze_mutex;
835835

836-
char sd_fsname[GFS2_FSNAME_LEN];
836+
char sd_fsname[GFS2_FSNAME_LEN + 3 * sizeof(int) + 2];
837837
char sd_table_name[GFS2_FSNAME_LEN];
838838
char sd_proto_name[GFS2_FSNAME_LEN];
839839

fs/gfs2/ops_fstype.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
11131113
return error;
11141114
}
11151115

1116-
snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s", sdp->sd_table_name);
1116+
snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s", sdp->sd_table_name);
11171117

11181118
error = gfs2_sys_fs_add(sdp);
11191119
/*
@@ -1159,10 +1159,10 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
11591159
}
11601160

11611161
if (sdp->sd_args.ar_spectator)
1162-
snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.s",
1162+
snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.s",
11631163
sdp->sd_table_name);
11641164
else
1165-
snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u",
1165+
snprintf(sdp->sd_fsname, sizeof(sdp->sd_fsname), "%s.%u",
11661166
sdp->sd_table_name, sdp->sd_lockstruct.ls_jid);
11671167

11681168
error = init_inodes(sdp, DO);

0 commit comments

Comments
 (0)