All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Don.Brace@microchip.com>
To: natechancellor@gmail.com, axboe@kernel.dk, aacraid@microsemi.com,
	jejb@linux.ibm.com, martin.petersen@oracle.com,
	manoj@linux.ibm.com, mrochs@linux.ibm.com, ukrishn@linux.ibm.com,
	linuxdrivers@attotech.com, don.brace@microsemi.com,
	brking@us.ibm.com
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, esc.storagedev@microsemi.com,
	ndesaulniers@google.com, bvanassche@acm.org
Subject: RE: [PATCH v4] scsi/ata: Use unsigned int for cmd's type in ioctls in scsi_host_template
Date: Mon, 28 Jan 2019 16:16:34 +0000	[thread overview]
Message-ID: <SN6PR11MB2767DF2A2BEF95EE07C15172E1960@SN6PR11MB2767.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20190126075256.29608-1-natechancellor@gmail.com>


Clang warns several times in the scsi subsystem (trimmed for brevity):

drivers/scsi/hpsa.c:6209:7: warning: overflow converting case value to switch condition type (2147762695 to 18446744071562347015) [-Wswitch]
        case CCISS_GETBUSTYPES:
             ^
drivers/scsi/hpsa.c:6208:7: warning: overflow converting case value to switch condition type (2147762694 to 18446744071562347014) [-Wswitch]
        case CCISS_GETHEARTBEAT:
             ^

The root cause is that the _IOC macro can generate really large numbers, which don't find into type 'int', which is used for the cmd paremeter in the ioctls in scsi_host_template. My research into how GCC and Clang are handling this at a low level didn't prove fruitful. However, looking at the rest of the kernel tree, all ioctls use an 'unsigned int' for the cmd parameter, which will fit all of the _IOC values in the scsi/ata subsystems.

Make that change because none of the ioctls expect to take a negative value, it brings the ioctls inline with the reset of the kernel, and it removes ambiguity, which is never good when dealing with compilers.

Link: https://github.com/ClangBuiltLinux/linux/issues/85
Link: https://github.com/ClangBuiltLinux/linux/issues/154
Link: https://github.com/ClangBuiltLinux/linux/issues/157
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>

 static void __exit esas2r_exit(void)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index ff67ef5d5347..28cfd3d01c5a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -251,10 +251,11 @@ static int number_of_controllers;

Acked-by: Don Brace <don.brace@microsemi.com>

 
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index f564af8949e8..5d9ccbab7581 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6043,7 +6043,8 @@ static int pqi_passthru_ioctl(struct pqi_ctrl_info *ctrl_info, void __user *arg)
 	return rc;
 }

Acked-by: Don Brace <don.brace@microsemi.com>
 

WARNING: multiple messages have this Message-ID (diff)
From: <Don.Brace@microchip.com>
To: <natechancellor@gmail.com>, <axboe@kernel.dk>,
	<aacraid@microsemi.com>, <jejb@linux.ibm.com>,
	<martin.petersen@oracle.com>, <manoj@linux.ibm.com>,
	<mrochs@linux.ibm.com>, <ukrishn@linux.ibm.com>,
	<linuxdrivers@attotech.com>, <don.brace@microsemi.com>,
	<brking@us.ibm.com>
Cc: <linux-ide@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-scsi@vger.kernel.org>, <esc.storagedev@microsemi.com>,
	<ndesaulniers@google.com>, <bvanassche@acm.org>
Subject: RE: [PATCH v4] scsi/ata: Use unsigned int for cmd's type in ioctls in scsi_host_template
Date: Mon, 28 Jan 2019 16:16:34 +0000	[thread overview]
Message-ID: <SN6PR11MB2767DF2A2BEF95EE07C15172E1960@SN6PR11MB2767.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20190126075256.29608-1-natechancellor@gmail.com>


Clang warns several times in the scsi subsystem (trimmed for brevity):

drivers/scsi/hpsa.c:6209:7: warning: overflow converting case value to switch condition type (2147762695 to 18446744071562347015) [-Wswitch]
        case CCISS_GETBUSTYPES:
             ^
drivers/scsi/hpsa.c:6208:7: warning: overflow converting case value to switch condition type (2147762694 to 18446744071562347014) [-Wswitch]
        case CCISS_GETHEARTBEAT:
             ^

The root cause is that the _IOC macro can generate really large numbers, which don't find into type 'int', which is used for the cmd paremeter in the ioctls in scsi_host_template. My research into how GCC and Clang are handling this at a low level didn't prove fruitful. However, looking at the rest of the kernel tree, all ioctls use an 'unsigned int' for the cmd parameter, which will fit all of the _IOC values in the scsi/ata subsystems.

Make that change because none of the ioctls expect to take a negative value, it brings the ioctls inline with the reset of the kernel, and it removes ambiguity, which is never good when dealing with compilers.

Link: https://github.com/ClangBuiltLinux/linux/issues/85
Link: https://github.com/ClangBuiltLinux/linux/issues/154
Link: https://github.com/ClangBuiltLinux/linux/issues/157
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>

 static void __exit esas2r_exit(void)
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index ff67ef5d5347..28cfd3d01c5a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -251,10 +251,11 @@ static int number_of_controllers;

Acked-by: Don Brace <don.brace@microsemi.com>

 
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index f564af8949e8..5d9ccbab7581 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6043,7 +6043,8 @@ static int pqi_passthru_ioctl(struct pqi_ctrl_info *ctrl_info, void __user *arg)
 	return rc;
 }

Acked-by: Don Brace <don.brace@microsemi.com>
 


  parent reply	other threads:[~2019-01-28 16:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19 17:57 [PATCH] scsi/ata: Use unsigned int for cmd's type in ioctls in scsi_host_template Nathan Chancellor
2018-10-19 19:38 ` Bart Van Assche
2018-10-20  4:52 ` kbuild test robot
2018-10-20  4:52   ` kbuild test robot
2018-10-20  5:01 ` [PATCH v2] " Nathan Chancellor
2018-12-17 17:31   ` Nathan Chancellor
2019-01-14  4:42   ` [PATCH v3] " Nathan Chancellor
2019-01-14  4:54     ` Bart Van Assche
2019-01-14  4:57       ` Nathan Chancellor
2019-01-26  7:52     ` [PATCH v4] " Nathan Chancellor
2019-01-26  9:19       ` Nick Desaulniers
2019-01-28 16:16       ` Don.Brace [this message]
2019-01-28 16:16         ` Don.Brace
2019-01-28 16:17         ` Nathan Chancellor
2019-02-05 18:42       ` Grove, Bradley
2019-02-07 10:52       ` Marc Gonzalez
2019-02-07 16:07       ` [PATCH v5] " Nathan Chancellor
2019-02-07 19:17         ` Nick Desaulniers
2019-02-08  8:05         ` Christoph Hellwig
2019-02-08 16:00           ` Nathan Chancellor
2019-02-08 22:33         ` Martin K. Petersen

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=SN6PR11MB2767DF2A2BEF95EE07C15172E1960@SN6PR11MB2767.namprd11.prod.outlook.com \
    --to=don.brace@microchip.com \
    --cc=aacraid@microsemi.com \
    --cc=axboe@kernel.dk \
    --cc=brking@us.ibm.com \
    --cc=bvanassche@acm.org \
    --cc=don.brace@microsemi.com \
    --cc=esc.storagedev@microsemi.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxdrivers@attotech.com \
    --cc=manoj@linux.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=mrochs@linux.ibm.com \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=ukrishn@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.