1
1

Simplify the code a little bit by recognizing that end=start isn't an error, but just indicates a partial address typical of CIDR notation.

This commit was SVN r24757.
Этот коммит содержится в:
Ralph Castain 2011-06-07 11:33:22 +00:00
родитель 666fdeab8f
Коммит 4c06c9c07c

Просмотреть файл

@ -494,13 +494,17 @@ static uint32_t parse_ipv4_dots(const char *addr, uint32_t* net, int* dots)
{ {
const char *start = addr, *end; const char *start = addr, *end;
uint32_t n[]={0,0,0,0}; uint32_t n[]={0,0,0,0};
int i, rc = OPAL_SUCCESS; int i;
/* now assemble the address */ /* now assemble the address */
for( i = 0; i < 4 && 0 < strlen(start); i++ ) { for( i = 0; i < 4; i++ ) {
n[i] = strtoul(start, (char**)&end, 10); n[i] = strtoul(start, (char**)&end, 10);
if( end == start ) { /* error case: use what we have so far */ if( end == start ) {
rc = OPAL_ERR_NETWORK_NOT_PARSEABLE; /* this is not an error, but indicates that
* we were given a partial address - e.g.,
* 192.168 - usually indicating an IP range
* in CIDR notation. So just return what we have
*/
break; break;
} }
/* did we read something sensible? */ /* did we read something sensible? */
@ -513,7 +517,7 @@ static uint32_t parse_ipv4_dots(const char *addr, uint32_t* net, int* dots)
} }
*dots = i; *dots = i;
*net = OPAL_IF_ASSEMBLE_NETWORK(n[0], n[1], n[2], n[3]); *net = OPAL_IF_ASSEMBLE_NETWORK(n[0], n[1], n[2], n[3]);
return rc; return OPAL_SUCCESS;
} }
int int