diff options
author | William Henderson <william.henderson@nutanix.com> | 2023-08-04 11:15:58 +0000 |
---|---|---|
committer | John Levon <john.levon@nutanix.com> | 2023-09-15 12:59:39 +0100 |
commit | 5002b8a08501942e34c0176ebc1f2238c2d7c49f (patch) | |
tree | 1b8bce18eda163fad9fe0d7fc47782a72ed100ff | |
parent | 69f3bb2c610df2d43b91dd96361a1d7b00632362 (diff) | |
download | libvfio-user-5002b8a08501942e34c0176ebc1f2238c2d7c49f.zip libvfio-user-5002b8a08501942e34c0176ebc1f2238c2d7c49f.tar.gz libvfio-user-5002b8a08501942e34c0176ebc1f2238c2d7c49f.tar.bz2 |
fix: error returns incorrectly not using ERROR_INT
Signed-off-by: William Henderson <william.henderson@nutanix.com>
-rw-r--r-- | lib/libvfio-user.c | 18 | ||||
-rw-r--r-- | lib/migration.c | 18 |
2 files changed, 18 insertions, 18 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index a5daaab..ff57b72 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -933,7 +933,7 @@ handle_device_feature(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) if (vfu_ctx->migration == NULL || msg->in.iov.iov_len < sizeof(struct vfio_user_device_feature)) { - return -EINVAL; + return ERROR_INT(EINVAL); } struct vfio_user_device_feature *req = msg->in.iov.iov_base; @@ -943,7 +943,7 @@ handle_device_feature(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) if ((req->flags & supported_flags) != (req->flags & ~VFIO_DEVICE_FEATURE_MASK) || supported_flags == 0) { - return -EINVAL; + return ERROR_INT(EINVAL); } uint32_t feature = req->flags & VFIO_DEVICE_FEATURE_MASK; @@ -955,7 +955,7 @@ handle_device_feature(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) msg->out.iov.iov_len = msg->in.iov.iov_len; if (msg->out.iov.iov_base == NULL) { - return -1; + return ERROR_INT(ENOMEM); } memcpy(msg->out.iov.iov_base, msg->in.iov.iov_base, @@ -971,7 +971,7 @@ handle_device_feature(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) msg->out.iov.iov_base = calloc(1, msg->out.iov.iov_len); if (msg->out.iov.iov_base == NULL) { - return -1; + return ERROR_INT(ENOMEM); } memcpy(msg->out.iov.iov_base, msg->in.iov.iov_base, @@ -1001,7 +1001,7 @@ handle_device_feature(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) msg->out.iov.iov_base = malloc(msg->out.iov.iov_len); if (msg->out.iov.iov_base == NULL) { - return -1; + return ERROR_INT(ENOMEM); } memcpy(msg->out.iov.iov_base, msg->in.iov.iov_base, @@ -1018,14 +1018,14 @@ handle_device_feature(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) msg->out.iov.iov_len = 0; } } else { - return -1; + return ERROR_INT(EINVAL); } } else if (req->flags & VFIO_DEVICE_FEATURE_SET) { msg->out.iov.iov_base = malloc(msg->in.iov.iov_len); msg->out.iov.iov_len = msg->in.iov.iov_len; if (msg->out.iov.iov_base == NULL) { - return -1; + return ERROR_INT(ENOMEM); } memcpy(msg->out.iov.iov_base, msg->in.iov.iov_base, @@ -1038,10 +1038,10 @@ handle_device_feature(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) } else if (is_dma_feature(feature)) { ret = dma_feature_set(vfu_ctx, feature, res->data); } else { - return -1; + return ERROR_INT(EINVAL); } } else { - return -1; + return ERROR_INT(EINVAL); } return ret; diff --git a/lib/migration.c b/lib/migration.c index 879978a..8abe6c2 100644 --- a/lib/migration.c +++ b/lib/migration.c @@ -204,7 +204,7 @@ migration_feature_get(vfu_ctx_t *vfu_ctx, uint32_t feature, void *buf) return 0; default: - return -EINVAL; + return ERROR_INT(EINVAL); }; } @@ -223,7 +223,7 @@ migration_feature_set(vfu_ctx_t *vfu_ctx, uint32_t feature, void *buf) state = next_state[migr->state][res->device_state]; if (state == VFIO_USER_DEVICE_STATE_ERROR) { - return -EINVAL; + return ERROR_INT(EINVAL); } ret = handle_device_state(vfu_ctx, migr, state, true); @@ -232,7 +232,7 @@ migration_feature_set(vfu_ctx_t *vfu_ctx, uint32_t feature, void *buf) return ret; } - return -EINVAL; + return ERROR_INT(EINVAL); } ssize_t @@ -245,27 +245,27 @@ handle_mig_data_read(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) struct vfio_user_mig_data *req = msg->in.iov.iov_base; if (vfu_ctx->migration == NULL) { - return -EINVAL; + return ERROR_INT(EINVAL); } if (migr->state != VFIO_USER_DEVICE_STATE_PRE_COPY && migr->state != VFIO_USER_DEVICE_STATE_STOP_COPY) { vfu_log(vfu_ctx, LOG_ERR, "bad migration state to read data: %d", migr->state); - return -EINVAL; + return ERROR_INT(EINVAL); } if (req->size > vfu_ctx->client_max_data_xfer_size) { vfu_log(vfu_ctx, LOG_ERR, "transfer size exceeds limit (%d > %ld)", req->size, vfu_ctx->client_max_data_xfer_size); - return -EINVAL; + return ERROR_INT(EINVAL); } msg->out.iov.iov_len = msg->in.iov.iov_len + req->size; msg->out.iov.iov_base = calloc(1, msg->out.iov.iov_len); if (msg->out.iov.iov_base == NULL) { - return -EINVAL; + return ERROR_INT(ENOMEM); } struct vfio_user_mig_data *res = msg->out.iov.iov_base; @@ -292,13 +292,13 @@ handle_mig_data_write(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg) struct vfio_user_mig_data *req = msg->in.iov.iov_base; if (vfu_ctx->migration == NULL) { - return -EINVAL; + return ERROR_INT(EINVAL); } if (migr->state != VFIO_USER_DEVICE_STATE_RESUMING) { vfu_log(vfu_ctx, LOG_ERR, "bad migration state to write data: %d", migr->state); - return -EINVAL; + return ERROR_INT(EINVAL); } return migr->callbacks.write_data(vfu_ctx, &req->data, req->size); |