[U-Boot-Users] Spartan FPGA patch

Matthias Fuchs matthias.fuchs at esd-electronics.com
Wed Nov 7 15:29:49 CET 2007


Hi Wolfgang,

when copying val from 'data[bytecount++]' it is common practice that val
if of the same type as the array elements. So val should be unsigned char.

I changed the sign check into a 'val & 0x80', which I think is fine an clean.

Matthias

On Monday 05 November 2007 20:21, Wolfgang Denk wrote:
> In message <472F1393.7040306 at inaccessnetworks.com> you wrote:
> > Wolfgang Denk wrote:
> > > In message <472752F9.9000307 at inaccessnetworks.com> you wrote:
> > >> The following patch fixes a bug in the slave serial programming mode for 
> > >> the xilinx spartan2 FPGA. A "char val" is declared, but it is used as a 
> > >> signed char. The check for negative value (<0) is always true on arm, or 
> > >> any other platform in which the char is not signed by default. As a 
> > >> result the FPGA cannot be programmed.
> > > 
> > > I have to admit that I hate to see "signed  char"  in  the  code.  Is
> > > there  any  special  reaso why "val" has to be a "char" type? Why not
> > > making it an "int" ?
> > 
> > Another way to do this safely is to declare it as an "unsigned char" and 
> > instead of doing "val < 0", do "val & 0x80". I don't like the current 
> > code either. Shifting a signed char and testing for negativity is 
> > definitely not the best way to test that the MSB is set.
> 
> So let me repeat my question: is there any special reason  why  "val"
> has to be a "char" type? Why not making it an "int" ?
> 
> 
> Best regards,
> 
> Wolfgang Denk
> 

-- 
-----------------------------------------------------------------------
Dipl.-Ing. Matthias Fuchs             esd electronic system design gmbh
http://www.esd-electronics.com                    Vahrenwalder Str. 207
phone: +49-511-37298-0, fax: -68                30165 Hannover, Germany
-----------------------------------------------------------------------





More information about the U-Boot mailing list