Commit 3756111d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent b8559f1a
...@@ -1069,7 +1069,7 @@ int bch2_btree_node_read_done(struct bch_fs *c, struct bch_dev *ca, ...@@ -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); bch2_bkey_val_to_text(&buf, c, u.s_c);
btree_err(BTREE_ERR_FIXABLE, c, NULL, b, i, 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); printbuf_exit(&buf);
btree_keys_account_key_drop(&b->nr, 0, k); btree_keys_account_key_drop(&b->nr, 0, k);
......
...@@ -1586,7 +1586,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb, ...@@ -1586,7 +1586,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
pr_buf(out, "Oldest version on disk:"); pr_buf(out, "Oldest version on disk:");
pr_tab(out); 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_newline(out);
pr_buf(out, "Created:"); pr_buf(out, "Created:");
......
...@@ -282,7 +282,8 @@ static inline size_t printbuf_linelen(struct printbuf *buf) ...@@ -282,7 +282,8 @@ static inline size_t printbuf_linelen(struct printbuf *buf)
return buf->pos - buf->last_newline; 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__) #define pr_buf(_out, ...) bch2_pr_buf(_out, __VA_ARGS__)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment