examples/mqttc: Fix handling of getaddrinfo errors
commit 36d4bfa774
set a hostname to work
around getaddrinfo failing. getaddrinfo returns a non-zero value on
error, and there should be an early return after the error message is
printed.
This commit is contained in:
parent
2a4db81217
commit
ec93611307
@ -153,9 +153,10 @@ static int initserver(const FAR struct mqttc_cfg_s *cfg)
|
|||||||
printf("Connecting to %s:%s...\n", cfg->host, cfg->port);
|
printf("Connecting to %s:%s...\n", cfg->host, cfg->port);
|
||||||
|
|
||||||
ret = getaddrinfo(cfg->host, cfg->port, &hints, &servinfo);
|
ret = getaddrinfo(cfg->host, cfg->port, &hints, &servinfo);
|
||||||
if (ret < 0)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
printf("ERROR! getaddrinfo() failed: %s\n", gai_strerror(ret));
|
printf("ERROR! getaddrinfo() failed: %s\n", gai_strerror(ret));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
itr = servinfo;
|
itr = servinfo;
|
||||||
|
Loading…
Reference in New Issue
Block a user