* [PATCH] staging: lustre: fix min() comparison types lacks cast build warning
@ 2015-01-18 10:54 jmmahler
2015-01-18 11:17 ` Jeremiah Mahler
0 siblings, 1 reply; 2+ messages in thread
From: jmmahler @ 2015-01-18 10:54 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: kbuild test robot, kbuild-all, linux-kernel, Jeremiah Mahler
Recent changes to use the builtin min functions [1] introduced
type checking which wasn't present before. This resulted in
"comparision of distinct pointer types lacks a cast" build
warnings on non X86 architectures [2,3].
[1]: https://lkml.org/lkml/2014/12/25/145
[2]: https://lists.01.org/pipermail/kbuild-all/2015-January/008588.html
[3]: https://lists.01.org/pipermail/kbuild-all/2015-January/008589.html
The call to min() which resulted in this warning took the result
of kiblnd_rd_frag_size(), which returned a __u32, and the
variable 'resid', which is an int. 'resid' is inside a while
loop which is only entered if it is positive. Casting it as a
__u32 can be perormed without a loss of data or change in
functionality.
Fix the warning by casting 'resid' as a __u32.
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
---
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 74df2af..d2e5667 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1126,7 +1126,8 @@ kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
}
wrknob = min(min(kiblnd_rd_frag_size(srcrd, srcidx),
- kiblnd_rd_frag_size(dstrd, dstidx)), resid);
+ kiblnd_rd_frag_size(dstrd, dstidx)),
+ (__u32) resid);
sge = &tx->tx_sge[tx->tx_nwrq];
sge->addr = kiblnd_rd_frag_addr(srcrd, srcidx);
--
2.1.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] staging: lustre: fix min() comparison types lacks cast build warning
2015-01-18 10:54 [PATCH] staging: lustre: fix min() comparison types lacks cast build warning jmmahler
@ 2015-01-18 11:17 ` Jeremiah Mahler
0 siblings, 0 replies; 2+ messages in thread
From: Jeremiah Mahler @ 2015-01-18 11:17 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: kbuild test robot, kbuild-all, linux-kernel, Jeremiah Mahler
Recent changes to use the builtin min functions [1] introduced
type checking which wasn't present before. This resulted in
"comparision of distinct pointer types lacks a cast" build
warnings on non X86 architectures [2,3].
[1]: https://lkml.org/lkml/2014/12/25/145
[2]: https://lists.01.org/pipermail/kbuild-all/2015-January/008588.html
[3]: https://lists.01.org/pipermail/kbuild-all/2015-January/008589.html
The call to min() which resulted in this warning took the result
of kiblnd_rd_frag_size(), which returned a __u32, and the
variable 'resid', which is an int. 'resid' is inside a while
loop which is only entered if it is positive. Casting it as a
__u32 can be perormed without a loss of data or change in
functionality.
Fix the warning by casting 'resid' as a __u32.
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
---
Notes:
- Resend to fix wrong From: address.
drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index 74df2af..d2e5667 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -1126,7 +1126,8 @@ kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
}
wrknob = min(min(kiblnd_rd_frag_size(srcrd, srcidx),
- kiblnd_rd_frag_size(dstrd, dstidx)), resid);
+ kiblnd_rd_frag_size(dstrd, dstidx)),
+ (__u32) resid);
sge = &tx->tx_sge[tx->tx_nwrq];
sge->addr = kiblnd_rd_frag_addr(srcrd, srcidx);
--
2.1.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-18 11:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-18 10:54 [PATCH] staging: lustre: fix min() comparison types lacks cast build warning jmmahler
2015-01-18 11:17 ` Jeremiah Mahler
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®