[OpenWrt-Devel] [PATCH 1/2] base-files: add network_get_ipaddrs_all()

Bastian Bittorf bittorf at bluebottle.com
Mon Oct 6 14:54:14 EDT 2014


* Mathias Kresin <openwrt at kresin.me> [06.10.2014 20:23]:
> +network_get_ipaddrs_all() {
> +	local __addr
> +	local __list=""

1)
is there a special reason for starting everything with '__'?
(the vars are local anyway).

2)
is there a special reason not to name the vars $1 and $2? e.g.

local dest_var="$1"
local interface="$2"

3)
why you append a '1' to the list if it's IPv6? (make it clear in the code)

4)
use a special var for the list and for the element of the list.
("for __addr in $__addr; do" -> for ELEMENT in $LIST)

> +	if __network_ifstatus "__addr" "$2" "['ipv4-address','ipv6-address','ipv6-prefix-assignment'][*].address"; then
> +		for __addr in $__addr; do
> +			case "$__addr" in
> +				*:) __list="${__list:+$__list }${__addr}1" ;;
> +				*)  __list="${__list:+$__list }${__addr}"  ;;
> +			esac
> +		done
> +
> +		export "$1=$__list"
> +		return 0
> +	fi
> +
> +	unset "$1"
> +	return 1
> +}

bye, bastian
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list