From 7a0e44998f426752c58975ae686d8e88aa131195 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sat, 11 May 2024 15:58:48 +0200 Subject: added error handler per connection type; improved handlers API and error reporting --- ecp/src/platform/fe310/transport.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ecp/src/platform/fe310') diff --git a/ecp/src/platform/fe310/transport.c b/ecp/src/platform/fe310/transport.c index bc758c9..35addfa 100644 --- a/ecp/src/platform/fe310/transport.c +++ b/ecp/src/platform/fe310/transport.c @@ -66,11 +66,12 @@ int ecp_tr_addr_set(ecp_tr_addr_t *addr, void *addr_s) { } int ecp_tr_open(ECPSocket *sock, ecp_tr_addr_t *addr) { - sock->sock = eos_sock_open_udp(packet_handler, NULL); - if (sock->sock < 0) { - sock->sock = 0; - return ECP_ERR; - } + int rv; + + rv = eos_sock_open_udp(packet_handler, NULL); + if (rv < 0) return ECP_ERR_OPEN; + + sock->sock = rv; _ecp_tr_sock = sock; return ECP_OK; @@ -97,7 +98,7 @@ ssize_t ecp_tr_send(ECPSocket *sock, ECPBuffer *packet, size_t pkt_size, ecp_tr_ } else { buf = eos_net_alloc(); } - if (buf == NULL) return ECP_ERR; + if (buf == NULL) return ECP_ERR_ALLOC; rv = eos_sock_sendto_async(sock->sock, reply ? NULL : packet->buffer, pkt_size, addr, buf, !!(flags & ECP_SEND_FLAG_MORE)); if (rv) return ECP_ERR_SEND; -- cgit v1.2.3