]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
mmp: abstract out repeated 'sizeof(buf), buf' usage
authorAndreas Dilger <adilger@dilger.ca>
Tue, 14 Jan 2020 21:42:18 +0000 (14:42 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 25 Jan 2020 04:06:58 +0000 (23:06 -0500)
commitbc56227376223c02b16703691fd0de6929a1036b
tree152c8394b763419a418e0c68fc1bab20e0367d7f
parent6b430d60caf6c4080bd32783659a819425657b69
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>
13 files changed:
debugfs/debugfs.c
e2fsck/unix.c
e2fsck/util.c
lib/blkid/probe.c
lib/e2p/ls.c
lib/ext2fs/ext2_fs.h
lib/support/plausible.c
misc/dumpe2fs.c
misc/e2label.c
misc/findsuper.c
misc/mke2fs.c
misc/tune2fs.c
misc/util.c