linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Andrzej Hajda <a.hajda@samsung.com>
Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org,
	linux-api@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-cachefs@redhat.com, linux-clk@vger.kernel.org,
	linux-crypto@vger.kernel.org, linux-fbdev@vger.kernel.org,
	linux-input@vger.kernel.org, linux-leds@vger.kernel.org,
	linux-media@vger.kernel.org, linux-mips@linux-mips.org,
	linux-mm@kvack.org, linux-omap@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-sh@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-wireless@vger.kernel.org, lustre-devel@lists.lustre.org
Subject: Re: [PATCH 00/38] Fixes related to incorrect usage of unsigned types
Date: Mon, 21 Sep 2015 14:42:25 +0100	[thread overview]
Message-ID: <17571.1442842945@warthog.procyon.org.uk> (raw)
In-Reply-To: <1442842450-29769-1-git-send-email-a.hajda@samsung.com>

Andrzej Hajda <a.hajda@samsung.com> wrote:

> Semantic patch finds comparisons of types:
>     unsigned < 0
>     unsigned >= 0
> The former is always false, the latter is always true.
> Such comparisons are useless, so theoretically they could be
> safely removed, but their presence quite often indicates bugs.

Or someone has left them in because they don't matter and there's the
possibility that the type being tested might be or become signed under some
circumstances.  If the comparison is useless, I'd expect the compiler to just
discard it - for such cases your patch is pointless.

If I have, for example:

	unsigned x;

	if (x == 0 || x > 27)
		give_a_range_error();

I will write this as:

	unsigned x;

	if (x <= 0 || x > 27)
		give_a_range_error();

because it that gives a way to handle x being changed to signed at some point
in the future for no cost.  In which case, your changing the <= to an ==
"because the < part of the case is useless" is arguably wrong.

David

  parent reply	other threads:[~2015-09-21 13:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1442842450-29769-1-git-send-email-a.hajda@samsung.com>
2015-09-21 13:33 ` [PATCH 20/38] net: brcm80211: fix range check Andrzej Hajda
2015-09-22 23:15   ` David Miller
2015-09-21 13:33 ` [PATCH 21/38] mwifiex: fix comparison expression Andrzej Hajda
2015-09-22 10:56   ` Amitkumar Karwar
2015-09-22 23:15   ` David Miller
2015-09-21 13:33 ` [PATCH 22/38] orinoco: fix checking for default value Andrzej Hajda
2015-09-22 23:15   ` David Miller
2015-09-21 13:33 ` [PATCH 23/38] rndis_wlan: " Andrzej Hajda
2015-09-22 23:15   ` David Miller
2015-09-21 13:42 ` David Howells [this message]
2015-09-22  9:13   ` [PATCH 00/38] Fixes related to incorrect usage of unsigned types Andrzej Hajda
2015-09-22  9:46     ` Jacek Anaszewski

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=17571.1442842945@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=a.hajda@samsung.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.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;
as well as URLs for NNTP newsgroup(s).