summaryrefslogtreecommitdiff
path: root/misc/tune2fs.c
diff options
context:
space:
mode:
authorAndreas Dilger <adilger@dilger.ca>2020-01-14 14:42:18 -0700
committerTheodore Ts'o <tytso@mit.edu>2020-01-24 23:06:58 -0500
commitbc56227376223c02b16703691fd0de6929a1036b (patch)
tree152c8394b763419a418e0c68fc1bab20e0367d7f /misc/tune2fs.c
parent6b430d60caf6c4080bd32783659a819425657b69 (diff)
downloade2fsprogs-bc56227376223c02b16703691fd0de6929a1036b.tar.gz
mmp: abstract out repeated 'sizeof(buf), buf' usage
The printf("%.*s") format requires both the buffer size and buffer pointer to be specified for each use. Since this is repeatedly given as "(int)sizeof(buf), (char *)buf" for mmp_nodename and mmp_bdevname fields, with typecasts to avoid compiler warnings. Add a helper macro EXT2_LEN_STR() to avoid repeated boilerplate code. This can also be used for other superblock buffer fields that may not have NUL-terminated strings (e.g. s_volume_name, s_last_mounted, s_{first,last}_error_func, s_mount_opts) to simplify code and avoid the need for temporary buffers for NUL-termination. Annotate the superblock string fields that may not be NUL-terminated. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'misc/tune2fs.c')
-rw-r--r--misc/tune2fs.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 301cf388..923fbb7a 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -2986,8 +2986,7 @@ retry_open:
if (print_label) {
/* For e2label emulation */
- printf("%.*s\n", (int) sizeof(sb->s_volume_name),
- sb->s_volume_name);
+ printf("%.*s\n", EXT2_LEN_STR(sb->s_volume_name));
remove_error_table(&et_ext2_error_table);
goto closefs;
}