Skip to content

Commit 4c06c9c

Browse files
author
Ralph Castain
committed
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.
1 parent 666fdea commit 4c06c9c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

opal/util/if.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,17 @@ static uint32_t parse_ipv4_dots(const char *addr, uint32_t* net, int* dots)
494494
{
495495
const char *start = addr, *end;
496496
uint32_t n[]={0,0,0,0};
497-
int i, rc = OPAL_SUCCESS;
497+
int i;
498498

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

519523
int

0 commit comments

Comments
 (0)