ash: code shrink

function                                             old     new   delta
ulimitcmd                                            489     415     -74

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-10-04 01:14:19 +02:00
parent fd2dc53ba4
commit 76622dbd16

View File

@ -12909,8 +12909,7 @@ printlim(enum limtype how, const struct rlimit *limit,
static int FAST_FUNC static int FAST_FUNC
ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{ {
int c; rlim_t val;
rlim_t val = 0;
enum limtype how = SOFT | HARD; enum limtype how = SOFT | HARD;
const struct limits *l; const struct limits *l;
int set, all = 0; int set, all = 0;
@ -12971,6 +12970,7 @@ ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
continue; continue;
set = *argptr ? 1 : 0; set = *argptr ? 1 : 0;
val = 0;
if (set) { if (set) {
char *p = *argptr; char *p = *argptr;
@ -12979,15 +12979,13 @@ ulimitcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
if (strncmp(p, "unlimited\n", 9) == 0) if (strncmp(p, "unlimited\n", 9) == 0)
val = RLIM_INFINITY; val = RLIM_INFINITY;
else { else {
val = (rlim_t) 0; if (sizeof(val) == sizeof(int))
val = bb_strtou(p, NULL, 10);
while ((c = *p++) >= '0' && c <= '9') { else if (sizeof(val) == sizeof(long))
val = (val * 10) + (long)(c - '0'); val = bb_strtoul(p, NULL, 10);
// val is actually 'unsigned long int' and can't get < 0 else
if (val < (rlim_t) 0) val = bb_strtoull(p, NULL, 10);
break; if (errno)
}
if (c)
ash_msg_and_raise_error("bad number"); ash_msg_and_raise_error("bad number");
val <<= l->factor_shift; val <<= l->factor_shift;
} }