Commit d4b69152 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Kill bch_scnmemcpy()

bch_scnmemcpy was for printing length-limited strings that might not
have a terminating null - turns out sprintf & pr_buf can do this with
%.*s.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 3117db99
...@@ -122,9 +122,9 @@ void bch2_dirent_to_text(struct printbuf *out, struct bch_fs *c, ...@@ -122,9 +122,9 @@ void bch2_dirent_to_text(struct printbuf *out, struct bch_fs *c,
{ {
struct bkey_s_c_dirent d = bkey_s_c_to_dirent(k); struct bkey_s_c_dirent d = bkey_s_c_to_dirent(k);
bch_scnmemcpy(out, d.v->d_name, pr_buf(out, "%.*s -> %llu type %s",
bch2_dirent_name_bytes(d)); bch2_dirent_name_bytes(d),
pr_buf(out, " -> %llu type %s", d.v->d_name,
d.v->d_type != DT_SUBVOL d.v->d_type != DT_SUBVOL
? le64_to_cpu(d.v->d_inum) ? le64_to_cpu(d.v->d_inum)
: le32_to_cpu(d.v->d_child_subvol), : le32_to_cpu(d.v->d_child_subvol),
......
...@@ -76,8 +76,9 @@ static int bch2_sb_disk_groups_validate(struct bch_sb *sb, ...@@ -76,8 +76,9 @@ static int bch2_sb_disk_groups_validate(struct bch_sb *sb,
for (g = sorted; g + 1 < sorted + nr_groups; g++) for (g = sorted; g + 1 < sorted + nr_groups; g++)
if (!BCH_GROUP_DELETED(g) && if (!BCH_GROUP_DELETED(g) &&
!group_cmp(&g[0], &g[1])) { !group_cmp(&g[0], &g[1])) {
pr_buf(err, "duplicate label %llu.", BCH_GROUP_PARENT(g)); pr_buf(err, "duplicate label %llu.%.*s",
bch_scnmemcpy(err, g->label, strnlen(g->label, sizeof(g->label))); BCH_GROUP_PARENT(g),
(int) sizeof(g->label), g->label);
goto err; goto err;
} }
...@@ -376,9 +377,7 @@ void bch2_disk_path_to_text(struct printbuf *out, ...@@ -376,9 +377,7 @@ void bch2_disk_path_to_text(struct printbuf *out,
v = path[--nr]; v = path[--nr];
g = groups->entries + v; g = groups->entries + v;
bch_scnmemcpy(out, g->label, pr_buf(out, "%.*s", (int) sizeof(g->label), g->label);
strnlen(g->label, sizeof(g->label)));
if (nr) if (nr)
pr_buf(out, "."); pr_buf(out, ".");
} }
......
...@@ -595,7 +595,7 @@ static void journal_entry_log_to_text(struct printbuf *out, struct bch_fs *c, ...@@ -595,7 +595,7 @@ static void journal_entry_log_to_text(struct printbuf *out, struct bch_fs *c,
struct jset_entry_log *l = container_of(entry, struct jset_entry_log, entry); struct jset_entry_log *l = container_of(entry, struct jset_entry_log, entry);
unsigned bytes = vstruct_bytes(entry) - offsetof(struct jset_entry_log, d); unsigned bytes = vstruct_bytes(entry) - offsetof(struct jset_entry_log, d);
bch_scnmemcpy(out, l->d, strnlen(l->d, bytes)); pr_buf(out, "%.*s", bytes, l->d);
} }
struct jset_entry_ops { struct jset_entry_ops {
......
...@@ -581,19 +581,6 @@ void memcpy_from_bio(void *dst, struct bio *src, struct bvec_iter src_iter) ...@@ -581,19 +581,6 @@ void memcpy_from_bio(void *dst, struct bio *src, struct bvec_iter src_iter)
} }
} }
void bch_scnmemcpy(struct printbuf *out,
const char *src, size_t len)
{
size_t n = printbuf_remaining(out);
if (n) {
n = min(n - 1, len);
memcpy(out->pos, src, n);
out->pos += n;
*out->pos = '\0';
}
}
#include "eytzinger.h" #include "eytzinger.h"
static int alignment_ok(const void *base, size_t align) static int alignment_ok(const void *base, size_t align)
......
...@@ -281,8 +281,6 @@ static inline void printbuf_newline(struct printbuf *buf) ...@@ -281,8 +281,6 @@ static inline void printbuf_newline(struct printbuf *buf)
pr_buf(buf, " "); pr_buf(buf, " ");
} }
void bch_scnmemcpy(struct printbuf *, const char *, size_t);
int bch2_strtoint_h(const char *, int *); int bch2_strtoint_h(const char *, int *);
int bch2_strtouint_h(const char *, unsigned int *); int bch2_strtouint_h(const char *, unsigned int *);
int bch2_strtoll_h(const char *, long long *); int bch2_strtoll_h(const char *, long long *);
......
...@@ -111,11 +111,11 @@ void bch2_xattr_to_text(struct printbuf *out, struct bch_fs *c, ...@@ -111,11 +111,11 @@ void bch2_xattr_to_text(struct printbuf *out, struct bch_fs *c,
else else
pr_buf(out, "(unknown type %u)", xattr.v->x_type); pr_buf(out, "(unknown type %u)", xattr.v->x_type);
bch_scnmemcpy(out, xattr.v->x_name, pr_buf(out, "%.*s:%.*s",
xattr.v->x_name_len); xattr.v->x_name_len,
pr_buf(out, ":"); xattr.v->x_name,
bch_scnmemcpy(out, xattr_val(xattr.v), le16_to_cpu(xattr.v->x_val_len),
le16_to_cpu(xattr.v->x_val_len)); (char *) xattr_val(xattr.v));
} }
static int bch2_xattr_get_trans(struct btree_trans *trans, struct bch_inode_info *inode, static int bch2_xattr_get_trans(struct btree_trans *trans, struct bch_inode_info *inode,
......
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