mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alessio Balsini <balsini@android.com>
To: linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@android.com,
	Alessio Balsini <balsini@android.com>,
	Jens Axboe <axboe@kernel.dk>
Subject: [PATCH] block: Fix implicit unsigned to signed conversion
Date: Wed, 18 Sep 2019 11:38:28 +0100	[thread overview]
Message-ID: <20190918103828.257631-1-balsini@android.com> (raw)

An unsigned integer variable may be assigned negative values, and is
returned by the function with an implicit conversion to signed.  Besides
the implicit conversion at return time for which the variable
representation is fine and there is no variable manipulation that may
lead to bugs in the current code base, this is a conceptual error.

Fix by changing the variable type from unsigned to signed.

Signed-off-by: Alessio Balsini <balsini@android.com>
Cc: Jens Axboe <axboe@kernel.dk>
---
 block/blk-settings.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 6bd1e3b082d8..c76c25c45869 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -496,7 +496,8 @@ EXPORT_SYMBOL(blk_queue_stack_limits);
 int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
 		     sector_t start)
 {
-	unsigned int top, bottom, alignment, ret = 0;
+	unsigned int top, bottom, alignment;
+	int ret = 0;
 
 	t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
 	t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
-- 
2.23.0.237.gc6a4ce50a0-goog


             reply	other threads:[~2019-09-18 10:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 10:38 Alessio Balsini [this message]
2019-09-18 19:38 ` Chaitanya Kulkarni

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=20190918103828.257631-1-balsini@android.com \
    --to=balsini@android.com \
    --cc=axboe@kernel.dk \
    --cc=kernel-team@android.com \
    --cc=linux-block@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®