mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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
1 changed files with 2 additions and 1 deletions
|
|
@ -153,9 +153,10 @@ static int initserver(const FAR struct mqttc_cfg_s *cfg)
|
|||
printf("Connecting to %s:%s...\n", cfg->host, cfg->port);
|
||||
|
||||
ret = getaddrinfo(cfg->host, cfg->port, &hints, &servinfo);
|
||||
if (ret < 0)
|
||||
if (ret != OK)
|
||||
{
|
||||
printf("ERROR! getaddrinfo() failed: %s\n", gai_strerror(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
itr = servinfo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue