linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] dm: remove redundant unsigned comparison to less than zero
@ 2019-05-01 12:57 Colin King
  2019-05-02 13:27 ` Bryan Gurney
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-05-01 12:57 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, dm-devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Variable block is an unsigned long long hence the less than zero
comparison is always false, hence it is redundant and can be removed.

Addresses-Coverity: ("Unsigned compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/md/dm-dust.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-dust.c b/drivers/md/dm-dust.c
index 178587bdc626..e739092bfc65 100644
--- a/drivers/md/dm-dust.c
+++ b/drivers/md/dm-dust.c
@@ -411,7 +411,7 @@ static int dust_message(struct dm_target *ti, unsigned int argc, char **argv,
 
 		block = tmp;
 		sector_div(size, dd->sect_per_block);
-		if (block > size || block < 0) {
+		if (block > size) {
 			DMERR("selected block value out of range");
 			return result;
 		}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] dm: remove redundant unsigned comparison to less than zero
  2019-05-01 12:57 [PATCH][next] dm: remove redundant unsigned comparison to less than zero Colin King
@ 2019-05-02 13:27 ` Bryan Gurney
  0 siblings, 0 replies; 2+ messages in thread
From: Bryan Gurney @ 2019-05-02 13:27 UTC (permalink / raw)
  To: Colin King
  Cc: Alasdair Kergon, Mike Snitzer, dm-devel, kernel-janitors, linux-kernel

On Wed, May 1, 2019 at 8:58 AM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Variable block is an unsigned long long hence the less than zero
> comparison is always false, hence it is redundant and can be removed.
>
> Addresses-Coverity: ("Unsigned compared against 0")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/md/dm-dust.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-dust.c b/drivers/md/dm-dust.c
> index 178587bdc626..e739092bfc65 100644
> --- a/drivers/md/dm-dust.c
> +++ b/drivers/md/dm-dust.c
> @@ -411,7 +411,7 @@ static int dust_message(struct dm_target *ti, unsigned int argc, char **argv,
>
>                 block = tmp;
>                 sector_div(size, dd->sect_per_block);
> -               if (block > size || block < 0) {
> +               if (block > size) {
>                         DMERR("selected block value out of range");
>                         return result;
>                 }
> --
> 2.20.1
>

Thanks.

There was already a check before that to ensure that the argument
feeding this variable is an unsigned long long; if it isn't, it will
fail with EINVAL:

# dmsetup message -- dust1 0 queryblock -1
device-mapper: message ioctl on dust1  failed: Invalid argument
Command failed

Reviewed-by: Bryan Gurney <bgurney@redhat.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-02 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 12:57 [PATCH][next] dm: remove redundant unsigned comparison to less than zero Colin King
2019-05-02 13:27 ` Bryan Gurney

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).