Skip to content

Commit

Permalink
Fix build breakage with older gcc
Browse files Browse the repository at this point in the history
  • Loading branch information
jserv committed Dec 16, 2024
1 parent d9cd460 commit 36fc1b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions virtio-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -134,6 +134,7 @@ static ssize_t handle_read(netdev_t *netdev,
strerror(errno));
}
break;
}
case _(user):
/* TODO: handle read */
break;
Expand All @@ -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)) {
Expand All @@ -165,6 +166,7 @@ static ssize_t handle_write(netdev_t *netdev,
strerror(errno));
}
break;
}
case _(user):
/* TODO: handle slirp_input */
break;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 36fc1b2

Please sign in to comment.