Skip to content

Commit afb664f

Browse files
authored
Merge pull request #635 from bytecodealliance/main
socket: Explicit narrowing type cast and add missing static keywords (bytecodealliance#1539)
2 parents 1a44a9b + 5b10d4e commit afb664f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

core/iwasm/libraries/lib-socket/src/wasi/wasi_socket_ext.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
145145
error = __wasi_sock_accept(sockfd, 0, &new_sockfd);
146146
HANDLE_ERROR(error)
147147

148-
error = getpeername(new_sockfd, addr, addrlen);
149-
HANDLE_ERROR(error)
148+
if (getpeername(new_sockfd, addr, addrlen) == -1) {
149+
return -1;
150+
}
150151

151152
return new_sockfd;
152153
}
@@ -556,7 +557,7 @@ freeaddrinfo(struct addrinfo *res)
556557
free(res);
557558
}
558559

559-
struct timeval
560+
static struct timeval
560561
time_us_to_timeval(uint64_t time_us)
561562
{
562563
struct timeval tv;
@@ -565,13 +566,13 @@ time_us_to_timeval(uint64_t time_us)
565566
return tv;
566567
}
567568

568-
uint64_t
569+
static uint64_t
569570
timeval_to_time_us(struct timeval tv)
570571
{
571572
return (tv.tv_sec * 1000000UL) + tv.tv_usec;
572573
}
573574

574-
int
575+
static int
575576
get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
576577
socklen_t *__restrict optlen)
577578
{
@@ -638,7 +639,7 @@ get_sol_socket_option(int sockfd, int optname, void *__restrict optval,
638639
}
639640
}
640641

641-
int
642+
static int
642643
get_ipproto_tcp_option(int sockfd, int optname, void *__restrict optval,
643644
socklen_t *__restrict optlen)
644645
{
@@ -677,7 +678,7 @@ get_ipproto_tcp_option(int sockfd, int optname, void *__restrict optval,
677678
}
678679
}
679680

680-
int
681+
static int
681682
get_ipproto_ip_option(int sockfd, int optname, void *__restrict optval,
682683
socklen_t *__restrict optlen)
683684
{
@@ -707,7 +708,7 @@ get_ipproto_ip_option(int sockfd, int optname, void *__restrict optval,
707708
}
708709
}
709710

710-
int
711+
static int
711712
get_ipproto_ipv6_option(int sockfd, int optname, void *__restrict optval,
712713
socklen_t *__restrict optlen)
713714
{
@@ -754,7 +755,7 @@ getsockopt(int sockfd, int level, int optname, void *__restrict optval,
754755
}
755756
}
756757

757-
int
758+
static int
758759
set_sol_socket_option(int sockfd, int optname, const void *optval,
759760
socklen_t optlen)
760761
{
@@ -838,7 +839,7 @@ set_sol_socket_option(int sockfd, int optname, const void *optval,
838839
}
839840
}
840841

841-
int
842+
static int
842843
set_ipproto_tcp_option(int sockfd, int optname, const void *optval,
843844
socklen_t optlen)
844845
{
@@ -878,7 +879,7 @@ set_ipproto_tcp_option(int sockfd, int optname, const void *optval,
878879
}
879880
}
880881

881-
int
882+
static int
882883
set_ipproto_ip_option(int sockfd, int optname, const void *optval,
883884
socklen_t optlen)
884885
{
@@ -931,7 +932,7 @@ set_ipproto_ip_option(int sockfd, int optname, const void *optval,
931932
}
932933
}
933934

934-
int
935+
static int
935936
set_ipproto_ipv6_option(int sockfd, int optname, const void *optval,
936937
socklen_t optlen)
937938
{

0 commit comments

Comments
 (0)