bcachefs: Add printf format attribute to bch2_pr_buf()

This tells the compiler to check printf format strings, and catches a
few bugs.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2022-03-21 18:05:39 -04:00 committed by Kent Overstreet
parent b8559f1a21
commit 3756111d13
3 changed files with 4 additions and 3 deletions

View file

@ -1069,7 +1069,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca,
bch2_bkey_val_to_text(&buf, c, u.s_c);
btree_err(BTREE_ERR_FIXABLE, c, NULL, b, i,
"invalid bkey %s: %s", buf, invalid);
"invalid bkey %s: %s", buf.buf, invalid);
printbuf_exit(&buf);
btree_keys_account_key_drop(&b->nr, 0, k);

View file

@ -1586,7 +1586,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
pr_buf(out, "Oldest version on disk:");
pr_tab(out);
pr_buf(out, "%u", bch2_metadata_versions[le16_to_cpu(sb->version_min)]);
pr_buf(out, "%s", bch2_metadata_versions[le16_to_cpu(sb->version_min)]);
pr_newline(out);
pr_buf(out, "Created:");

View file

@ -282,7 +282,8 @@ static inline size_t printbuf_linelen(struct printbuf *buf)
return buf->pos - buf->last_newline;
}
void bch2_pr_buf(struct printbuf *out, const char *fmt, ...);
void bch2_pr_buf(struct printbuf *out, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
#define pr_buf(_out, ...) bch2_pr_buf(_out, __VA_ARGS__)