Get_band_defaults why use for loop

Why use the for loop to read Band, Channel, and HTMODE information in the "get_band_defaults" function of the mac80211.sh script,as follows:

get_band_defaults() {
	local phy="$1"

	for c in $(__get_band_defaults "$phy"); do
		local band="${c%%:*}"
		c="${c#*:}"
		local chan="${c%%:*}"
		c="${c#*:}"
		local mode="${c%%:*}"

		case "$band" in
			1) band=2g;;
			2) band=5g;;
			3) band=60g;;
			4) band=6g;;
			*) band="";;
		esac

		[ -n "$band" ] || continue
		[ -n "$mode_band" -a "$band" = "6g" ] && return

		mode_band="$band"
		channel="$chan"
		htmode="$mode"
	done
}

Because after the end of the loop, only the last Band, Channel, and HTMODE information are used, so I feel that the loop is not necessary.

(You migh want to move this thread to the For Developers section.)

Moved over.

1 Like

Not quite true.
There is the return statement inside the loop that has an impact.

1 Like

Not 6G can only return the last Band, Channel, and htmode information.Why it do this?
Thanks

I want to know why it designed like this

It has been modified by commit https://github.com/openwrt/openwrt/commit/8504212f65865449dd6b9ed9daa0ba9781f8f287 by @nbd
He might be able to answer you...