diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-04 01:14:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-04 01:14:19 +0200 |
commit | 76622dbd1666ca3e0e45e97d880836296ecb0dad (patch) | |
tree | 7e4e471854f919fea2146fb6261fb9cce138027c | |
parent | fd2dc53ba49ed2bdb077a45f4793d397fa92d2da (diff) | |
download | busybox-w32-76622dbd1666ca3e0e45e97d880836296ecb0dad.tar.gz busybox-w32-76622dbd1666ca3e0e45e97d880836296ecb0dad.tar.bz2 busybox-w32-76622dbd1666ca3e0e45e97d880836296ecb0dad.zip |
ash: code shrink
function old new delta
ulimitcmd 489 415 -74
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/shell/ash.c b/shell/ash.c index e5503a140..444a6961b 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -12909,8 +12909,7 @@ printlim(enum limtype how, const struct rlimit *limit, | |||
12909 | static int FAST_FUNC | 12909 | static int FAST_FUNC |
12910 | ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 12910 | ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
12911 | { | 12911 | { |
12912 | int c; | 12912 | rlim_t val; |
12913 | rlim_t val = 0; | ||
12914 | enum limtype how = SOFT | HARD; | 12913 | enum limtype how = SOFT | HARD; |
12915 | const struct limits *l; | 12914 | const struct limits *l; |
12916 | int set, all = 0; | 12915 | int set, all = 0; |
@@ -12971,6 +12970,7 @@ ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
12971 | continue; | 12970 | continue; |
12972 | 12971 | ||
12973 | set = *argptr ? 1 : 0; | 12972 | set = *argptr ? 1 : 0; |
12973 | val = 0; | ||
12974 | if (set) { | 12974 | if (set) { |
12975 | char *p = *argptr; | 12975 | char *p = *argptr; |
12976 | 12976 | ||
@@ -12979,15 +12979,13 @@ ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
12979 | if (strncmp(p, "unlimited\n", 9) == 0) | 12979 | if (strncmp(p, "unlimited\n", 9) == 0) |
12980 | val = RLIM_INFINITY; | 12980 | val = RLIM_INFINITY; |
12981 | else { | 12981 | else { |
12982 | val = (rlim_t) 0; | 12982 | if (sizeof(val) == sizeof(int)) |
12983 | 12983 | val = bb_strtou(p, NULL, 10); | |
12984 | while ((c = *p++) >= '0' && c <= '9') { | 12984 | else if (sizeof(val) == sizeof(long)) |
12985 | val = (val * 10) + (long)(c - '0'); | 12985 | val = bb_strtoul(p, NULL, 10); |
12986 | // val is actually 'unsigned long int' and can't get < 0 | 12986 | else |
12987 | if (val < (rlim_t) 0) | 12987 | val = bb_strtoull(p, NULL, 10); |
12988 | break; | 12988 | if (errno) |
12989 | } | ||
12990 | if (c) | ||
12991 | ash_msg_and_raise_error("bad number"); | 12989 | ash_msg_and_raise_error("bad number"); |
12992 | val <<= l->factor_shift; | 12990 | val <<= l->factor_shift; |
12993 | } | 12991 | } |