From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Wed, 14 Nov 2007 20:46:13 +0100 Subject: [U-Boot-Users] Spartan FPGA patch In-Reply-To: Your message of "Wed, 14 Nov 2007 14:05:46 +0200." <473AE49A.40801@inaccessnetworks.com> Message-ID: <20071114194613.19F55247F1@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de In message <473AE49A.40801@inaccessnetworks.com> you wrote: > > This is the main misunderstanding. When you said "int" I though you > meant dereferencing an "int *", in fact not only me but other people on > the list as well. So your proposal is to convert the "char val" to an > "int val". You don't solve the problem I mentioned by doing this. Well, the original error description said the problem was caused by the fact that "char" might be treated as "unsigned char" on some platforms to the test for "< 0" would always fail. > Let us not forget that all we want to do here is take the *bits* of the > buffer one by one, starting from the MSB. Checking for negativity is > just a hack to acquire the MSB, since signed values are two's complement. If this was the intention of the code, then the implementation of that part is wrong (as has been pointed out before). Ii is already wrong to assume that you are on a two complements machine... > architectures, but I fail to see how this is cleaner than converting the > val to "unsigned char" like the "data" and doing "val & 0x80". It depends on the purpose of the code (which I didn't bother to dig into). If you want to really make a difference between <0 and >=0 you should use integer types. If you want to test if a certain bit is set or not than you should use a logical AND operation. In this case the bug was in using a '<0', not in the variable type. I think we can close this now. A patch was submitted which cleans this up. 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 "Nobody will ever need more than 640k RAM!" -- Bill Gates, 1981 "Windows 95 needs@least 8 MB RAM." -- Bill Gates, 1996 "Nobody will ever need Windows 95." -- logical conclusion