MT#55283 convert open_socket to bool

Change-Id: I715afc937f6b1cbc124ff14a0428f781f58cd050
pull/1910/head
Richard Fuchs 2 months ago
parent e7a0bad24e
commit c2ba54e615

@ -1047,7 +1047,7 @@ struct local_intf *get_any_interface_address(const struct logical_intf *lif, soc
static bool add_socket(socket_t *r, unsigned int port, struct intf_spec *spec, const str *label) {
__C_DBG("An attempt to open a socket for the port: '%u'", port);
if (open_socket(r, SOCK_DGRAM, port, &spec->local_address.addr)) {
if (!open_socket(r, SOCK_DGRAM, port, &spec->local_address.addr)) {
__C_DBG("Can't open a socket for the port: '%d'", port);
return false;
}

@ -78,7 +78,7 @@ static int tcp_listener_init(socket_t *sock, const endpoint_t *ep,
cb->p = obj_get_o(obj);
cb->ul = sock;
if (open_socket(sock, SOCK_STREAM, ep->port, &ep->address))
if (!open_socket(sock, SOCK_STREAM, ep->port, &ep->address))
goto fail;
if (sock->family->listen(sock, 5))
goto fail;

@ -86,7 +86,7 @@ int udp_listener_init(socket_t *sock, const endpoint_t *ep,
cb->p = obj_get_o(obj);
cb->ul = sock;
if (open_socket(sock, SOCK_DGRAM, ep->port, &ep->address))
if (!open_socket(sock, SOCK_DGRAM, ep->port, &ep->address))
goto fail;
socket_pktinfo(sock);

@ -305,10 +305,6 @@ void free_sfd_intf_list(struct sfd_intf_list *il);
void free_release_sfd_intf_list(struct sfd_intf_list *il);
void free_socket_intf_list(struct socket_intf_list *il);
INLINE int open_intf_socket(socket_t *r, unsigned int port, const struct local_intf *lif) {
return open_socket(r, SOCK_DGRAM, port, &lif->spec->local_address.addr);
}
void kernelize(struct packet_stream *);
void __unkernelize(struct packet_stream *, const char *);
void unkernelize(struct packet_stream *, const char *);

@ -735,14 +735,14 @@ static int __socket(socket_t *r, int type, sockfamily_t *fam) {
return 0;
}
int open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *sa) {
bool open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *sa) {
sockfamily_t *fam;
fam = sa->family;
if (__socket(r, type, fam)) {
__C_DBG("open socket fail, fd=%d", r->fd);
return -1;
return false;
}
nonblock(r->fd);
@ -765,11 +765,11 @@ int open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *sa)
__C_DBG("open socket success, fd=%d, port=%d", r->fd, port);
return 0;
return true;
fail:
close_socket(r);
return -1;
return false;
}
int open_v46_socket(socket_t *r, int type) {

@ -274,7 +274,7 @@ INLINE int socket_cpu_affinity(socket_t *s, int cpu) {
void socket_init(void);
int open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *);
bool open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *);
int open_v46_socket(socket_t *r, int type);
int connect_socket(socket_t *r, int type, const endpoint_t *ep);
int connect_socket_nb(socket_t *r, int type, const endpoint_t *ep); // 1 == in progress

Loading…
Cancel
Save