aboutsummaryrefslogtreecommitdiff
path: root/contrib/vhost-user-blk/vhost-user-blk.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/vhost-user-blk/vhost-user-blk.c')
-rw-r--r--contrib/vhost-user-blk/vhost-user-blk.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
index 89e5f11..6cc18a1 100644
--- a/contrib/vhost-user-blk/vhost-user-blk.c
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
@@ -16,6 +16,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/bswap.h"
#include "standard-headers/linux/virtio_blk.h"
#include "libvhost-user-glib.h"
@@ -194,8 +195,8 @@ vub_discard_write_zeroes(VubReq *req, struct iovec *iov, uint32_t iovcnt,
#if defined(__linux__) && defined(BLKDISCARD) && defined(BLKZEROOUT)
VubDev *vdev_blk = req->vdev_blk;
desc = buf;
- uint64_t range[2] = { le64toh(desc->sector) << 9,
- le32toh(desc->num_sectors) << 9 };
+ uint64_t range[2] = { le64_to_cpu(desc->sector) << 9,
+ (uint64_t)le32_to_cpu(desc->num_sectors) << 9 };
if (type == VIRTIO_BLK_T_DISCARD) {
if (ioctl(vdev_blk->blk_fd, BLKDISCARD, range) == 0) {
g_free(buf);
@@ -267,13 +268,13 @@ static int vub_virtio_process_req(VubDev *vdev_blk,
req->in = (struct virtio_blk_inhdr *)elem->in_sg[in_num - 1].iov_base;
in_num--;
- type = le32toh(req->out->type);
+ type = le32_to_cpu(req->out->type);
switch (type & ~VIRTIO_BLK_T_BARRIER) {
case VIRTIO_BLK_T_IN:
case VIRTIO_BLK_T_OUT: {
ssize_t ret = 0;
bool is_write = type & VIRTIO_BLK_T_OUT;
- req->sector_num = le64toh(req->out->sector);
+ req->sector_num = le64_to_cpu(req->out->sector);
if (is_write) {
ret = vub_writev(req, &elem->out_sg[1], out_num);
} else {
@@ -469,7 +470,6 @@ static int unix_sock_new(char *unix_fn)
{
int sock;
struct sockaddr_un un;
- size_t len;
assert(unix_fn);
@@ -481,10 +481,9 @@ static int unix_sock_new(char *unix_fn)
un.sun_family = AF_UNIX;
(void)snprintf(un.sun_path, sizeof(un.sun_path), "%s", unix_fn);
- len = sizeof(un.sun_family) + strlen(un.sun_path);
(void)unlink(unix_fn);
- if (bind(sock, (struct sockaddr *)&un, len) < 0) {
+ if (bind(sock, (struct sockaddr *)&un, sizeof(un)) < 0) {
perror("bind");
goto fail;
}