From 1f27ab0d4bb65425496ff4ed0fbbd0f5bb32786f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 23 Sep 2009 17:17:53 +0200 Subject: *: 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 --- networking/libiproute/rtm_map.c | 2 +- networking/libiproute/utils.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'networking/libiproute') diff --git a/networking/libiproute/rtm_map.c b/networking/libiproute/rtm_map.c index ca2f4436a..6fe5c4b75 100644 --- a/networking/libiproute/rtm_map.c +++ b/networking/libiproute/rtm_map.c @@ -88,7 +88,7 @@ int rtnl_rtntype_a2n(int *id, char *arg) res = RTN_THROW; else { res = strtoul(arg, &end, 0); - if (!end || end == arg || *end || res > 255) + if (end == arg || *end || res > 255) return -1; } *id = res; diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index c84d018eb..5f0971751 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c @@ -22,6 +22,7 @@ unsigned get_unsigned(char *arg, const char *errmsg) if (*arg) { res = strtoul(arg, &ptr, 0); +//FIXME: "" will be accepted too, is it correct?! if (!*ptr && res <= UINT_MAX) { return res; } @@ -36,6 +37,7 @@ uint32_t get_u32(char *arg, const char *errmsg) if (*arg) { res = strtoul(arg, &ptr, 0); +//FIXME: "" will be accepted too, is it correct?! if (!*ptr && res <= 0xFFFFFFFFUL) { return res; } @@ -50,6 +52,7 @@ uint16_t get_u16(char *arg, const char *errmsg) if (*arg) { res = strtoul(arg, &ptr, 0); +//FIXME: "" will be accepted too, is it correct?! if (!*ptr && res <= 0xFFFF) { return res; } -- cgit v1.2.3