brctl: fixing stp parameters incompatibility

function                                             old     new   delta
static.stp_opts                                        -      23     +23
brctl_main                                          1148    1169     +21
packed_usage                                       26786   26794      +8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 52/0)               Total: 52 bytes

Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Maciek Borzecki 2010-03-23 05:18:38 +01:00 committed by Denys Vlasenko
parent 1c3f117ca4
commit 30ebd7bd78
2 changed files with 18 additions and 13 deletions

View File

@ -187,7 +187,7 @@
"\n setpathcost BRIDGE COST Set path cost" \ "\n setpathcost BRIDGE COST Set path cost" \
"\n setportprio BRIDGE PRIO Set port priority" \ "\n setportprio BRIDGE PRIO Set port priority" \
"\n setbridgeprio BRIDGE PRIO Set bridge priority" \ "\n setbridgeprio BRIDGE PRIO Set bridge priority" \
"\n stp BRIDGE [1|0] STP on/off" \ "\n stp BRIDGE [1/yes/on|0/no/off] STP on/off" \
) \ ) \
#define bunzip2_trivial_usage \ #define bunzip2_trivial_usage \

View File

@ -59,7 +59,7 @@ static ALWAYS_INLINE void strtotimeval(struct timeval *tv,
tv->tv_usec = 1000000 * (secs - tv->tv_sec); tv->tv_usec = 1000000 * (secs - tv->tv_sec);
} }
static ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv) static ALWAYS_INLINE unsigned long tv_to_jiffies(const struct timeval *tv)
{ {
unsigned long long jif; unsigned long long jif;
@ -68,7 +68,7 @@ static ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv)
return jif/10000; return jif/10000;
} }
# if 0 # if 0
static void __jiffies_to_tv(struct timeval *tv, unsigned long jiffies) static void jiffies_to_tv(struct timeval *tv, unsigned long jiffies)
{ {
unsigned long long tvusec; unsigned long long tvusec;
@ -81,7 +81,7 @@ static unsigned long str_to_jiffies(const char *time_str)
{ {
struct timeval tv; struct timeval tv;
strtotimeval(&tv, time_str); strtotimeval(&tv, time_str);
return __tv_to_jiffies(&tv); return tv_to_jiffies(&tv);
} }
static void arm_ioctl(unsigned long *args, static void arm_ioctl(unsigned long *args,
@ -220,9 +220,14 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
} }
#if ENABLE_FEATURE_BRCTL_FANCY #if ENABLE_FEATURE_BRCTL_FANCY
if (key == ARG_stp) { /* stp */ if (key == ARG_stp) { /* stp */
/* FIXME: parsing yes/y/on/1 versus no/n/off/0 is too involved */ static const char stp_opts[] ALIGN1 =
arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, "0\0" "off\0" "n\0" "no\0" /* 0 .. 3 */
(unsigned)(**argv - '0'), 0); "1\0" "on\0" "y\0" "yes\0"; /* 4 .. 7 */
int onoff = index_in_strings(stp_opts, *argv);
if (onoff < 0)
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
onoff = (unsigned)onoff / 4;
arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, onoff, 0);
goto fire; goto fire;
} }
if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */ if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */