diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-09-11 09:54:02 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-09-11 09:54:02 -0700 |
commit | b367ca379ad97763f28a41f601680c376c3de040 (patch) | |
tree | 237b1c272cb22573d976951a0716b37b5c02c453 /gethost.c | |
parent | 88380275fe13af5238955047f6b018e6e6a3adc8 (diff) | |
download | xorg-app-xauth-b367ca379ad97763f28a41f601680c376c3de040.tar.gz |
Variable scope reductions, as suggested by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'gethost.c')
-rw-r--r-- | gethost.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -67,13 +67,6 @@ in this Software without prior written authorization from The Open Group. const char * get_hostname (Xauth *auth) { -#ifdef TCPCONN - static struct hostent *hp; - int af; - - hp = NULL; -#endif - if (auth->address_length == 0) return "Illegal Address"; #ifdef TCPCONN @@ -83,6 +76,9 @@ get_hostname (Xauth *auth) #endif ) { + static struct hostent *hp = NULL; + int af; + #if defined(IPv6) && defined(AF_INET6) if (auth->family == FamilyInternet6) af = AF_INET6; @@ -167,7 +163,6 @@ struct addrlist *get_address_info ( #if defined(IPv6) && defined(AF_INET6) struct addrlist *lastrv = NULL; struct addrinfo *firstai = NULL; - struct addrinfo *ai = NULL; struct addrinfo hints; #else unsigned int hostinetaddr; @@ -252,7 +247,7 @@ struct addrlist *get_address_info ( hints.ai_socktype = SOCK_STREAM; /* only interested in TCP */ hints.ai_protocol = 0; if (getaddrinfo(host,NULL,&hints,&firstai) !=0) return NULL; - for (ai = firstai; ai != NULL; ai = ai->ai_next) { + for (struct addrinfo *ai = firstai; ai != NULL; ai = ai->ai_next) { struct addrlist *duplicate; len = 0; |