diff mbox

[v1,1/1] scsi_debug: check for bigger value first

Message ID 1448562170-122075-1-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Andy Shevchenko Nov. 26, 2015, 6:22 p.m. UTC
From: Andy Shevchenko <andy.shevchenko@gmail.com>

Even for signed types we have to check for bigger positive value first.
Otherwise it will be never happened.

Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/scsi/scsi_debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Johannes Thumshirn Nov. 27, 2015, 9:32 a.m. UTC | #1
On Thu, 2015-11-26 at 20:22 +0200, Andy Shevchenko wrote:
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> Even for signed types we have to check for bigger positive value first.
> Otherwise it will be never happened.
> 
> Acked-by: Douglas Gilbert <dgilbert@interlog.com>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> ---
>  drivers/scsi/scsi_debug.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index dfcc45b..f773b34 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -4846,10 +4846,10 @@ static int __init scsi_debug_init(void)
>  	/* play around with geometry, don't waste too much on track 0 */
>  	sdebug_heads = 8;
>  	sdebug_sectors_per = 32;
> -	if (scsi_debug_dev_size_mb >= 16)
> -		sdebug_heads = 32;
> -	else if (scsi_debug_dev_size_mb >= 256)
> +	if (scsi_debug_dev_size_mb >= 256)
>  		sdebug_heads = 64;
> +	else if (scsi_debug_dev_size_mb >= 16)
> +		sdebug_heads = 32;
>  	sdebug_cylinders_per = (unsigned long)sdebug_capacity /
>  			       (sdebug_sectors_per * sdebug_heads);
>  	if (sdebug_cylinders_per >= 1024) {

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ewan Milne Nov. 30, 2015, 1:55 p.m. UTC | #2
On Thu, 2015-11-26 at 20:22 +0200, Andy Shevchenko wrote:
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> Even for signed types we have to check for bigger positive value first.
> Otherwise it will be never happened.
> 
> Acked-by: Douglas Gilbert <dgilbert@interlog.com>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> ---
>  drivers/scsi/scsi_debug.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index dfcc45b..f773b34 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -4846,10 +4846,10 @@ static int __init scsi_debug_init(void)
>  	/* play around with geometry, don't waste too much on track 0 */
>  	sdebug_heads = 8;
>  	sdebug_sectors_per = 32;
> -	if (scsi_debug_dev_size_mb >= 16)
> -		sdebug_heads = 32;
> -	else if (scsi_debug_dev_size_mb >= 256)
> +	if (scsi_debug_dev_size_mb >= 256)
>  		sdebug_heads = 64;
> +	else if (scsi_debug_dev_size_mb >= 16)
> +		sdebug_heads = 32;
>  	sdebug_cylinders_per = (unsigned long)sdebug_capacity /
>  			       (sdebug_sectors_per * sdebug_heads);
>  	if (sdebug_cylinders_per >= 1024) {

Reviewed-by: Ewan D. Milne <emilne@redhat.com>


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin K. Petersen Nov. 30, 2015, 5:14 p.m. UTC | #3
>>>>> "Andy" == Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:

Andy> Even for signed types we have to check for bigger positive value
Andy> first.  Otherwise it will be never happened.

Applied to 4.5/scsi-queue.
diff mbox

Patch

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index dfcc45b..f773b34 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -4846,10 +4846,10 @@  static int __init scsi_debug_init(void)
 	/* play around with geometry, don't waste too much on track 0 */
 	sdebug_heads = 8;
 	sdebug_sectors_per = 32;
-	if (scsi_debug_dev_size_mb >= 16)
-		sdebug_heads = 32;
-	else if (scsi_debug_dev_size_mb >= 256)
+	if (scsi_debug_dev_size_mb >= 256)
 		sdebug_heads = 64;
+	else if (scsi_debug_dev_size_mb >= 16)
+		sdebug_heads = 32;
 	sdebug_cylinders_per = (unsigned long)sdebug_capacity /
 			       (sdebug_sectors_per * sdebug_heads);
 	if (sdebug_cylinders_per >= 1024) {