util: fix a shadowed variable name srv
This commit is contained in:
parent
d9bda20849
commit
b188c78432
10
util.c
10
util.c
@ -19,7 +19,7 @@ eprint(const char *fmt, ...) {
|
|||||||
static int
|
static int
|
||||||
dial(char *host, char *port) {
|
dial(char *host, char *port) {
|
||||||
static struct addrinfo hints;
|
static struct addrinfo hints;
|
||||||
int srv;
|
int fd;
|
||||||
struct addrinfo *res, *r;
|
struct addrinfo *res, *r;
|
||||||
|
|
||||||
memset(&hints, 0, sizeof hints);
|
memset(&hints, 0, sizeof hints);
|
||||||
@ -28,16 +28,16 @@ dial(char *host, char *port) {
|
|||||||
if(getaddrinfo(host, port, &hints, &res) != 0)
|
if(getaddrinfo(host, port, &hints, &res) != 0)
|
||||||
eprint("error: cannot resolve hostname '%s':", host);
|
eprint("error: cannot resolve hostname '%s':", host);
|
||||||
for(r = res; r; r = r->ai_next) {
|
for(r = res; r; r = r->ai_next) {
|
||||||
if((srv = socket(r->ai_family, r->ai_socktype, r->ai_protocol)) == -1)
|
if((fd = socket(r->ai_family, r->ai_socktype, r->ai_protocol)) == -1)
|
||||||
continue;
|
continue;
|
||||||
if(connect(srv, r->ai_addr, r->ai_addrlen) == 0)
|
if(connect(fd, r->ai_addr, r->ai_addrlen) == 0)
|
||||||
break;
|
break;
|
||||||
close(srv);
|
close(fd);
|
||||||
}
|
}
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
if(!r)
|
if(!r)
|
||||||
eprint("error: cannot connect to host '%s'\n", host);
|
eprint("error: cannot connect to host '%s'\n", host);
|
||||||
return srv;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
|
Loading…
Reference in New Issue
Block a user