public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] Spartan FPGA patch
Date: Wed, 14 Nov 2007 20:46:13 +0100	[thread overview]
Message-ID: <20071114194613.19F55247F1@gemini.denx.de> (raw)
In-Reply-To: Your message of "Wed, 14 Nov 2007 14:05:46 +0200." <473AE49A.40801@inaccessnetworks.com>

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

  reply	other threads:[~2007-11-14 19:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-30 15:51 [U-Boot-Users] Spartan FPGA patch Aggelos Manousarides
2007-11-03 21:46 ` Wolfgang Denk
2007-11-05 12:58   ` Aggelos Manousarides
2007-11-05 19:21     ` Wolfgang Denk
2007-11-07 11:43       ` Aggelos Manousarides
2007-11-07 13:33         ` Wolfgang Denk
2007-11-07 16:49           ` Andreas Schweigstill
2007-11-07 19:51             ` Wolfgang Denk
2007-11-14 12:05               ` Aggelos Manousarides
2007-11-14 19:46                 ` Wolfgang Denk [this message]
2007-11-07 14:29       ` Matthias Fuchs
2007-11-07 19:48         ` Wolfgang Denk
2007-11-07 21:07           ` Jerry Van Baren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071114194613.19F55247F1@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox