]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: print-tree: use string format for key names
authorDavid Sterba <dsterba@suse.com>
Fri, 26 Sep 2025 06:32:56 +0000 (08:32 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 20:37:36 +0000 (21:37 +0100)
There's a warning when -Wformat=2 is used:

fs/btrfs/print-tree.c: In function ‘key_type_string’:
fs/btrfs/print-tree.c:424:17: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
  424 |                 scnprintf(buf, buf_size, key_to_str[key->type]);

We're printing fixed strings from a table so there's no problem but
let's fix the warning so we could enable the warning in fs/btrfs/.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/print-tree.c

index 62b993fae54ff3432e51cdeb5604e50a7f1f20ee..d16f2960d55d239be65debaefd2b3c4cb8eef6d2 100644 (file)
@@ -421,7 +421,7 @@ static void key_type_string(const struct btrfs_key *key, char *buf, int buf_size
        if (key->type == 0 && key->objectid == BTRFS_FREE_SPACE_OBJECTID)
                scnprintf(buf, buf_size, "UNTYPED");
        else if (key_to_str[key->type])
-               scnprintf(buf, buf_size, key_to_str[key->type]);
+               scnprintf(buf, buf_size, "%s", key_to_str[key->type]);
        else
                scnprintf(buf, buf_size, "UNKNOWN.%d", key->type);
 }