Re: [OpenWrt-Devel] [PATCH] base-files: fix get_mac_address not accepting hex offsets

2019-09-05 Thread Adrian Schmutzler
Hi David,

> -Original Message-
> From: David Bauer [mailto:m...@david-bauer.net]
> Sent: Mittwoch, 4. September 2019 23:07
> To: m...@adrianschmutzler.de
> Cc: openwrt-devel@lists.openwrt.org
> Subject: Re: [OpenWrt-Devel] [PATCH] base-files: fix get_mac_address not 
> accepting hex offsets
> 
> Hello Adrian,
> 
> On 9/4/19 10:08 PM, m...@adrianschmutzler.de wrote:
> > when I tested it then, the hexdump offset did accept hexadecimal values 
> > intrinsically.
> > I remember that because I was quite surprised that offset accepted 
> > hexadecimal values and size didn't.
> 
> This might be the case for hexdump, however dd does not accept hexadecimal 
> values.

Indeed, I overlooked that one. So we have four cases:

1. mtd_get_mac_text:

This uses dd and should currently be broken, so it needs the $(($...)) as a fix.

2. get_mac_binary:

This one uses hexdump, so $(($...)) is not required, but might be added for 
convenience.

3. mtd_get_mac_binary:

This one is just calling get_mac_binary. I'd say that get_mac_binary should be 
safe to be called with hex offset, so I would not change to decimal _before_, 
so just keep this as it is.

4. mtd_get_mac_binary_ubi:

This could be treated similar to 2. However, on a closer look part of this 
function is the same as in get_mac_binary. So, IMO this one should be 
refactored to call get_mac_binary as in mtd_get_mac_binary.

Nevertheless, thanks for spotting and repairing the bug introduced in my patch!

Best

Adrian

> 
> The commit message is indeed not correct in that regard. However I've changed 
> the
> evaluation there too, as originally it was provided decimal numbers, keeping 
> the
> underlying call stable.
> 
> Best wishes
> David


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files: fix get_mac_address not accepting hex offsets

2019-09-04 Thread David Bauer
Hello Adrian,

On 9/4/19 10:08 PM, m...@adrianschmutzler.de wrote:
> when I tested it then, the hexdump offset did accept hexadecimal values 
> intrinsically.
> I remember that because I was quite surprised that offset accepted 
> hexadecimal values and size didn't.

This might be the case for hexdump, however dd does not accept hexadecimal 
values.

The commit message is indeed not correct in that regard. However I've changed 
the
evaluation there too, as originally it was provided decimal numbers, keeping the
underlying call stable.

Best wishes
David

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files: fix get_mac_address not accepting hex offsets

2019-09-04 Thread mail
Hi, 

> -Original Message- 
> From: openwrt-devel [mailto:openwrt-devel-boun...@lists.openwrt.org] 
> On Behalf Of David Bauer 
> Sent: Mittwoch, 4. September 2019 21:19 
> To: openwrt-devel@lists.openwrt.org 
> Cc: m...@adrianschmutzler.de 
> Subject: [OpenWrt-Devel] [PATCH] base-files: fix get_mac_address not 
> accepting hex offsets 
> 
> The get_mac_address helper methods did not support hexadecimal offset 
> values, resulting them to break after 75bfc393ba6c ("treewide: 
> convert MAC address location offsets to hexadecimal") 

when I tested it then, the hexdump offset did accept hexadecimal values 
intrinsically. 
I remember that because I was quite surprised that offset accepted hexadecimal 
values and size didn't. 

In particular I've always been using get_mac_binary with hexadecimal values as 
second argument. 
Or am I misunderstanding you somewhere? 

However, converting it as in this patch doesn't hurt, especially if the 
behavior of hexdump changes in the future. 

Best 

Adrian 


openpgp-digital-signature.asc
Description: PGP signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: fix get_mac_address not accepting hex offsets

2019-09-04 Thread David Bauer
The get_mac_address helper methods did not support hexadecimal offset
values, resulting them to break after 75bfc393ba6c ("treewide:
convert MAC address location offsets to hexadecimal")

This commit fixes this by evaluating the hexadecimal input,
converting them to decimal.

Signed-off-by: David Bauer 
---
 package/base-files/files/lib/functions/system.sh | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/package/base-files/files/lib/functions/system.sh 
b/package/base-files/files/lib/functions/system.sh
index 9b9d03df7b..4a97b27f5a 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -2,7 +2,7 @@
 
 get_mac_binary() {
local path="$1"
-   local offset="$2"
+   local offset=$(($2))
 
if ! [ -e "$path" ]; then
echo "get_mac_binary: file $path not found!" >&2
@@ -40,7 +40,7 @@ mtd_get_mac_ascii() {
 
 mtd_get_mac_text() {
local mtdname=$1
-   local offset=$2
+   local offset=$(($2))
local part
local mac_dirty
 
@@ -63,7 +63,7 @@ mtd_get_mac_text() {
 
 mtd_get_mac_binary() {
local mtdname="$1"
-   local offset="$2"
+   local offset=$(($2))
local part
 
part=$(find_mtd_part "$mtdname")
@@ -72,7 +72,7 @@ mtd_get_mac_binary() {
 
 mtd_get_mac_binary_ubi() {
local mtdname="$1"
-   local offset="$2"
+   local offset=$(($2))
 
. /lib/upgrade/nand.sh
 
-- 
2.23.0


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel