[U-Boot] Inconsistency between $filesize and commands which accept numeric params

Wolfgang Denk wd at denx.de
Tue Nov 4 21:53:02 CET 2014


Dear Ian,

In message <1415116135.11486.51.camel at hellion.org.uk> you wrote:
>
> > > /*
> > >  * Parse the user's input, partially heuristic.  Valid formats:
> > >  * <0x00112233 4 05>	- an array of cells.  Numbers follow standard
> > >  *			C conventions.
> > >  * [00 11 22 .. nn] - byte stream
> > >  * "string"	- If the the value doesn't start with "<" or "[", it is
> > >  *			treated as a string.  Note that the quotes are
> > >  *			stripped by the parser before we get the string.
> > > 
> > > which is inconsistent with the "U-Boot uses hex input base by default"
> > > mantra.
> > 
> > Because this is FDT centric and not U-Boot centric, yes?
> 
> I guess?

Well, we probably should not use this FDT centric decoding function
directly on arguments passed from the U-Boot command line.

> >   Since <decimal
> > numbers> is a valid thing to do in an entry here.  I think the right
> > answer is the more hacky sounding one of when you script using 'fdt set'
> > you need to be mindful of the constraints on input that are imposed upon
> > us by FDT.  <hex> is invalid but <0xhex> is what is expected.
> 
> The 0x prefix hack/trick is what I'm actually doing, but the maintainer
> of our test system wanted some assurances that u-boot wasn't going to
> change under our feet if someone fixed a bug.

I think this is a hack that is bound to break.  Today you use
$filesize, tomorrow you may find you need to perform some operations
on this (say, rounding up in some way), and you may end up with a
variable that already contains a "0x" prefix, and your code will fail
beause 0x0x... gets misinterpreted.

> Sounds like you are saying this is all working as designed, and there is
> no bug, but I'll let Wolfgang and you thrash that out ;-).

Tom: this is a bug ;-)

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The rule on staying alive as a program manager is to give 'em a  num-
ber or give 'em a date, but never give 'em both at once.


More information about the U-Boot mailing list