Skip to contentSkip to conversation

xfs: silent -Wformat-security warning

PATCH In review Nicolas Iooss 2 participants 2 messages Dec 19, 2016 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: silent -Wformat-security warning

When building the XFS driver with clang, the compiler reports a -Wformat-security warning in xlog_recover_validate_buf_type() because xfs_warn() is being called with a non-literal string. Even though variable warnmsg is always initialized as a constant string without any '%' character, silent the warning by calling xfs_warn with "%s" format string.

---
 fs/xfs/xfs_log_recover.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_log_recover.c +1 -1
index 4a98762ec8b4..9208296e9f15 100644
@@ -2572,7 +2572,7 @@ xlog_recover_validate_buf_type(
 		return;
 
 	if (warnmsg) {
-		xfs_warn(mp, warnmsg);
+		xfs_warn(mp, "%s", warnmsg);
 		ASSERT(0);
 	}
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Nicolas Iooss

When building the XFS driver with clang, the compiler reports a -Wformat-security warning in xlog_recover_validate_buf_type() because xfs_warn() is being called with a non-literal string. Even though variable warnmsg is always initialized as a constant string without any '%' character, silent the warning by calling xfs_warn with "%s" format string.

Looks fine: