From: Roland Dreier <rdreier@cisco.com>
To: openib-general@openib.org
Cc: linux-kernel@vger.kernel.org
Subject: dealing with gcc 'comparison is always false' warnings (was: [PATCH] drivers/infiniband: fix comparsion between unsigned and negative)
Date: Wed, 30 May 2007 08:30:00 -0700 [thread overview]
Message-ID: <adazm3mqqh3.fsf@cisco.com> (raw)
In-Reply-To: <20070530080518.GA29195@nostromo.devel.redhat.com> (Bill Nottingham's message of "Wed, 30 May 2007 04:05:18 -0400")
thanks... I'm wondering if there's a consensus among kernel hackers
about changes like:
> - if (hdr.cmd < 0 || hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
> + if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
> return -EINVAL;
I understand that new gcc sees that hdr.cmd is unsigned and hence
can't be < 0, and generates a warning for that, and having a build
cluttered with warnings hides bugs and so on. However the code here
looks quite sensible to me -- otherwise we end up with missing range
checking if hdr.cmd ever changes to a signed type. This seems like a
good way to introduce bugs: delete valid range checking code to shut
up a silly gcc warning, and then change the type of a variable.
Can't we just make gcc shut up about the comparison and generate no
code for it because it knows it can't be true?
- R.
next prev parent reply other threads:[~2007-05-30 15:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-30 8:05 [PATCH] drivers/infiniband: fix comparsion between unsigned and negative Bill Nottingham
2007-05-30 15:30 ` Roland Dreier [this message]
2007-05-30 15:41 ` dealing with gcc 'comparison is always false' warnings (was: [PATCH] drivers/infiniband: fix comparsion between unsigned and negative) Satyam Sharma
2007-05-30 15:56 ` [ofa-general] Re: dealing with gcc 'comparison is always false' warnings Roland Dreier
2007-05-30 17:00 ` Satyam Sharma
2007-05-30 16:06 ` dealing with gcc 'comparison is always false' warnings (was: [PATCH] drivers/infiniband: fix comparsion between unsigned and negative) Satyam Sharma
2007-05-30 19:00 ` dealing with gcc 'comparison is always false' warnings Tilman Schmidt
2007-05-30 19:14 ` Satyam Sharma
2007-05-30 19:09 ` dealing with gcc 'comparison is always false' warnings (was: [PATCH] drivers/infiniband: fix comparsion between unsigned and negative) Bill Nottingham
2007-05-30 19:23 ` Satyam Sharma
2007-05-30 20:48 ` [ofa-general] [PATCH] drivers/infiniband: fix comparsion between unsigned and negative Roland Dreier
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=adazm3mqqh3.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=openib-general@openib.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