MT#55283 convert endpoint_parse_any to bool

Change-Id: Ia6fd64615591efe1dfd6de4cc70a5642ea777331
pull/1910/head
Richard Fuchs 10 months ago
parent 4b13ada4e5
commit 927c85e5ff

@ -1179,7 +1179,7 @@ static int redis_hash_get_endpoint(struct endpoint *out, const struct redis_hash
if (redis_hash_get_str(&s, h, k))
return -1;
if (endpoint_parse_any(out, s.s))
if (!endpoint_parse_any(out, s.s))
return -1;
return 0;

@ -594,7 +594,7 @@ sockfamily_t *get_socket_family_rfc(const str *s) {
sockfamily_t *__get_socket_family_enum(enum socket_families i) {
return &__socket_families[i];
}
int endpoint_parse_any(endpoint_t *d, const char *s) {
bool endpoint_parse_any(endpoint_t *d, const char *s) {
int i;
sockfamily_t *fam;
unsigned int len;
@ -604,29 +604,29 @@ int endpoint_parse_any(endpoint_t *d, const char *s) {
ep = strrchr(s, ':');
if (!ep) {
if (strchr(s, '.'))
return -1;
return false;
/* just a port number */
d->port = atoi(s);
ZERO(d->address);
d->address.family = __get_socket_family_enum(SF_IP4);
return 0;
return true;
}
len = ep - s;
if (len >= sizeof(buf))
return -1;
return false;
d->port = atoi(ep+1);
if (d->port > 0xffff)
return -1;
return false;
sprintf(buf, "%.*s", len, s);
for (i = 0; i < __SF_LAST; i++) {
fam = &__socket_families[i];
if (fam->addr_parse(&d->address, buf)) {
d->address.family = fam;
return 0;
return true;
}
}
return -1;
return false;
}
static int socket_addrinfo_convert(sockaddr_t *a, struct addrinfo *res) {

@ -289,7 +289,7 @@ sockfamily_t *__get_socket_family_enum(enum socket_families);
bool sockaddr_parse_any(sockaddr_t *dst, const char *src);
bool sockaddr_parse_any_str(sockaddr_t *dst, const str *src);
bool sockaddr_parse_str(sockaddr_t *dst, sockfamily_t *fam, const str *src);
int endpoint_parse_any(endpoint_t *, const char *); // address (ip) optional
bool endpoint_parse_any(endpoint_t *, const char *); // address (ip) optional
int sockaddr_getaddrinfo_alt(sockaddr_t *a, sockaddr_t *a2, const char *s);
int endpoint_parse_any_getaddrinfo_alt(endpoint_t *d, endpoint_t *d2, const char *s); // address (ip or hostname) optional
INLINE int endpoint_parse_any_getaddrinfo(endpoint_t *d, const char *s);
@ -318,7 +318,7 @@ INLINE int endpoint_parse_port_any(endpoint_t *e, const char *p, unsigned int po
// address (ip) required
INLINE int endpoint_parse_any_full(endpoint_t *d, const char *s) {
int ret;
ret = endpoint_parse_any(d, s);
ret = endpoint_parse_any(d, s) ? 0 : -1;
if (ret)
return ret;
if (is_addr_unspecified(&d->address))
@ -354,7 +354,7 @@ INLINE int ipv46_any_convert(endpoint_t *ep) {
INLINE int endpoint_parse_any_str(endpoint_t *d, str *s) {
char tmp = s->s[s->len];
s->s[s->len] = '\0';
int ret = endpoint_parse_any(d, s->s);
int ret = endpoint_parse_any(d, s->s) ? 0 : -1;
s->s[s->len] = tmp;
return ret;
}

Loading…
Cancel
Save