diff options
author | John Levon <john.levon@nutanix.com> | 2021-04-13 10:35:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-13 10:35:59 +0100 |
commit | 451b4180c18722b11047ba6c7554e24dde0004f9 (patch) | |
tree | b4c14a5bc834701f5fff7fc7fc498c7b023d9c7b /samples/server.c | |
parent | 944da3686dc5e70e104fadf0d3acd616312d1388 (diff) | |
download | libvfio-user-451b4180c18722b11047ba6c7554e24dde0004f9.zip libvfio-user-451b4180c18722b11047ba6c7554e24dde0004f9.tar.gz libvfio-user-451b4180c18722b11047ba6c7554e24dde0004f9.tar.bz2 |
dma: use ERROR_INT()
The first in a series excising the use of the "return -errno" idiom. This is a
non-standard usage, and in userspace, we have "errno" for delivering side-band
error values. As there have been multiple bugs from not using standard error
return methods like -1+errno or NULL+errno, let's do that.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'samples/server.c')
-rw-r--r-- | samples/server.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/samples/server.c b/samples/server.c index f9bde30..a449bb6 100644 --- a/samples/server.c +++ b/samples/server.c @@ -45,6 +45,7 @@ #include "common.h" #include "libvfio-user.h" +#include "private.h" #include "tran_sock.h" struct dma_regions { @@ -184,7 +185,7 @@ dma_unregister(vfu_ctx_t *vfu_ctx, vfu_dma_info_t *info) } } - return -EINVAL; + return ERROR_INT(EINVAL); } static void @@ -219,10 +220,9 @@ static void do_dma_io(vfu_ctx_t *vfu_ctx, struct server_data *server_data) (vfu_dma_addr_t)server_data->regions[0].iova.iov_base, count, &sg, 1, PROT_WRITE); if (ret < 0) { - errx(EXIT_FAILURE, "failed to map %p-%p: %s", - server_data->regions[0].iova.iov_base, - server_data->regions[0].iova.iov_base + count -1, - strerror(-ret)); + err(EXIT_FAILURE, "failed to map %p-%p", + server_data->regions[0].iova.iov_base, + server_data->regions[0].iova.iov_base + count -1); } memset(buf, 'A', count); @@ -231,7 +231,7 @@ static void do_dma_io(vfu_ctx_t *vfu_ctx, struct server_data *server_data) server_data->regions[0].iova.iov_base, count); ret = vfu_dma_write(vfu_ctx, &sg, buf); if (ret < 0) { - errx(EXIT_FAILURE, "vfu_dma_write failed: %s", strerror(-ret)); + err(EXIT_FAILURE, "vfu_dma_write failed"); } memset(buf, 0, count); @@ -239,7 +239,7 @@ static void do_dma_io(vfu_ctx_t *vfu_ctx, struct server_data *server_data) server_data->regions[0].iova.iov_base, count); ret = vfu_dma_read(vfu_ctx, &sg, buf); if (ret < 0) { - errx(EXIT_FAILURE, "vfu_dma_read failed: %s", strerror(-ret)); + err(EXIT_FAILURE, "vfu_dma_read failed"); } get_md5sum(buf, count, md5sum2); for(i = 0; i < MD5_DIGEST_LENGTH; i++) { |