diff options
Diffstat (limited to 'libhw_cr')
-rw-r--r-- | libhw_cr/host_alarmclock.c | 4 | ||||
-rw-r--r-- | libhw_cr/host_net.c | 22 | ||||
-rw-r--r-- | libhw_cr/rp2040_dma.c | 4 | ||||
-rw-r--r-- | libhw_cr/rp2040_gpioirq.c | 2 | ||||
-rw-r--r-- | libhw_cr/rp2040_hwspi.c | 12 | ||||
-rw-r--r-- | libhw_cr/w5500.c | 8 |
6 files changed, 30 insertions, 22 deletions
diff --git a/libhw_cr/host_alarmclock.c b/libhw_cr/host_alarmclock.c index 9eedec2..ac2093c 100644 --- a/libhw_cr/host_alarmclock.c +++ b/libhw_cr/host_alarmclock.c @@ -49,7 +49,7 @@ static void hostclock_handle_sig_alarm(int LM_UNUSED(sig), siginfo_t *info, void if (alarmclock->queue) { struct itimerspec alarmspec = { .it_value = ns_to_host_ns_time(alarmclock->queue->fire_at_ns), - .it_interval = {0}, + .it_interval = {}, }; if (timer_settime(alarmclock->timer_id, TIMER_ABSTIME, &alarmspec, NULL) != 0) error(1, errno, "timer_settime"); @@ -101,7 +101,7 @@ static bool hostclock_add_trigger(struct hostclock *alarmclock, if (alarmclock->queue == trigger) { struct itimerspec alarmspec = { .it_value = ns_to_host_ns_time(trigger->fire_at_ns), - .it_interval = {0}, + .it_interval = {}, }; if (timer_settime(alarmclock->timer_id, TIMER_ABSTIME, &alarmspec, NULL) != 0) error(1, errno, "timer_settime"); diff --git a/libhw_cr/host_net.c b/libhw_cr/host_net.c index 01f4370..4a2e65f 100644 --- a/libhw_cr/host_net.c +++ b/libhw_cr/host_net.c @@ -53,7 +53,7 @@ static void hostnet_handle_sig_io(int LM_UNUSED(sig), siginfo_t *info, void *LM_ } static void hostnet_init(void) { - struct sigaction action = {0}; + struct sigaction action = {}; if (hostnet_sig_io) return; @@ -128,7 +128,7 @@ void hostnet_tcp_listener_init(struct hostnet_tcp_listener *self, uint16_t port) union { struct sockaddr_in in; struct sockaddr gen; - } addr = { 0 }; + } addr = {}; hostnet_init(); @@ -241,6 +241,10 @@ static ssize_t hostnet_tcp_readv(struct _hostnet_tcp_conn *conn, const struct io assert(conn); assert(iov); assert(iovcnt > 0); + size_t count = 0; + for (int i = 0; i < iovcnt; i++) + count += iov[i].iov_len; + assert(count); ssize_t ret; struct hostnet_pthread_readv_args args = { @@ -259,7 +263,7 @@ static ssize_t hostnet_tcp_readv(struct _hostnet_tcp_conn *conn, const struct io return -NET_ERECV_TIMEOUT; args.timeout = ns_to_host_us_time(conn->read_deadline_ns-now_ns); } else { - args.timeout = (host_us_time_t){0}; + args.timeout = (host_us_time_t){}; } if (RUN_PTHREAD(hostnet_pthread_readv, &args)) @@ -319,6 +323,10 @@ static ssize_t hostnet_tcp_writev(struct _hostnet_tcp_conn *conn, const struct i assert(conn); assert(iov); assert(iovcnt > 0); + size_t count = 0; + for (int i = 0; i < iovcnt; i++) + count += iov[i].iov_len; + assert(count); ssize_t ret; struct hostnet_pthread_writev_args args = { @@ -359,7 +367,7 @@ void hostnet_udp_conn_init(struct hostnet_udp_conn *self, uint16_t port) { struct sockaddr_in in; struct sockaddr gen; struct sockaddr_storage stor; - } addr = { 0 }; + } addr = {}; hostnet_init(); @@ -396,7 +404,7 @@ static void *hostnet_pthread_sendto(void *_args) { struct sockaddr_in in; struct sockaddr gen; struct sockaddr_storage stor; - } addr = { 0 }; + } addr = {}; addr.in.sin_family = AF_INET; addr.in.sin_addr.s_addr = @@ -464,7 +472,7 @@ static void *hostnet_pthread_recvfrom(void *_args) { struct sockaddr_in in; struct sockaddr gen; struct sockaddr_storage stor; - } addr = { 0 }; + } addr = {}; socklen_t addr_size; *(args->ret_size) = setsockopt(args->connfd, SOL_SOCKET, SO_RCVTIMEO, @@ -518,7 +526,7 @@ static ssize_t hostnet_udp_recvfrom(struct hostnet_udp_conn *conn, void *buf, si return -NET_ERECV_TIMEOUT; args.timeout = ns_to_host_us_time(conn->read_deadline_ns-now_ns); } else { - args.timeout = (host_us_time_t){0}; + args.timeout = (host_us_time_t){}; } if (RUN_PTHREAD(hostnet_pthread_recvfrom, &args)) diff --git a/libhw_cr/rp2040_dma.c b/libhw_cr/rp2040_dma.c index 47d5cd3..e117c19 100644 --- a/libhw_cr/rp2040_dma.c +++ b/libhw_cr/rp2040_dma.c @@ -12,9 +12,9 @@ struct dmairq_handler_entry { dmairq_handler_t fn; void *arg; }; -struct dmairq_handler_entry dmairq_handlers[NUM_DMA_CHANNELS] = {0}; +struct dmairq_handler_entry dmairq_handlers[NUM_DMA_CHANNELS] = {}; -bool dmairq_initialized[NUM_DMA_IRQS] = {0}; +bool dmairq_initialized[NUM_DMA_IRQS] = {}; static void dmairq_handler(void) { enum dmairq irq = __get_current_exception() - VTABLE_FIRST_IRQ; diff --git a/libhw_cr/rp2040_gpioirq.c b/libhw_cr/rp2040_gpioirq.c index 1ae74f9..5b3d616 100644 --- a/libhw_cr/rp2040_gpioirq.c +++ b/libhw_cr/rp2040_gpioirq.c @@ -15,7 +15,7 @@ struct gpioirq_handler_entry { gpioirq_handler_t fn; void *arg; }; -struct gpioirq_handler_entry gpioirq_handlers[NUM_BANK0_GPIOS][4] = {0}; +struct gpioirq_handler_entry gpioirq_handlers[NUM_BANK0_GPIOS][4] = {}; int gpioirq_core = -1; diff --git a/libhw_cr/rp2040_hwspi.c b/libhw_cr/rp2040_hwspi.c index c0b4fa4..3bf3f84 100644 --- a/libhw_cr/rp2040_hwspi.c +++ b/libhw_cr/rp2040_hwspi.c @@ -158,12 +158,14 @@ static void rp2040_hwspi_readwritev(struct rp2040_hwspi *self, const struct dupl uint8_t bogus_rx_dst; + size_t count = 0; int pruned_iovcnt = 0; - for (int i = 0; i < iovcnt; i++) + for (int i = 0; i < iovcnt; i++) { + count += iov[i].iov_len; if (iov[i].iov_len) pruned_iovcnt++; - if (!pruned_iovcnt) - return; + } + assert(count); /* It doesn't *really* matter which aliases we choose: * @@ -230,8 +232,8 @@ static void rp2040_hwspi_readwritev(struct rp2040_hwspi *self, const struct dupl }; j++; } - tx_data_blocks[pruned_iovcnt] = (typeof(tx_data_blocks[0])){0}; - rx_data_blocks[pruned_iovcnt] = (typeof(rx_data_blocks[0])){0}; + tx_data_blocks[pruned_iovcnt] = (typeof(tx_data_blocks[0])){}; + rx_data_blocks[pruned_iovcnt] = (typeof(rx_data_blocks[0])){}; /* If ctrl isn't the trigger then we need to make sure that * DMA_CTRL_IRQ_QUIET isn't cleared before the trigger * happens. */ diff --git a/libhw_cr/w5500.c b/libhw_cr/w5500.c index e676364..2893e8f 100644 --- a/libhw_cr/w5500.c +++ b/libhw_cr/w5500.c @@ -436,7 +436,7 @@ static void w5500_if_ifup(struct w5500 *chip, struct net_iface_config cfg) { static void w5500_if_ifdown(struct w5500 *chip) { log_debugf("if_down()"); - _w5500_if_up(chip, (struct net_iface_config){0}); + _w5500_if_up(chip, (struct net_iface_config){}); } static lo_interface net_stream_listener w5500_if_tcp_listen(struct w5500 *chip, uint16_t local_port) { @@ -608,10 +608,9 @@ static ssize_t w5500_tcp_writev(struct _w5500_socket *socket, const struct iovec size_t count = 0; for (int i = 0; i < iovcnt; i++) count += iov[i].iov_len; + assert(count); log_debugf("tcp_conn.write(%zu)", count); ASSERT_SELF(stream_conn, TCP); - if (count == 0) - return 0; /* What we really want is to pause until we receive an ACK for * some data we just queued, so that we can line up some new @@ -701,10 +700,9 @@ static ssize_t w5500_tcp_readv(struct _w5500_socket *socket, const struct iovec size_t count = 0; for (int i = 0; i < iovcnt; i++) count += iov[i].iov_len; + assert(count); log_debugf("tcp_conn.read(%zu)", count); ASSERT_SELF(stream_conn, TCP); - if (count == 0) - return 0; struct alarmclock_trigger trigger = {}; if (socket->read_deadline_ns) |