Skip to content

Commit

Permalink
iolog, dataplacement: fix Coverity Scan defect
Browse files Browse the repository at this point in the history
CID 494151: Error handling issues (NEGATIVE_RETURNS) @ io_u.c:1877 in get_io_u()
This patch removes negative returns from dp_init() to ensure
its value can be properly consumed by td_verror()

Signed-off-by: Hyunwoo Park <dshw.park@samsung.com>
  • Loading branch information
parkvibes committed May 30, 2024
1 parent 2b07ca9 commit fc7289a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dataplacement.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
static int fdp_ruh_info(struct thread_data *td, struct fio_file *f,
struct fio_ruhs_info *ruhs)
{
int ret = -EINVAL;
int ret = EINVAL;

if (!td->io_ops) {
log_err("fio: no ops set in fdp init?!\n");
Expand Down Expand Up @@ -47,13 +47,13 @@ static int init_ruh_info(struct thread_data *td, struct fio_file *f)

ruhs = scalloc(1, sizeof(*ruhs) + FDP_MAX_RUHS * sizeof(*ruhs->plis));
if (!ruhs)
return -ENOMEM;
return ENOMEM;

/* set up the data structure used for FDP to work with the supplied stream IDs */
if (td->o.dp_type == FIO_DP_STREAMS) {
if (!td->o.dp_nr_ids) {
log_err("fio: stream IDs must be provided for dataplacement=streams\n");
return -EINVAL;
return EINVAL;
}
ruhs->nr_ruhs = td->o.dp_nr_ids;
for (int i = 0; i < ruhs->nr_ruhs; i++)
Expand All @@ -80,14 +80,14 @@ static int init_ruh_info(struct thread_data *td, struct fio_file *f)

for (i = 0; i < td->o.dp_nr_ids; i++) {
if (td->o.dp_ids[i] >= ruhs->nr_ruhs) {
ret = -EINVAL;
ret = EINVAL;
goto out;
}
}

tmp = scalloc(1, sizeof(*tmp) + ruhs->nr_ruhs * sizeof(*tmp->plis));
if (!tmp) {
ret = -ENOMEM;
ret = ENOMEM;
goto out;
}

Expand Down Expand Up @@ -117,13 +117,13 @@ static int init_ruh_scheme(struct thread_data *td, struct fio_file *f)
if (!scheme_fp) {
log_err("fio: ruh scheme failed to open scheme file %s\n",
td->o.dp_scheme_file);
ret = -errno;
ret = errno;
goto out;
}

ruh_scheme = scalloc(1, sizeof(*ruh_scheme));
if (!ruh_scheme) {
ret = -ENOMEM;
ret = ENOMEM;
goto out_with_close_fp;
}

Expand Down

0 comments on commit fc7289a

Please sign in to comment.