*: optimize code size in strtoul calls

function                                             old     new   delta
bb_parse_mode                                        433     431      -2
rtnl_rtntype_a2n                                     202     198      -4
ParseField                                           511     498     -13
bb_init_module_24                                   4730    4675     -55
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-74)             Total: -74 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2009-09-23 17:17:53 +02:00
parent 8d338173a4
commit 1f27ab0d4b
8 changed files with 37 additions and 23 deletions

View File

@@ -816,7 +816,7 @@ static int bb__parsepwent(void *data, char *line)
i = 0;
do {
p = ((char *) ((struct passwd *) data)) + pw_off[i];
p = (char *) data + pw_off[i];
if ((i & 6) ^ 2) { /* i!=2 and i!=3 */
*((char **) p) = line;
@@ -873,7 +873,7 @@ static int bb__parsegrent(void *data, char *line)
end_of_buf = ((struct group *) data)->gr_name; /* Evil hack! */
i = 0;
do {
p = ((char *) ((struct group *) data)) + gr_off[i];
p = (char *) data + gr_off[i];
if (i < 2) {
*((char **) p) = line;
@@ -966,15 +966,15 @@ static const unsigned char sp_off[] ALIGN1 = {
offsetof(struct spwd, sp_flag) /* 8 - not a char ptr */
};
static int bb__parsespent(void *data, char * line)
static int bb__parsespent(void *data, char *line)
{
char *endptr;
char *p;
int i;
i = 0;
do {
p = ((char *) ((struct spwd *) data)) + sp_off[i];
while (1) {
p = (char *) data + sp_off[i];
if (i < 2) {
*((char **) p) = line;
line = strchr(line, ':');
@@ -982,10 +982,10 @@ static int bb__parsespent(void *data, char * line)
break;
}
} else {
*((long *) p) = (long) strtoul(line, &endptr, 10);
*((long *) p) = strtoul(line, &endptr, 10);
if (endptr == line) {
*((long *) p) = ((i != 8) ? -1L : ((long)(~0UL)));
*((long *) p) = (i != 8) ? -1L : (long)(~0UL);
}
line = endptr;
@@ -1003,9 +1003,9 @@ static int bb__parsespent(void *data, char * line)
}
*line++ = 0;
*line++ = '\0';
++i;
} while (1);
}
return EINVAL;
}