diff options
author | Denys Vlasenko | 2009-09-23 17:17:53 +0200 |
---|---|---|
committer | Denys Vlasenko | 2009-09-23 17:17:53 +0200 |
commit | 1f27ab0d4bb65425496ff4ed0fbbd0f5bb32786f (patch) | |
tree | a7181ba3c498570257040c8663f125938ecad0a6 /modutils | |
parent | 8d338173a4668740b1ab4a40d1d26cd25402e406 (diff) | |
download | busybox-1f27ab0d4bb65425496ff4ed0fbbd0f5bb32786f.zip busybox-1f27ab0d4bb65425496ff4ed0fbbd0f5bb32786f.tar.gz |
*: 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>
Diffstat (limited to 'modutils')
-rw-r--r-- | modutils/modutils-24.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c index 9f91c99..e5ff54d 100644 --- a/modutils/modutils-24.c +++ b/modutils/modutils-24.c @@ -2432,11 +2432,11 @@ new_process_module_arguments(struct obj_file *f, const char *options) loc = contents + sym->value; if (*pinfo == 'c') { - if (!isdigit(*(pinfo + 1))) { + if (!isdigit(pinfo[1])) { bb_error_msg_and_die("parameter type 'c' for %s must be followed by" " the maximum size", param); } - charssize = strtoul(pinfo + 1, (char **) NULL, 10); + charssize = strtoul(pinfo + 1, NULL, 10); } if (val == NULL) { @@ -2449,6 +2449,8 @@ new_process_module_arguments(struct obj_file *f, const char *options) n = 0; p = val; while (*p != 0) { + char *endp; + if (++n > max) bb_error_msg_and_die("too many values for %s (max %d)", param, max); @@ -2472,19 +2474,23 @@ new_process_module_arguments(struct obj_file *f, const char *options) p += len; break; case 'b': - *loc++ = strtoul(p, &p, 0); + *loc++ = strtoul(p, &endp, 0); + p = endp; /* gcc likes temp var for &endp */ break; case 'h': - *(short *) loc = strtoul(p, &p, 0); + *(short *) loc = strtoul(p, &endp, 0); loc += tgt_sizeof_short; + p = endp; break; case 'i': - *(int *) loc = strtoul(p, &p, 0); + *(int *) loc = strtoul(p, &endp, 0); loc += tgt_sizeof_int; + p = endp; break; case 'l': - *(long *) loc = strtoul(p, &p, 0); + *(long *) loc = strtoul(p, &endp, 0); loc += tgt_sizeof_long; + p = endp; break; default: bb_error_msg_and_die("unknown parameter type '%c' for %s", |