Browse Source

MT#55283 convert bind to bool

Change-Id: Ic127aabf04e3185293e77194953f4eb93dd1a771
pull/1910/head
Richard Fuchs 10 months ago
parent
commit
eb172ce029
2 changed files with 6 additions and 6 deletions
  1. +5
    -5
      lib/socket.c
  2. +1
    -1
      lib/socket.h

+ 5
- 5
lib/socket.c View File

@ -23,7 +23,7 @@ static int __ip4_eq(const sockaddr_t *a, const sockaddr_t *b);
static int __ip6_eq(const sockaddr_t *a, const sockaddr_t *b);
static bool __ip4_is_specified(const sockaddr_t *a);
static bool __ip6_is_specified(const sockaddr_t *a);
static int __ip_bind(socket_t *s, unsigned int, const sockaddr_t *);
static bool __ip_bind(socket_t *s, unsigned int, const sockaddr_t *);
static int __ip_connect(socket_t *s, const endpoint_t *);
static int __ip_listen(socket_t *s, int backlog);
static int __ip_accept(socket_t *s, socket_t *new_sock);
@ -264,18 +264,18 @@ static bool __ip6_addrport2sockaddr(void *p, const sockaddr_t *sa, unsigned int
sin->sin6_addr = sa->ipv6;
return true;
}
static int __ip_bind(socket_t *s, unsigned int port, const sockaddr_t *a) {
static bool __ip_bind(socket_t *s, unsigned int port, const sockaddr_t *a) {
struct sockaddr_storage sin;
s->family->addrport2sockaddr(&sin, a, port);
if (bind(s->fd, (struct sockaddr *) &sin, s->family->sockaddr_size)) {
__C_DBG("bind fail, fd=%d, port=%d", s->fd, s->local.port);
return -1;
return false;
} else {
__C_DBG("bind success, fd=%d, port=%d", s->fd, s->local.port);
}
return 0;
return true;
}
static int __ip_connect(socket_t *s, const endpoint_t *ep) {
struct sockaddr_storage sin;
@ -755,7 +755,7 @@ bool open_socket(socket_t *r, int type, unsigned int port, const sockaddr_t *sa)
goto fail;
}
if (fam->bind(r, port, sa)) {
if (!fam->bind(r, port, sa)) {
__C_DBG("open socket fail, fd=%d, port=%d", r->fd, port);
goto fail;
}


+ 1
- 1
lib/socket.h View File

@ -69,7 +69,7 @@ struct socket_family {
bool (*sockaddr2endpoint)(endpoint_t *, const void *);
bool (*endpoint2sockaddr)(void *, const endpoint_t *);
bool (*addrport2sockaddr)(void *, const sockaddr_t *, unsigned int);
int (*bind)(socket_t *, unsigned int, const sockaddr_t *);
bool (*bind)(socket_t *, unsigned int, const sockaddr_t *);
int (*connect)(socket_t *, const endpoint_t *);
int (*listen)(socket_t *, int);
int (*accept)(socket_t *, socket_t *);


Loading…
Cancel
Save