minissdpc.c: fix variable redeclaration of p

This commit is contained in:
Thomas Bernard 2019-04-10 14:15:33 +02:00
parent 1ef1deec01
commit 5ae326a95e
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
1 changed files with 18 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $Id: minissdpc.c,v 1.32 2016/10/07 09:04:36 nanard Exp $ */ /* $Id: minissdpc.c,v 1.39 2019/04/10 12:09:17 nanard Exp $ */
/* vim: tabstop=4 shiftwidth=4 noexpandtab /* vim: tabstop=4 shiftwidth=4 noexpandtab
* Project : miniupnp * Project : miniupnp
* Web : http://miniupnp.free.fr/ * Web : http://miniupnp.free.fr/
@ -492,7 +492,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
struct sockaddr_storage sockudp_w; struct sockaddr_storage sockudp_w;
#else #else
int rv; int rv;
struct addrinfo hints, *servinfo, *p; struct addrinfo hints, *servinfo;
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
unsigned long _ttl = (unsigned long)ttl; unsigned long _ttl = (unsigned long)ttl;
@ -817,24 +817,26 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
#endif #endif
break; break;
} } else {
for(p = servinfo; p; p = p->ai_next) { struct addrinfo *p;
n = sendto(sudp, bufr, n, 0, p->ai_addr, MSC_CAST_INT p->ai_addrlen); for(p = servinfo; p; p = p->ai_next) {
if (n < 0) { n = sendto(sudp, bufr, n, 0, p->ai_addr, MSC_CAST_INT p->ai_addrlen);
if (n < 0) {
#ifdef DEBUG #ifdef DEBUG
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
if (getnameinfo(p->ai_addr, (socklen_t)p->ai_addrlen, hbuf, sizeof(hbuf), sbuf, if (getnameinfo(p->ai_addr, (socklen_t)p->ai_addrlen, hbuf, sizeof(hbuf), sbuf,
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) { sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
fprintf(stderr, "host:%s port:%s\n", hbuf, sbuf); fprintf(stderr, "host:%s port:%s\n", hbuf, sbuf);
} }
#endif #endif
PRINT_SOCKET_ERROR("sendto"); PRINT_SOCKET_ERROR("sendto");
continue; continue;
} else { } else {
sentok = 1; sentok = 1;
}
} }
freeaddrinfo(servinfo);
} }
freeaddrinfo(servinfo);
if(!sentok) { if(!sentok) {
if(error) if(error)
*error = MINISSDPC_SOCKET_ERROR; *error = MINISSDPC_SOCKET_ERROR;