[LEDE-DEV] [PATCH] package/utils/nvram/files/nvram.init * Double quote to prevent globbing and word splitting. * $/${} is unnecessary on arithmetic variables. * remove unused variables

Mathias Kresin dev at kresin.me
Tue Oct 4 00:01:28 PDT 2016


04.10.2016 02:35, Jan-Tarek Butt:
> Signed-off-by: Jan-Tarek Butt <tarek at ring0.de>

Some problem with the commit title and message as with your ct-bugcheck 
patch.


> ---
>  package/utils/nvram/files/nvram.init | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/package/utils/nvram/files/nvram.init b/package/utils/nvram/files/nvram.init
> index 467ab28..ec06e7a 100755
> --- a/package/utils/nvram/files/nvram.init
> +++ b/package/utils/nvram/files/nvram.init
> @@ -4,10 +4,10 @@
>  # This file handles the NVRAM quirks of various hardware.
>
>  START=02
> -alias debug=${DEBUG:-:}
> +alias debug="${DEBUG:-:}"
>
>  nvram_default() {
> -	[ -z "$(nvram get $1)" ] && nvram set "$1=$2"
> +	[ -z "$(nvram get "$1")" ] && nvram set "$1=$2"
>  }
>
>  nvram_set() { # for the linksys fixup part
> @@ -20,12 +20,11 @@ nvram_set() { # for the linksys fixup part
>  fixup_linksys() {
>  	# work around braindead CFE defaults in linksys routers
>  	boardtype=$(nvram get boardtype)
> -	boardnum=$(nvram get boardnum)
>  	boardflags=$(($(nvram get boardflags)))
> -	adm_switch="$(( ($boardflags & 0x80) >> 7 ))"
> +	adm_switch="$(( (boardflags & 0x80) >> 7 ))"
>
>  	[ -n "$(nvram get vxkilled)" ] && boardtype=0 # don't mess with the ram settings on the hacked cfe
> -	case "$(( $boardtype ))" in
> +	case "$(( boardtype ))" in
>  		"1800") #0x708
>  			if [ "$adm_switch" = 0 ]; then
>  				nvram_set sdram_init "$(printf 0x%04x $(( $(/usr/sbin/nvram get sdram_init) | 0x0100 )))"
> @@ -53,10 +52,10 @@ fixup_linksys() {
>  		;;
>  		"1071") #0x042f
>  			# do sanity check first! max 0x0011 = 128mb
> -			SDRAM_INIT=$(printf %d $(/usr/sbin/nvram get sdram_init))
> -			[ "$SDRAM_INIT" -lt "9" -o "$SDRAM_INIT" -gt "17" ] && {
> +			SDRAM_INIT=$(printf %d "$(/usr/sbin/nvram get sdram_init)")
> +			[ "$SDRAM_INIT" -lt "9" ] || [ "$SDRAM_INIT" -gt "17" ] && {
>  				# set this to default: 0x09 only if value is invaild like 16MB on Asus WL-500GP
> -				echo "sdram_init is invaild: $(printf 0x%04x $SDRAM_INIT), force to default!"
> +				echo "sdram_init is invaild: $(printf 0x%04x "$SDRAM_INIT"), force to default!"
>  				nvram_set sdram_init 0x0009
>  			}
>  			# on WRT54G3GV2 set flag, so checksum errors of firmware image 2 don't stop the boot process
> @@ -83,16 +82,16 @@ start() {
>
>  	[ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
>  		# if default wifi mac, set two higher than the lan mac
> -		nvram set il0macaddr=$(nvram get et0macaddr|
> -		awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
> +		nvram set il0macaddr="$(nvram get et0macaddr|
> +		awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')"
>  	}
>
>  	[ "$(nvram get et0macaddr)" = "00:90:4c:c0:00:08" ] && {
>  		# OvisLink WL-1600GL mac workaround
> -		nvram set et0macaddr=$(hexdump -n 6 -s 130976 -e '5/1 "%02x:" "%02x" ' /dev/mtd/0)
> -		nvram set il0macaddr=$(nvram get et0macaddr|
> -		awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
> +		nvram set et0macaddr="$(hexdump -n 6 -s 130976 -e '5/1 "%02x:" "%02x" ' /dev/mtd/0)"
> +		nvram set il0macaddr="$(nvram get et0macaddr|
> +		awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')"
>  	}
>
>  	[ "$COMMIT" = "1" ] && nvram commit
> -}
> +      }
>




More information about the Lede-dev mailing list