mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-26 19:51:32 +00:00
Improve compile-time type checking for f2fs_report_zone()
Change the type of the third argument of f2fs_report_zone() from void * into struct blk_zone * to enable type checking. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
a491213a0d
commit
cdd66bafeb
@ -1560,9 +1560,11 @@ blk_zone_cond_str(struct blk_zone *blkz)
|
||||
|
||||
#endif
|
||||
|
||||
struct blk_zone;
|
||||
|
||||
extern int f2fs_get_zoned_model(int);
|
||||
extern int f2fs_get_zone_blocks(int);
|
||||
extern int f2fs_report_zone(int, uint64_t, void *);
|
||||
extern int f2fs_report_zone(int, uint64_t, struct blk_zone *);
|
||||
typedef int (report_zones_cb_t)(int i, void *, void *);
|
||||
extern int f2fs_report_zones(int, report_zones_cb_t *, void *);
|
||||
extern int f2fs_check_zones(int);
|
||||
|
@ -202,21 +202,26 @@ int f2fs_get_zone_blocks(int i)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int f2fs_report_zone(int i, uint64_t sector, void *blkzone)
|
||||
int f2fs_report_zone(int i, uint64_t sector, struct blk_zone *blkzone)
|
||||
{
|
||||
struct blk_zone *blkz = (struct blk_zone *)blkzone;
|
||||
struct blk_zone_report *rep;
|
||||
struct one_zone_report {
|
||||
struct blk_zone_report rep;
|
||||
struct blk_zone zone;
|
||||
} *rep;
|
||||
int ret = -1;
|
||||
|
||||
rep = calloc(1, sizeof(struct blk_zone_report) +
|
||||
sizeof(struct blk_zone));
|
||||
static_assert(sizeof(*rep) == sizeof(rep->rep) + sizeof(rep->zone), "");
|
||||
|
||||
rep = calloc(1, sizeof(*rep));
|
||||
if (!rep) {
|
||||
ERR_MSG("No memory for report zones\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
rep->sector = sector;
|
||||
rep->nr_zones = 1;
|
||||
rep->rep = (struct blk_zone_report){
|
||||
.sector = sector,
|
||||
.nr_zones = 1,
|
||||
};
|
||||
ret = ioctl(c.devices[i].fd, BLKREPORTZONE, rep);
|
||||
if (ret != 0) {
|
||||
ret = -errno;
|
||||
@ -224,7 +229,7 @@ int f2fs_report_zone(int i, uint64_t sector, void *blkzone)
|
||||
goto out;
|
||||
}
|
||||
|
||||
*blkz = *(struct blk_zone *)(rep + 1);
|
||||
*blkzone = rep->zone;
|
||||
out:
|
||||
free(rep);
|
||||
return ret;
|
||||
@ -533,7 +538,8 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
|
||||
|
||||
#else
|
||||
|
||||
int f2fs_report_zone(int i, uint64_t UNUSED(sector), void *UNUSED(blkzone))
|
||||
int f2fs_report_zone(int i, uint64_t UNUSED(sector),
|
||||
struct blk_zone *UNUSED(blkzone))
|
||||
{
|
||||
ERR_MSG("%d: Unsupported zoned block device\n", i);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user