Re: [OpenWrt-Devel] problem with big integer on openwrt
very thanks to all :D 2010/7/15 Andreas Mohr > On Thu, Jul 15, 2010 at 12:00:04PM +0200, > openwrt-devel-requ...@lists.openwrt.org wrote: > > Hey all I have a big problem with openwrt! > > > > In a bash shell if i write this command > > printf "%d\n" "`echo "255.255.255.255" | awk -F\. '{printf "%d", > > ($4)+($3*256)+($2*256*256)+($1*256*256*256)}'`" > > i obtain > > 2147483647 > > that is wrong! > > The question here would be WHAT exactly is wrong here ;) > Probably not this shell... > > %d is a format string for a _signed_ integer, not the unsigned > expression that is being evaluated here. > And with common systems an integer value is specified as 32bit, > resulting in this INT_MAX value for any values _larger_ than that. > > > If i put the same command in my gentoo bash shell i obtain 4294967295 > that > > is the good value how to fix this ? > > %u would fix that, or perhaps better use %lu (or better %llu?) for > higher probability to get the correct value. > OTOH since an IPv4 address will always remain 32bit, %u is fully > sufficient and thus the exactly adapted and proper solution. > > HTH, > > Andreas Mohr > ___ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel > ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] problem with big integer on openwrt
On Thu, Jul 15, 2010 at 12:00:04PM +0200, openwrt-devel-requ...@lists.openwrt.org wrote: > Hey all I have a big problem with openwrt! > > In a bash shell if i write this command > printf "%d\n" "`echo "255.255.255.255" | awk -F\. '{printf "%d", > ($4)+($3*256)+($2*256*256)+($1*256*256*256)}'`" > i obtain > 2147483647 > that is wrong! The question here would be WHAT exactly is wrong here ;) Probably not this shell... %d is a format string for a _signed_ integer, not the unsigned expression that is being evaluated here. And with common systems an integer value is specified as 32bit, resulting in this INT_MAX value for any values _larger_ than that. > If i put the same command in my gentoo bash shell i obtain 4294967295 that > is the good value how to fix this ? %u would fix that, or perhaps better use %lu (or better %llu?) for higher probability to get the correct value. OTOH since an IPv4 address will always remain 32bit, %u is fully sufficient and thus the exactly adapted and proper solution. HTH, Andreas Mohr ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] problem with big integer on openwrt
The problem is not Openwrt but awk that cannot handle big number on small device :( bash can than i fixed with this printf "%d\n" $(( (`echo "255.255.255.255" | awk -F\. '{printf "%d", ($4)}'`)+ (256*`echo "255.255.255.255" | awk -F\. '{printf "%d", ($3)}'`) + (256*256*`echo "255.255.255.255" | awk -F\. '{printf "%d", ($2)}'`) + (256*256*256*`echo "255.255.255.255" | awk -F\. '{printf "%d", ($4)}'`) )) 2010/7/15 Gioacchino Mazzurco > Hey all I have a big problem with openwrt! > > In a bash shell if i write this command > printf "%d\n" "`echo "255.255.255.255" | awk -F\. '{printf "%d", > ($4)+($3*256)+($2*256*256)+($1*256*256*256)}'`" > i obtain > 2147483647 > that is wrong! > > If i put the same command in my gentoo bash shell i obtain 4294967295 that > is the good value how to fix this ? > ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] problem with big integer on openwrt
If awk of Busybox has a range limit issue, then try calculating in the shell itself: echo $(( `echo "255.255.255.255" | awk -F\. '{printf "(%i*256*256*256) + (%i*256*256) + (%i*256) + (%i)", $1, $2, $3, $4}'` )) Awk creates the formular, while ash calculates it via $(( Maddes On 15.07.2010 11:46, Gioacchino Mazzurco wrote: > Hey all I have a big problem with openwrt! > > In a bash shell if i write this command > printf "%d\n" "`echo "255.255.255.255" | awk -F\. '{printf "%d", > ($4)+($3*256)+($2*256*256)+($1*256*256*256)}'`" > i obtain > 2147483647 > that is wrong! > > If i put the same command in my gentoo bash shell i obtain 4294967295 > that is the good value how to fix this ? > > > > ___ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] problem with big integer on openwrt
Hey all I have a big problem with openwrt! In a bash shell if i write this command printf "%d\n" "`echo "255.255.255.255" | awk -F\. '{printf "%d", ($4)+($3*256)+($2*256*256)+($1*256*256*256)}'`" i obtain 2147483647 that is wrong! If i put the same command in my gentoo bash shell i obtain 4294967295 that is the good value how to fix this ? ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] Resolve interfaces in dnsmasq configuration
Hi, shouldn't /etc/init.d/dnsmasq try to "resolve" the name of interfaces w.r.t. how they are called in /etc/config/network? I've been bitten by this recently. If there is no objection, I'll make a patch and submit it here. Regards, -- Gabriel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 1/3] ar71xx: in-flash macs and eeprom for mach-eap7660d
2010.07.14. 0:38 keltezéssel, daniel.go...@gmail.com írta: > I now renamed everything to ath5k_platform and also included all other > previously suggested fixes. > Cheers! > > > This adds in-flash mac-addresses and callibration data for the Senao EAP7660D > board. > > Signed-off-by: Daniel Golle Applied: https://dev.openwrt.org/changeset/22187 Thanks, Gabor ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 3/3] madwifi: in-flash macs for mach-eap7660d
2010.07.14. 0:45 keltezéssel, daniel.go...@gmail.com írta: > Moved new code outside of #ifdef CONFIG_ATHEROS_AR71XXX and removed unneeded > cast. > > > This patch makes madwifi respect (at least) the platform_data supplied MAC > address. > > Signed-off-by: Daniel Golle Applied: https://dev.openwrt.org/changeset/22190 Thanks, Gabor ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH 2/3] ath5k: in-flash macs and eeprom for mach-eap7660d
2010.07.14. 0:42 keltezéssel, daniel.go...@gmail.com írta: > I removed unneeded casts and now hopefully really checking the first word for > the magic... > Also renamed everything to ath5k_platform here, too, of course. > > > This adds ath_platform.h to mac80211 and patches ath5k to respect MAC > addresses and eeprom content from platform_data, if supplied. > > Signed-off-by: Daniel Golle Applied: https://dev.openwrt.org/changeset/22188 Thanks, Gabor ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel