public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: Oleg Drokin <green@linuxhacker.ru>
Cc: alan@lxorguk.ukuu.org.uk, linux-kernel@vger.kernel.org
Subject: Re: 2.4.21-pre4 comparison bugs
Date: Sun, 9 Feb 2003 00:25:10 +0100	[thread overview]
Message-ID: <20030208232510.GA1841@werewolf.able.es> (raw)
In-Reply-To: <20030208171838.GA2230@linuxhacker.ru>; from green@linuxhacker.ru on Sat, Feb 08, 2003 at 18:18:38 +0100


On 2003.02.08 Oleg Drokin wrote:
> Hello!
> 
>    Thanks to whoever mentioned "gcc -W", it's *sweet*  ;)
>    Looking at it's output I found few cases where error checking
>    does not work.
>    Though nothing too serious it seems (except maybe IDE setup-pci stuff,
>    I just do not know about that, and may be in that case
>    we actually want to change all the functions to return signed
>    value, though my fix is certainly less intrusive ;) )
>    Most of the patched stuff in here assigns signed value to unsigned
>    variable and then checks if it is less than zero which does not work
>    for obvious reasons ;)
>    I decided taht in most cases simple casting to int would be best
>    and least intrusive resolution of a problem.
>    The only exception is fs/isofs/inode.c, there we have unsigned int
>    (so it is unsigned not depending on any arch) and so '> some num'
>    stuff will also check for former negative numbers anyway. So
>    I removed one extra comparison in that case.
>    See the patch below.
> 

So:

unsgined f()
{
	return -1;
}

if ((int)f()<0)
??

Wouldn't you get killed by some kind of bit/sign extension in the return ?
Just to be sure, probably the answer is just 'go learn C internals'...

-- 
J.A. Magallon <jamagallon@able.es>      \                 Software is like sex:
werewolf.able.es                         \           It's better when it's free
Mandrake Linux release 9.1 (Cooker) for i586
Linux 2.4.21-pre4-jam1 (gcc 3.2.1 (Mandrake Linux 9.1 3.2.1-5mdk))

  reply	other threads:[~2003-02-08 23:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-08 17:18 2.4.21-pre4 comparison bugs Oleg Drokin
2003-02-08 23:25 ` J.A. Magallon [this message]
2003-02-17  2:10   ` Bill Davidsen
2003-02-09  0:58 ` Alan Cox
2003-02-09 17:53   ` 2.4.21-pre4 comparison bugs (More of those) Oleg Drokin
2003-02-09 18:22     ` 2.4.21-pre4 comparison bugs (Even More Again) Oleg Drokin
2003-02-09 21:59       ` Alan Cox
2003-02-09 22:01     ` 2.4.21-pre4 comparison bugs (More of those) Alan Cox
2003-02-10  7:06       ` Oleg Drokin
2003-02-09 16:54 ` 2.4.21-pre4 more extra semicolons bugs Oleg Drokin
2003-02-09 16:59   ` 2.4.21-pre4 - two simple compile fixes Oleg Drokin
2003-02-09 22:02     ` Alan Cox

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=20030208232510.GA1841@werewolf.able.es \
    --to=jamagallon@able.es \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=green@linuxhacker.ru \
    --cc=linux-kernel@vger.kernel.org \
    /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