* Clang build error in drivers/scsi/smartpqi/smartpqi_init.c
@ 2018-12-21 7:11 Nathan Chancellor
2018-12-21 7:22 ` Nathan Chancellor
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2018-12-21 7:11 UTC (permalink / raw)
To: Don Brace, esc.storagedev
Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel, Nick Desaulniers
Hi all,
After commit 4fd22c13ad44 ("scsi: smartpqi: add ofa support"), an arm
allyesconfig build with Clang fails with the following warning/error:
drivers/scsi/smartpqi/smartpqi_init.c:7473:2: warning: comparison of distinct pointer types ('typeof ((sg_count)) *' (aka 'unsigned int *') and 'uint64_t *' (aka 'unsigned long long *')) [-Wcompare-distinct-pointer-types]
do_div(sg_count, chunk_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/div64.h:222:28: note: expanded from macro 'do_div'
(void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
drivers/scsi/smartpqi/smartpqi_init.c:7473:2: error: incompatible pointer types passing 'u32 *' (aka 'unsigned int *') to parameter of type 'uint64_t *' (aka 'unsigned long long *') [-Werror,-Wincompatible-pointer-types]
do_div(sg_count, chunk_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/div64.h:239:22: note: expanded from macro 'do_div'
__rem = __div64_32(&(n), __base); \
^~~~
./arch/arm/include/asm/div64.h:33:45: note: passing argument to parameter 'n' here
static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
^
drivers/scsi/smartpqi/smartpqi_init.c:7473:2: warning: shift count >= width of type [-Wshift-count-overflow]
do_div(sg_count, chunk_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/div64.h:235:25: note: expanded from macro 'do_div'
} else if (likely(((n) >> 32) == 0)) { \
^ ~~
./include/linux/compiler.h:76:40: note: expanded from macro 'likely'
# define likely(x) __builtin_expect(!!(x), 1)
^
According to include/asm-generic/div64.h, the first parameter of do_div
must be a 64-bit number, meaning the below diff would properly fix it.
However, I am not sure if there are any unintended consequences of this
change, hence reaching out before sending it in. If you have a more
preferred way of fixing it, please do so.
Thank you,
Nathan
==========================================================================================
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index e57fbff08f03..6a185a6172c4 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -7460,7 +7460,7 @@ static void pqi_ofa_ctrl_unquiesce(struct pqi_ctrl_info *ctrl_info)
static int pqi_ofa_alloc_mem(struct pqi_ctrl_info *ctrl_info,
u32 total_size, u32 chunk_size)
{
- u32 sg_count;
+ u64 sg_count;
u32 size;
int i;
struct pqi_sg_descriptor *mem_descriptor = NULL;
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: Clang build error in drivers/scsi/smartpqi/smartpqi_init.c
2018-12-21 7:11 Clang build error in drivers/scsi/smartpqi/smartpqi_init.c Nathan Chancellor
@ 2018-12-21 7:22 ` Nathan Chancellor
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2018-12-21 7:22 UTC (permalink / raw)
To: Don Brace, esc.storagedev
Cc: James E.J. Bottomley, Martin K. Petersen, linux-scsi,
linux-kernel, Nick Desaulniers
On Fri, Dec 21, 2018 at 12:11:00AM -0700, Nathan Chancellor wrote:
> Hi all,
>
> After commit 4fd22c13ad44 ("scsi: smartpqi: add ofa support"), an arm
> allyesconfig build with Clang fails with the following warning/error:
>
> drivers/scsi/smartpqi/smartpqi_init.c:7473:2: warning: comparison of distinct pointer types ('typeof ((sg_count)) *' (aka 'unsigned int *') and 'uint64_t *' (aka 'unsigned long long *')) [-Wcompare-distinct-pointer-types]
> do_div(sg_count, chunk_size);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/div64.h:222:28: note: expanded from macro 'do_div'
> (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
> ~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
> drivers/scsi/smartpqi/smartpqi_init.c:7473:2: error: incompatible pointer types passing 'u32 *' (aka 'unsigned int *') to parameter of type 'uint64_t *' (aka 'unsigned long long *') [-Werror,-Wincompatible-pointer-types]
> do_div(sg_count, chunk_size);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/div64.h:239:22: note: expanded from macro 'do_div'
> __rem = __div64_32(&(n), __base); \
> ^~~~
> ./arch/arm/include/asm/div64.h:33:45: note: passing argument to parameter 'n' here
> static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
> ^
> drivers/scsi/smartpqi/smartpqi_init.c:7473:2: warning: shift count >= width of type [-Wshift-count-overflow]
> do_div(sg_count, chunk_size);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/asm-generic/div64.h:235:25: note: expanded from macro 'do_div'
> } else if (likely(((n) >> 32) == 0)) { \
> ^ ~~
> ./include/linux/compiler.h:76:40: note: expanded from macro 'likely'
> # define likely(x) __builtin_expect(!!(x), 1)
> ^
>
> According to include/asm-generic/div64.h, the first parameter of do_div
> must be a 64-bit number, meaning the below diff would properly fix it.
>
> However, I am not sure if there are any unintended consequences of this
> change, hence reaching out before sending it in. If you have a more
> preferred way of fixing it, please do so.
>
> Thank you,
> Nathan
>
> ==========================================================================================
>
> diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
> index e57fbff08f03..6a185a6172c4 100644
> --- a/drivers/scsi/smartpqi/smartpqi_init.c
> +++ b/drivers/scsi/smartpqi/smartpqi_init.c
> @@ -7460,7 +7460,7 @@ static void pqi_ofa_ctrl_unquiesce(struct pqi_ctrl_info *ctrl_info)
> static int pqi_ofa_alloc_mem(struct pqi_ctrl_info *ctrl_info,
> u32 total_size, u32 chunk_size)
> {
> - u32 sg_count;
> + u64 sg_count;
> u32 size;
> int i;
> struct pqi_sg_descriptor *mem_descriptor = NULL;
Ugh disregard, I just looked at the SCSI tree and saw this was fixed
already:
https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git/commit/?id=e52c9e0710d2f5d54a521d620a230ac2ae646dc7
Should have looked at it before sending, sorry for the noise!
Nathan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-21 7:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-21 7:11 Clang build error in drivers/scsi/smartpqi/smartpqi_init.c Nathan Chancellor
2018-12-21 7:22 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox