diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-06 14:04:34 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:27 -0400 |
commit | 07b8121f07056480c54fca99046870d84a657d13 (patch) | |
tree | e3fcf7003f4e2729024d34193a4f6fca8d6d4572 /fs/bcachefs/util.h | |
parent | e1f7fa06a8ed48feedd5f538fc4724734c6e1869 (diff) | |
download | linux-07b8121f07056480c54fca99046870d84a657d13.tar.gz linux-07b8121f07056480c54fca99046870d84a657d13.tar.bz2 linux-07b8121f07056480c54fca99046870d84a657d13.zip |
bcachefs: Fix pr_tab_rjust()
pr_tab_rjust() was broken and leaving a null somewhere in the output
string - this patch fixes it and simplifies it a bit.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/util.h')
-rw-r--r-- | fs/bcachefs/util.h | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index 7667944f9ae4..ba0c4d29c038 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -334,27 +334,11 @@ static inline void pr_tab(struct printbuf *buf) buf->tabstop++; } +void bch2_pr_tab_rjust(struct printbuf *); + static inline void pr_tab_rjust(struct printbuf *buf) { - ssize_t shift = min_t(ssize_t, buf->tabstops[buf->tabstop] - - printbuf_linelen(buf), - printbuf_remaining(buf)); - ssize_t move = min_t(ssize_t, buf->pos - buf->last_field, - printbuf_remaining(buf) - shift); - - BUG_ON(buf->tabstop > ARRAY_SIZE(buf->tabstops)); - - if (shift > 0) { - memmove(buf->buf + buf->last_field + shift, - buf->buf + buf->last_field, - move); - memset(buf->buf + buf->last_field, ' ', shift); - buf->pos += shift; - buf->buf[buf->pos] = 0; - } - - buf->last_field = buf->pos; - buf->tabstop++; + bch2_pr_tab_rjust(buf); } void bch2_pr_units(struct printbuf *, s64, s64); |