* bashizm in hotplug scripts (including 20040401)
@ 2004-04-02 0:11 Arkadiusz Miskiewicz
2004-04-02 1:09 ` Martin Schwenke
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Arkadiusz Miskiewicz @ 2004-04-02 0:11 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1317 bytes --]
Hi,
hotplug package is seriously broken and won't work on POSIX/SUSv3
compilant /bin/sh shells.
$ echo $((0xff))
ksh: 0xff: bad number `0xff'
There is a lot of hex to dec conversions using bash only function in hotplug,
example:
echo $((0xff))
Under ksh (pdksh)
$ echo $((0xff))
ksh: 0xff: bad number `0xff'
There is more portable version
hex=0xff
echo "$((16#`echo "$hex" | sed -e 's#^0x##g'`))"
it works well on zsh, pdksh, bash in their enhaced mode but for example on
pdksh run in sh mode it overflows - example:
[arekm@mobarm arekm]$ echo $((16#ff))
255
[arekm@mobarm arekm]$ echo $((16#ffffffff))
-1
pdksh run as pdksh works though.
There are two solutions known to me right now:
- first, very easy - #!/bin/bash instead of #!/bin/sh in these scripts
- second working, POSIX/SUSv3 compilant but much slower; use awk for
conversions (see attached patch).
Any other known fast and portable hex to dec conversions?
ps. using hex2dec() function regardles of choosen conversion method would be
nice - it would allow easy way to change the way of doing conversion + it
explicitly says where hex number should occur
--
Arkadiusz Miśkiewicz CS at FoE, Wroclaw University of Technology
arekm.pld-linux.org, 1024/3DB19BBD, JID: arekm.jabber.org, PLD/Linux
[-- Attachment #2: hotplug-PLD.patch --]
[-- Type: text/x-diff, Size: 9588 bytes --]
diff -urN hotplug-2004_04_01.org/etc/hotplug/hotplug.functions hotplug-2004_04_01/etc/hotplug/hotplug.functions
--- hotplug-2004_04_01.org/etc/hotplug/hotplug.functions 2004-04-02 00:38:53.301487496 +0200
+++ hotplug-2004_04_01/etc/hotplug/hotplug.functions 2004-04-02 01:45:37.628737224 +0200
@@ -190,4 +190,13 @@
# empty line terminates events
}
+####################################################################
+
+# usage: hex2dec hexnumber
+hex2dec()
+{
+ hex="$1"
+ echo | awk "{ printf(\"%d\n\", \"$hex\"); }"
+}
+
# vim:syntax=sh
diff -urN hotplug-2004_04_01.org/etc/hotplug/ieee1394.agent hotplug-2004_04_01/etc/hotplug/ieee1394.agent
--- hotplug-2004_04_01.org/etc/hotplug/ieee1394.agent 2004-04-02 00:38:53.302487344 +0200
+++ hotplug-2004_04_01/etc/hotplug/ieee1394.agent 2004-04-02 00:54:07.717475136 +0200
@@ -39,9 +39,9 @@
fi
-device_vendor_id=$((0x$VENDOR_ID))
-device_specifier_id=$((0x$SPECIFIER_ID))
-device_version=$((0x$VERSION))
+device_vendor_id=$(hex2dec 0x$VENDOR_ID)
+device_specifier_id=$(hex2dec 0x$SPECIFIER_ID)
+device_version=$(hex2dec 0x$VERSION)
MATCH_VENDOR_ID=0x0001
MATCH_SPECIFIER_ID=0x0004
@@ -63,9 +63,11 @@
: check match for $module
# convert from hex to dec
- match_flags=$(($match_flags))
- vendor_id=$(($vendor_id)); model_id=$(($model_id))
- specifier_id=$(($specifier_id)); version=$(($version))
+ match_flags=$(hex2dec $match_flags)
+ vendor_id=$(hex2dec $vendor_id);
+ model_id=$(hex2dec $model_id)
+ specifier_id=$(hex2dec $specifier_id);
+ version=$(hex2dec $version)
: vendor_id $vendor_id $device_vendor_id
if [ $(($match_flags & $MATCH_VENDOR_ID)) -ne 0 -a $vendor_id -ne $device_vendor_id ]; then
diff -urN hotplug-2004_04_01.org/etc/hotplug/input.agent hotplug-2004_04_01/etc/hotplug/input.agent
--- hotplug-2004_04_01.org/etc/hotplug/input.agent 2004-04-02 00:38:53.323484152 +0200
+++ hotplug-2004_04_01/etc/hotplug/input.agent 2004-04-02 00:55:54.221284096 +0200
@@ -78,14 +78,14 @@
IFS=/
set $PRODUCT ''
IFS="$DEFAULT_IFS"
- i_bustype=$((0x$1))
- i_vendor=$((0x$2))
- i_product=$((0x$3))
- i_version=$((0x$4))
+ i_bustype=$(hex2dec 0x$1)
+ i_vendor=$(hex2dec 0x$2)
+ i_product=$(hex2dec 0x$3)
+ i_version=$(hex2dec 0x$4)
fi
if [ "$EV" != "" ]; then
- i_evBits=$((0x$EV))
+ i_evBits=$(hex2dec 0x$EV)
fi
input_join_words i_keyBits "$KEY"
@@ -101,14 +101,14 @@
INPUT_DEVICE_ID_MATCH_VENDOR=2
INPUT_DEVICE_ID_MATCH_PRODUCT=4
INPUT_DEVICE_ID_MATCH_VERSION=8
-INPUT_DEVICE_ID_MATCH_EVBIT=$((0x010))
-INPUT_DEVICE_ID_MATCH_KEYBIT=$((0x020))
-INPUT_DEVICE_ID_MATCH_RELBIT=$((0x040))
-INPUT_DEVICE_ID_MATCH_ABSBIT=$((0x080))
-INPUT_DEVICE_ID_MATCH_MSCBIT=$((0x100))
-INPUT_DEVICE_ID_MATCH_LEDBIT=$((0x200))
-INPUT_DEVICE_ID_MATCH_SNDBIT=$((0x400))
-INPUT_DEVICE_ID_MATCH_FFBIT=$((0x800))
+INPUT_DEVICE_ID_MATCH_EVBIT=$(hex2dec 0x010)
+INPUT_DEVICE_ID_MATCH_KEYBIT=$(hex2dec 0x020)
+INPUT_DEVICE_ID_MATCH_RELBIT=$(hex2dec 0x040)
+INPUT_DEVICE_ID_MATCH_ABSBIT=$(hex2dec 0x080)
+INPUT_DEVICE_ID_MATCH_MSCBIT=$(hex2dec 0x100)
+INPUT_DEVICE_ID_MATCH_LEDBIT=$(hex2dec 0x200)
+INPUT_DEVICE_ID_MATCH_SNDBIT=$(hex2dec 0x400)
+INPUT_DEVICE_ID_MATCH_FFBIT=$(hex2dec 0x800)
input_match_bits ()
@@ -118,8 +118,8 @@
if [ "$dev_bits" = "" ]; then
return 0
fi
- mword=$((0x${mod_bits##*:}))
- dword=$((0x${dev_bits##*:}))
+ mword=$(hex2dec 0x${mod_bits##*:})
+ dword=$(hex2dec 0x${dev_bits##*:})
while true; do
if [ $(( $mword & $dword != $mword )) -eq 1 ]; then
@@ -163,12 +163,12 @@
set $line
module="$1"
- matchBits=$(($2))
+ matchBits=$(hex2dec $2)
- bustype=$(($3))
- vendor=$(($4))
- product=$(($5))
- version=$(($6))
+ bustype=$(hex2dec $3)
+ vendor=$(hex2dec $4)
+ product=$(hex2dec $5)
+ version=$(hex2dec $6)
evBits="$7"
keyBits="$8"
@@ -180,7 +180,7 @@
ledBits="$3"
sndBits="$4"
ffBits="$5"
- driverInfo=$(($6))
+ driverInfo=$(hex2dec $6)
: checkmatch $module
diff -urN hotplug-2004_04_01.org/etc/hotplug/pci.agent hotplug-2004_04_01/etc/hotplug/pci.agent
--- hotplug-2004_04_01.org/etc/hotplug/pci.agent 2004-04-02 00:38:53.303487192 +0200
+++ hotplug-2004_04_01/etc/hotplug/pci.agent 2004-04-02 00:57:14.024152216 +0200
@@ -59,18 +59,18 @@
pci_convert_vars ()
{
- pci_class=$((0x$PCI_CLASS))
+ pci_class=$(hex2dec 0x$PCI_CLASS)
set $(echo $PCI_ID | sed -e 's/\([^:]*\):\(.*\)/\1 \2/')
- pci_id_vendor=$((0x$1))
- pci_id_device=$((0x$2))
+ pci_id_vendor=$(hex2dec 0x$1)
+ pci_id_device=$(hex2dec 0x$2)
set $(echo $PCI_SUBSYS_ID | sed -e 's/\([^:]*\):\(.*\)/\1 \2/')
- pci_subid_vendor=$((0x$1))
- pci_subid_device=$((0x$2))
+ pci_subid_vendor=$(hex2dec 0x$1)
+ pci_subid_device=$(hex2dec 0x$2)
}
-PCI_ANY=$((0xffffffff))
+PCI_ANY=$(hex2dec 0xffffffff)
#
@@ -95,9 +95,12 @@
esac
# convert the fields from hex to dec
- vendor=$(($vendor)); device=$(($device))
- subvendor=$(($subvendor)); subdevice=$(($subdevice))
- class=$(($class)); class_mask=$(($class_mask))
+ vendor=$(hex2dec $vendor)
+ device=$(hex2dec $device)
+ subvendor=$(hex2dec $subvendor)
+ subdevice=$(hex2dec $subdevice)
+ class=$(hex2dec $class)
+ class_mask=$(hex2dec $class_mask)
: checkmatch $module
diff -urN hotplug-2004_04_01.org/etc/hotplug/pci.rc hotplug-2004_04_01/etc/hotplug/pci.rc
--- hotplug-2004_04_01.org/etc/hotplug/pci.rc 2004-04-02 00:38:53.303487192 +0200
+++ hotplug-2004_04_01/etc/hotplug/pci.rc 2004-04-02 01:00:37.344242864 +0200
@@ -65,6 +65,7 @@
case "$1" in
start)
pci_boot_events
+ exit $?
;;
stop)
# echo $"pci stop -- ignored"
diff -urN hotplug-2004_04_01.org/etc/hotplug/usb.agent hotplug-2004_04_01/etc/hotplug/usb.agent
--- hotplug-2004_04_01.org/etc/hotplug/usb.agent 2004-04-02 00:38:53.318484912 +0200
+++ hotplug-2004_04_01/etc/hotplug/usb.agent 2004-04-02 00:59:47.428831160 +0200
@@ -181,9 +181,9 @@
-e "s+/\([0-9]\)\.\([0-9][0-9]\)+/0\1\2+" \
-e "s+/\([0-9][0-9]\)\.\([0-9][0-9]\)+/\1\2+"`
set $(echo $PRODUCT | sed -e 's+\([^/]*\)/\([^/]*\)/\(.*\)+\1 \2 \3+')
- usb_idVendor=$((0x$1))
- usb_idProduct=$((0x$2))
- usb_bcdDevice=$((0x$3))
+ usb_idVendor=$(hex2dec 0x$1)
+ usb_idProduct=$(hex2dec 0x$2)
+ usb_bcdDevice=$(hex2dec 0x$3)
if [ "$TYPE" != "" ]; then
IFS=/
@@ -193,9 +193,9 @@
usb_bDeviceProtocol=$3
IFS="$DEFAULT_IFS"
elif [ -r $SYSFS/$DEVPATH/bDeviceClass ]; then
- usb_bDeviceClass=$((0x$(cat $SYSFS/$DEVPATH/bDeviceClass)))
- usb_bDeviceSubClass=$((0x$(cat $SYSFS/$DEVPATH/bDeviceSubClass)))
- usb_bDeviceProtocol=$((0x$(cat $SYSFS/$DEVPATH/bDeviceProtocol)))
+ usb_bDeviceClass=$(hex2dec 0x$(cat $SYSFS/$DEVPATH/bDeviceClass))
+ usb_bDeviceSubClass=$(hex2dec 0x$(cat $SYSFS/$DEVPATH/bDeviceSubClass))
+ usb_bDeviceProtocol=$(hex2dec 0x$(cat $SYSFS/$DEVPATH/bDeviceProtocol))
else
# out-of-range values
usb_bDeviceClass=1000
@@ -211,9 +211,9 @@
usb_bInterfaceProtocol=$3
IFS="$DEFAULT_IFS"
elif [ -r $SYSFS/$DEVPATH/bInterfaceClass ]; then
- usb_bInterfaceClass=$((0x$(cat $SYSFS/$DEVPATH/bInterfaceClass)))
- usb_bInterfaceSubClass=$((0x$(cat $SYSFS/$DEVPATH/bInterfaceSubClass)))
- usb_bInterfaceProtocol=$((0x$(cat $SYSFS/$DEVPATH/bInterfaceProtocol)))
+ usb_bInterfaceClass=$(hex2dec 0x$(cat $SYSFS/$DEVPATH/bInterfaceClass))
+ usb_bInterfaceSubClass=$(hex2dec 0x$(cat $SYSFS/$DEVPATH/bInterfaceSubClass))
+ usb_bInterfaceProtocol=$(hex2dec 0x$(cat $SYSFS/$DEVPATH/bInterfaceProtocol))
else
# out-of-range values
usb_bInterfaceClass=1000
@@ -222,16 +222,16 @@
fi
}
-USB_MATCH_VENDOR=$((0x0001))
-USB_MATCH_PRODUCT=$((0x0002))
-USB_MATCH_DEV_LO=$((0x0004))
-USB_MATCH_DEV_HI=$((0x0008))
-USB_MATCH_DEV_CLASS=$((0x0010))
-USB_MATCH_DEV_SUBCLASS=$((0x0020))
-USB_MATCH_DEV_PROTOCOL=$((0x0040))
-USB_MATCH_INT_CLASS=$((0x0080))
-USB_MATCH_INT_SUBCLASS=$((0x0100))
-USB_MATCH_INT_PROTOCOL=$((0x0200))
+USB_MATCH_VENDOR=$(hex2dec 0x0001)
+USB_MATCH_PRODUCT=$(hex2dec 0x0002)
+USB_MATCH_DEV_LO=$(hex2dec 0x0004)
+USB_MATCH_DEV_HI=$(hex2dec 0x0008)
+USB_MATCH_DEV_CLASS=$(hex2dec 0x0010)
+USB_MATCH_DEV_SUBCLASS=$(hex2dec 0x0020)
+USB_MATCH_DEV_PROTOCOL=$(hex2dec 0x0040)
+USB_MATCH_INT_CLASS=$(hex2dec 0x0080)
+USB_MATCH_INT_SUBCLASS=$(hex2dec 0x0100)
+USB_MATCH_INT_PROTOCOL=$(hex2dec 0x0200)
#
# stdin is "modules.usbmap" syntax
@@ -255,21 +255,21 @@
set $line
module=$1
- match_flags=$(($2))
+ match_flags=$(hex2dec $2)
- idVendor=$(($3))
- idProduct=$(($4))
- bcdDevice_lo=$(($5))
- bcdDevice_hi=$(($6))
-
- bDeviceClass=$(($7))
- bDeviceSubClass=$(($8))
- bDeviceProtocol=$(($9))
+ idVendor=$(hex2dec $3)
+ idProduct=$(hex2dec $4)
+ bcdDevice_lo=$(hex2dec $5)
+ bcdDevice_hi=$(hex2dec $6)
+
+ bDeviceClass=$(hex2dec $7)
+ bDeviceSubClass=$(hex2dec $8)
+ bDeviceProtocol=$(hex2dec $9)
shift 9
- bInterfaceClass=$(($1))
- bInterfaceSubClass=$(($2))
- bInterfaceProtocol=$(($3))
+ bInterfaceClass=$(hex2dec $1)
+ bInterfaceSubClass=$(hex2dec $2)
+ bInterfaceProtocol=$(hex2dec $3)
: checkmatch $module
diff -urN hotplug-2004_04_01.org/etc/hotplug.d/default/default.hotplug hotplug-2004_04_01/etc/hotplug.d/default/default.hotplug
--- hotplug-2004_04_01.org/etc/hotplug.d/default/default.hotplug 2004-04-02 00:38:53.324484000 +0200
+++ hotplug-2004_04_01/etc/hotplug.d/default/default.hotplug 2004-04-02 01:01:00.153775288 +0200
@@ -32,7 +32,7 @@
# DEBUG=yes export DEBUG
-debug_mesg "arguments ($*) env (`env`)"
+[ -n "$DEBUG" ] && debug_mesg "arguments ($*) env (`env`)"
#
# Only one required argument: event type type being dispatched.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bashizm in hotplug scripts (including 20040401)
2004-04-02 0:11 bashizm in hotplug scripts (including 20040401) Arkadiusz Miskiewicz
@ 2004-04-02 1:09 ` Martin Schwenke
2004-04-02 13:05 ` Arkadiusz Miskiewicz
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Martin Schwenke @ 2004-04-02 1:09 UTC (permalink / raw)
To: linux-hotplug
>>>>> "Arkadiusz" = Arkadiusz Miskiewicz <arekm@pld-linux.org> writes:
Arkadiusz> hotplug package is seriously broken and won't work on
Arkadiusz> POSIX/SUSv3 compilant /bin/sh shells.
Arkadiusz> $ echo $((0xff))
Arkadiusz> ksh: 0xff: bad number `0xff'
Yuck! In section 2.6.4, the standard says:
Only the decimal-constant, octal-constant, and hexadecimal-constant
constants specified in the ISO C standard, Section 6.4.4.1 are
required to be recognised as constants.
and this section has:
hexadecimal-constant:
hexadecimal-prefix hexadecimal-digit
hexadecimal-constant hexadecimal-digit
hexadecimal-prefix: one of
0x 0X
Looks like ksh is broken (and my testing of pdksh 5.2.14 (in Debian
unstable) support this).
However...
Arkadiusz> There is more portable version
Arkadiusz> hex=0xff
Arkadiusz> echo "$((16#`echo "$hex" | sed -e 's#^0x##g'`))"
This will work just as well, is as POSIX compliant as the above (see
below) and avoids the fork/exec overhead:
echo $((16#${hex#0x}))
Arkadiusz> it works well on zsh, pdksh, bash in their enhaced mode
Arkadiusz> [...]
I've tested the above in pdksh and bash.
Arkadiusz> [...] but for example on pdksh run in sh mode it
Arkadiusz> overflows - example:
Arkadiusz> [arekm@mobarm arekm]$ echo $((16#ff))
Arkadiusz> 255
Arkadiusz> [arekm@mobarm arekm]$ echo $((16#ffffffff))
Arkadiusz> -1
Debian's ash-0.4.25 overflows too.
Note that POSIX says:
Only signed long integer arithmetic is required.
There's another problem. In ash:
echo $((16#ff))
fails. Neither the POSIX or C standard mentions the "base#num"
notation!
Looks like the best way of fixing this is to leave hotplug the way it
is (except if a workaround for the overlows is needed) and fix
pdksh... :-)
Incidently, last time I looked, hotplug had quite a few uses of things
like sed and cut that could be replaced by clever us of the POSIX
substring operations:
${paramter%word}
${paramter%%word}
${paramter#word}
${paramter##word}
At the time I thought these were bash-specific, so I didn't send a
patch. Now that I've read the relevant part of the standard, I'd be
happy to create a patch that uses these if it is likely to be applied.
peace & happiness,
martin
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bashizm in hotplug scripts (including 20040401)
2004-04-02 0:11 bashizm in hotplug scripts (including 20040401) Arkadiusz Miskiewicz
2004-04-02 1:09 ` Martin Schwenke
@ 2004-04-02 13:05 ` Arkadiusz Miskiewicz
2004-04-05 6:06 ` Martin Schwenke
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Arkadiusz Miskiewicz @ 2004-04-02 13:05 UTC (permalink / raw)
To: linux-hotplug
Dnia Friday 02 of April 2004 03:09, Martin Schwenke napisa³:
> Yuck! In section 2.6.4, the standard says:
>
> Only the decimal-constant, octal-constant, and hexadecimal-constant
> constants specified in the ISO C standard, Section 6.4.4.1 are
> required to be recognised as constants.
Missed that :/
> Arkadiusz> [...] but for example on pdksh run in sh mode it
> Arkadiusz> overflows - example:
>
> Arkadiusz> [arekm@mobarm arekm]$ echo $((16#ff))
> Arkadiusz> 255
> Arkadiusz> [arekm@mobarm arekm]$ echo $((16#ffffffff))
> Arkadiusz> -1
>
> Debian's ash-0.4.25 overflows too.
>
> Note that POSIX says:
>
> Only signed long integer arithmetic is required.
So hotplug scripts still need the change because they do arithmetic beyond
signed long:
[misiek@arm ~/rpm/SOURCES/hotplug-2004_04_01.org]$ grep -r 0xffffffff .
./etc/hotplug/pci.agent:PCI_ANY=$((0xffffffff))
> Looks like the best way of fixing this is to leave hotplug the way it
> is (except if a workaround for the overlows is needed)
It's needed. Either create some workaround or put #!/bin/bash there. Any
propositions for workaround?
> and fix
> pdksh... :-)
http://cvs.pld-linux.org/cgi-bin/cvsweb/SOURCES/pdksh-hex.patch?rev=1.1 from
OpenBSD people
> peace & happiness,
> martin
--
Arkadiusz Mi¶kiewicz CS at FoE, Wroclaw University of Technology
arekm.pld-linux.org, 1024/3DB19BBD, JID: arekm.jabber.org, PLD/Linux
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&opÌk
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bashizm in hotplug scripts (including 20040401)
2004-04-02 0:11 bashizm in hotplug scripts (including 20040401) Arkadiusz Miskiewicz
2004-04-02 1:09 ` Martin Schwenke
2004-04-02 13:05 ` Arkadiusz Miskiewicz
@ 2004-04-05 6:06 ` Martin Schwenke
2004-04-05 17:11 ` Greg KH
2004-04-05 17:46 ` Arkadiusz Miskiewicz
4 siblings, 0 replies; 6+ messages in thread
From: Martin Schwenke @ 2004-04-05 6:06 UTC (permalink / raw)
To: linux-hotplug
>>>>> "Arkadiusz" = Arkadiusz Miskiewicz <arekm@pld-linux.org> writes:
Arkadiusz> So hotplug scripts still need the change because they
Arkadiusz> do arithmetic beyond signed long:
Arkadiusz> [...]$ grep -r 0xffffffff .
Arkadiusz> ./etc/hotplug/pci.agent:PCI_ANY=$((0xffffffff))
The value of PCI_ANY only ever compared against other things - there's
no useful arithmetic done. The PCI 2.2 specification only allows
Vendor ID and Device ID to be 16 bits (in configuration space at
least). If there any reason for using the value 0xffffffff, rather
than just 0xffff? Greg?
peace & happiness,
martin
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bashizm in hotplug scripts (including 20040401)
2004-04-02 0:11 bashizm in hotplug scripts (including 20040401) Arkadiusz Miskiewicz
` (2 preceding siblings ...)
2004-04-05 6:06 ` Martin Schwenke
@ 2004-04-05 17:11 ` Greg KH
2004-04-05 17:46 ` Arkadiusz Miskiewicz
4 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2004-04-05 17:11 UTC (permalink / raw)
To: linux-hotplug
On Mon, Apr 05, 2004 at 04:06:15PM +1000, Martin Schwenke wrote:
> >>>>> "Arkadiusz" = Arkadiusz Miskiewicz <arekm@pld-linux.org> writes:
>
> Arkadiusz> So hotplug scripts still need the change because they
> Arkadiusz> do arithmetic beyond signed long:
>
> Arkadiusz> [...]$ grep -r 0xffffffff .
> Arkadiusz> ./etc/hotplug/pci.agent:PCI_ANY=$((0xffffffff))
>
> The value of PCI_ANY only ever compared against other things - there's
> no useful arithmetic done. The PCI 2.2 specification only allows
> Vendor ID and Device ID to be 16 bits (in configuration space at
> least). If there any reason for using the value 0xffffffff, rather
> than just 0xffff? Greg?
Look at include/linux/mod_devicetable.h for why that is a 32 bit number
(needs to match up with the pci_device_id fields.)
Now why those fields are 32 bits, you will probably have to go dig
through the 2.3 kernel archives, I don't remember anymore.
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: bashizm in hotplug scripts (including 20040401)
2004-04-02 0:11 bashizm in hotplug scripts (including 20040401) Arkadiusz Miskiewicz
` (3 preceding siblings ...)
2004-04-05 17:11 ` Greg KH
@ 2004-04-05 17:46 ` Arkadiusz Miskiewicz
4 siblings, 0 replies; 6+ messages in thread
From: Arkadiusz Miskiewicz @ 2004-04-05 17:46 UTC (permalink / raw)
To: linux-hotplug
Dnia Monday 05 of April 2004 08:06, Martin Schwenke napisa³:
> The value of PCI_ANY only ever compared against other things - there's
> no useful arithmetic done. The PCI 2.2 specification only allows
> Vendor ID and Device ID to be 16 bits (in configuration space at
> least). If there any reason for using the value 0xffffffff, rather
> than just 0xffff? Greg?
If 16 bits is max in reality then it seems that we don't have to do anything
because:
PCI_ANY=$((0xffffffff))
would overflow to -1 and
vendor=$(($vendor));
this will also overflow to -1
if [ $vendor -ne $PCI_ANY -a $vendor -ne $pci_id_vendor ]; then
and we end up with -1 -ne -1 comparsion.
Anyway comment about this should be added in hotplug scripts.
> peace & happiness,
> martin
--
Arkadiusz Mi¶kiewicz CS at FoE, Wroclaw University of Technology
arekm.pld-linux.org, 1024/3DB19BBD, JID: arekm.jabber.org, PLD/Linux
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id\x1470&alloc_id638&opÌk
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-04-05 17:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-02 0:11 bashizm in hotplug scripts (including 20040401) Arkadiusz Miskiewicz
2004-04-02 1:09 ` Martin Schwenke
2004-04-02 13:05 ` Arkadiusz Miskiewicz
2004-04-05 6:06 ` Martin Schwenke
2004-04-05 17:11 ` Greg KH
2004-04-05 17:46 ` Arkadiusz Miskiewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).