[misc] Coverity fixups

This commit is contained in:
ejurgensen 2022-01-20 20:10:47 +01:00
parent ad4c7fd74c
commit 6f6a9c6cb9

View File

@ -258,7 +258,7 @@ net_bind(short unsigned *port, int type, const char *log_service_name)
char strport[8]; char strport[8];
int yes = 1; int yes = 1;
int no = 0; int no = 0;
int fd; int fd = -1;
int ret; int ret;
cfgaddr = cfg_getstr(cfg_getsec(cfg, "general"), "bind_address"); cfgaddr = cfg_getstr(cfg_getsec(cfg, "general"), "bind_address");
@ -275,7 +275,7 @@ net_bind(short unsigned *port, int type, const char *log_service_name)
return -1; return -1;
} }
for (ptr = servinfo, fd = -1; ptr != NULL; ptr = ptr->ai_next) for (ptr = servinfo; ptr != NULL; ptr = ptr->ai_next)
{ {
if (fd >= 0) if (fd >= 0)
close(fd); close(fd);
@ -338,7 +338,8 @@ net_bind(short unsigned *port, int type, const char *log_service_name)
return fd; return fd;
error: error:
close(fd); if (fd >= 0)
close(fd);
return -1; return -1;
} }