diff --git a/src/libCom/misc/aToIPAddr.c b/src/libCom/misc/aToIPAddr.c index abd72d501..b5b64b828 100644 --- a/src/libCom/misc/aToIPAddr.c +++ b/src/libCom/misc/aToIPAddr.c @@ -112,34 +112,20 @@ epicsShareFunc int epicsShareAPI /* * check for a valid host name before giving up */ - status = sscanf (pAddrString, " %511[^:]:%hu", hostName, &port); - if (status>0) { - if (status==2) { - status = hostToIPAddr (hostName, &ina); - if (status==0) { - return initIPAddr (ina, port, pIP); - } - else { - return -1; - } + status = sscanf ( pAddrString, " %511[^:]:%hu", hostName, &port ); + if ( status >= 1 ) { + if ( status == 1 ) { + port = defaultPort; } - else { - return-1; - } - } - else { - status = sscanf (pAddrString, " %511s", hostName, &port); - if (status==1) { - status = hostToIPAddr (hostName, &ina); - if (status==0) { - return initIPAddr (ina, defaultPort, pIP); - } - else { - return -1; - } - } + status = hostToIPAddr ( hostName, &ina ); + if ( status == 0 ) { + return initIPAddr ( ina, port, pIP ); + } else { return -1; } + } + else { + return -1; } }