diff mbox

[OpenWrt-Devel] ar71xx: fix wndr3700_board_detect for some NETGEAR WNDR3700v2 (again)

Message ID 8c2fd0fb2b291699cb4556b17e63c0a5357f462d.1448029284.git.mschiffer@universe-factory.net
State Accepted
Delegated to: Jo-Philipp Wich
Headers show

Commit Message

Matthias Schiffer Nov. 20, 2015, 2:22 p.m. UTC
When fixing the model string for WNDR3700v2 which contain a model string
followed by 0xff in r46455, the match for other versions of the WNDR3700v2
which just contain lots of 0xff broke (as the 0xff $model is checked for
is stripped off).

Fix by stripping off non-printable characters only for the actual output
string, but not for the internal matching.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 target/linux/ar71xx/base-files/lib/ar71xx.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Hannu Nyman Nov. 20, 2015, 6:09 p.m. UTC | #1
Looks ok to me.

I have an old/original WNDR3700v2 with only ff's there in the version string. 
But I had not noticed the effects of your r46455 patch in July as I had not 
used my v2 since April. I flashed it with the trunk version 47515 from 
yesterday, and indeed, the model name got parsed wrong as plain "NETGEAR".

I then tested with three different revisions of ar71xx.sh:
- the last one before 46455 (=46425) works ok
- version 46455 fails
- current version 47532 with your patch is ok:

root@OpenWrt:/lib# ./03_a_46425.sh
NETGEAR WNDR3700v2
root@OpenWrt:/lib# ./03_b_46455.sh
NETGEAR
root@OpenWrt:/lib# ./03_patch.sh
NETGEAR WNDR3700v2


On 20.11.2015 16:22, Matthias Schiffer wrote:
> When fixing the model string for WNDR3700v2 which contain a model string
> followed by 0xff in r46455, the match for other versions of the WNDR3700v2
> which just contain lots of 0xff broke
Jo-Philipp Wich Nov. 20, 2015, 11:39 p.m. UTC | #2
Applied in r47538 - thank you!

~ Jow
diff mbox

Patch

diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index cc8c43a..af2df8e 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -37,8 +37,9 @@  wndr3700_board_detect() {
 		machine="NETGEAR WNDR3700"
 		;;
 	"33373031")
-		# Use awk to remove everything after the first zero byte
-		model="$(ar71xx_get_mtd_offset_size_format art 41 32 %c | LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}')"
+		model="$(ar71xx_get_mtd_offset_size_format art 41 32 %c)"
+		# Use awk to remove everything unprintable
+		model_stripped="$(echo -n "$model" | LC_CTYPE=C awk -v 'FS=[^[:print:]]' '{print $1; exit}')"
 		case $model in
 		$'\xff'*)
 			if [ "${model:24:1}" = 'N' ]; then
@@ -48,14 +49,14 @@  wndr3700_board_detect() {
 			fi
 			;;
 		'29763654+16+64'*)
-			machine="NETGEAR ${model:14}"
+			machine="NETGEAR ${model_stripped:14}"
 			;;
 		'29763654+16+128'*)
-			machine="NETGEAR ${model:15}"
+			machine="NETGEAR ${model_stripped:15}"
 			;;
 		*)
 			# Unknown ID
-			machine="NETGEAR $model"
+			machine="NETGEAR ${model_stripped}"
 		esac
 	esac