[packages] olsrd: init: reduce code duplication by reusing already_in_schema()

changed scope/position of this function, and reuse it.

Signed-off-by: Bastian Bittorf <bittorf@bluebottle.com>

git-svn-id: svn://svn.openwrt.org/openwrt/packages/net/olsrd@36300 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
Saverio Proto 2013-04-10 10:48:36 +00:00
parent 34e1ff5702
commit 4ea4cb2969
1 changed files with 23 additions and 25 deletions

View File

@ -270,34 +270,32 @@ config_write_options() {
return 0
}
case " $schema " in
*" speed "*)
get_value_for_entry "speed"
already_in_schema()
{
case " $schema " in
*" $1 "*)
return 0
;;
*)
return 1
;;
esac
}
if [ 2>/dev/null $value -gt 0 -a $value -le 20 ]; then
speed="$value"
else
log "$funcname() Warning: invalid speed-value: '$value' - allowed integers: 1...20, fallback to 6"
speed=6
fi
already_in_schema "speed" && {
get_value_for_entry "speed"
already_in_schema()
{
case " $schema " in
*" $1 "*)
return 0
;;
*)
return 1
;;
esac
}
if [ 2>/dev/null $value -gt 0 -a $value -le 20 ]; then
speed="$value"
else
log "$funcname() Warning: invalid speed-value: '$value' - allowed integers: 1...20, fallback to 6"
speed=6
fi
for schema_entry in $list_speed_vars; do {
already_in_schema "$schema_entry" || schema="$schema $schema_entry"
} done
;;
esac
for schema_entry in $list_speed_vars; do {
already_in_schema "$schema_entry" || schema="$schema $schema_entry"
} done
}
for schema_entry in $schema; do
if [ -n "$speed" ]; then # like sven-ola freifunk firmware fff-1.7.4