From 36fc1b2bfcbfe4a81b5afd07072f4232f418bf20 Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Mon, 16 Dec 2024 11:23:13 +0800 Subject: [PATCH] Fix build breakage with older gcc --- netdev.c | 2 +- virtio-net.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/netdev.c b/netdev.c index 4a713f7..858a21f 100644 --- a/netdev.c +++ b/netdev.c @@ -55,7 +55,7 @@ static int net_init_tap(netdev_t *netdev) return 0; } -static int net_init_user(netdev_t *netdev) +static int net_init_user(netdev_t *netdev UNUSED) { /* TODO: create slirp dev */ return 0; diff --git a/virtio-net.c b/virtio-net.c index 8e38bb6..e8b0f6e 100644 --- a/virtio-net.c +++ b/virtio-net.c @@ -121,7 +121,7 @@ static ssize_t handle_read(netdev_t *netdev, ssize_t plen = 0; #define _(dev) NETDEV_IMPL_##dev switch (netdev->type) { - case _(tap): + case _(tap): { net_tap_options_t *tap = (net_tap_options_t *) netdev->op; plen = readv(tap->tap_fd, iovs_cursor, niovs); if (plen < 0 && (errno == EWOULDBLOCK || errno == EAGAIN)) { @@ -134,6 +134,7 @@ static ssize_t handle_read(netdev_t *netdev, strerror(errno)); } break; + } case _(user): /* TODO: handle read */ break; @@ -152,7 +153,7 @@ static ssize_t handle_write(netdev_t *netdev, ssize_t plen = 0; #define _(dev) NETDEV_IMPL_##dev switch (netdev->type) { - case _(tap): + case _(tap): { net_tap_options_t *tap = (net_tap_options_t *) netdev->op; plen = writev(tap->tap_fd, iovs_cursor, niovs); if (plen < 0 && (errno == EWOULDBLOCK || errno == EAGAIN)) { @@ -165,6 +166,7 @@ static ssize_t handle_write(netdev_t *netdev, strerror(errno)); } break; + } case _(user): /* TODO: handle slirp_input */ break; @@ -280,7 +282,7 @@ void virtio_net_refresh_queue(virtio_net_state_t *vnet) netdev_impl_t dev_type = vnet->peer.type; #define _(dev) NETDEV_IMPL_##dev switch (dev_type) { - case _(tap): + case _(tap): { net_tap_options_t *tap = (net_tap_options_t *) vnet->peer.op; struct pollfd pfd = {tap->tap_fd, POLLIN | POLLOUT, 0}; poll(&pfd, 1, 0); @@ -293,6 +295,7 @@ void virtio_net_refresh_queue(virtio_net_state_t *vnet) virtio_net_try_tx(vnet); } break; + } case _(user): /* TODO: handle slirp input/output */ break;