Fix clang build errors
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2025-07-17 17:38:44 -04:00
parent 8471005b9f
commit ffe083c31d
3 changed files with 47 additions and 56 deletions

View File

@ -104,8 +104,9 @@ int cmd_strip_alloc(int argc, char *argv[])
struct bch_opts opts = bch2_opts_empty();
opt_set(opts, nostart, true);
struct bch_fs *c;
reopen:
struct bch_fs *c = bch2_fs_open(&devs, &opts);
c = bch2_fs_open(&devs, &opts);
int ret = PTR_ERR_OR_ZERO(c);
if (ret)
die("Error opening filesystem: %s", bch2_err_str(ret));

View File

@ -439,40 +439,38 @@ static void link_file_data(struct bch_fs *c,
fiemap_iter_exit(&iter);
}
static struct range align_range(struct range r, unsigned bs)
{
r.start = round_down(r.start, bs);
r.end = round_up(r.end, bs);
return r;
}
struct range seek_data(int fd, u64 i_size, loff_t o)
{
s64 s = lseek(fd, o, SEEK_DATA);
if (s < 0 && errno == ENXIO)
return (struct range) {};
if (s < 0)
die("lseek error: %m");
s64 e = lseek(fd, s, SEEK_HOLE);
if (e < 0 && errno == ENXIO)
e = i_size;
if (e < 0)
die("lseek error: %m");
return (struct range) { s, e };
}
static struct range seek_data_aligned(int fd, u64 i_size, loff_t o, unsigned bs)
{
struct range seek_data(int fd, loff_t o)
{
s64 s = lseek(fd, o, SEEK_DATA);
if (s < 0 && errno == ENXIO)
return (struct range) {};
if (s < 0)
die("lseek error: %m");
s64 e = lseek(fd, s, SEEK_HOLE);
if (e < 0 && errno == ENXIO)
e = i_size;
if (e < 0)
die("lseek error: %m");
return (struct range) { s, e };
}
struct range __seek_data_aligned(int fd, loff_t o, unsigned bs)
{
struct range r = seek_data(fd, o);
r.start = round_down(r.start, bs);
r.end = round_up(r.end, bs);
return r;
}
struct range r = __seek_data_aligned(fd, o, bs);
struct range r = align_range(seek_data(fd, i_size, o), bs);
if (!r.end)
return r;
while (true) {
struct range n = __seek_data_aligned(fd, r.end, bs);
struct range n = align_range(seek_data(fd, i_size, r.end), bs);
if (!n.end || r.end < n.start)
break;
@ -482,38 +480,30 @@ static struct range seek_data_aligned(int fd, u64 i_size, loff_t o, unsigned bs)
return r;
}
struct range seek_mismatch(const char *buf1, const char *buf2,
unsigned o, unsigned len)
{
while (o < len && buf1[o] == buf2[o])
o++;
if (o == len)
return (struct range) {};
unsigned s = o;
while (o < len && buf1[o] != buf2[o])
o++;
return (struct range) { s, o };
}
static struct range seek_mismatch_aligned(const char *buf1, const char *buf2,
unsigned offset, unsigned len,
unsigned bs)
{
struct range seek_mismatch(unsigned o)
{
while (o < len && buf1[o] == buf2[o])
o++;
if (o == len)
return (struct range) {};
unsigned s = o;
while (o < len && buf1[o] != buf2[o])
o++;
return (struct range) { s, o };
}
struct range __seek_mismatch_aligned(unsigned o)
{
struct range r = seek_mismatch(o);
r.start = round_down(r.start, bs);
r.end = round_up(r.end, bs);
return r;
}
struct range r = __seek_mismatch_aligned(offset);
struct range r = align_range(seek_mismatch(buf1, buf2, offset, len), bs);
if (r.end)
while (true) {
struct range n = __seek_mismatch_aligned(r.end);
struct range n = align_range(seek_mismatch(buf1, buf2, r.end, len), bs);
if (!n.end || r.end < n.start)
break;

View File

@ -87,7 +87,7 @@ struct super_block {
};
static inline void evict_inodes(struct super_block *sb) {}
static inline int sync_filesystem(struct super_block *) { return 0; }
static inline int sync_filesystem(struct super_block *sb) { return 0; }
/*
* File types