From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] libmlx4: Fix a compiler warning
Date: Sun, 01 Apr 2012 19:09:38 +0000 [thread overview]
Message-ID: <4F78A7F2.7020903@acm.org> (raw)
In-Reply-To: <CAL1RGDVNoh1Fdm5pvDaeB9YykRpfXMe-s+P_iHs=8Z_r5_DpBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 10/11/11 00:41, Roland Dreier wrote:
> On Mon, Oct 10, 2011 at 10:47 AM, Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org> wrote:
>> - uint32_t hi = *(uint32_t *)(gid->raw);
>> - uint32_t lo = *(uint32_t *)(gid->raw + 4);
>> - if (hi == htonl(0xfe800000) && lo == 0)
>> - return 1;
>> + uint32_t hi = gid->u32[0];
>> + uint32_t lo = gid->u32[1];
>
> Thanks, however I like to keep libmlx4 backwards compatible
> if possible. So we can't do this unconditionally.
How about the patch below ?
[PATCH] libmlx4: Fix a compiler warning
Avoid that link_local_gid() triggers the following compiler warning:
dereferencing type-punned pointer will break strict-aliasing rules
Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
---
configure.in | 10 ++++++++++
src/verbs.c | 5 +++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/configure.in b/configure.in
index 8aad5ff..eb03820 100644
--- a/configure.in
+++ b/configure.in
@@ -63,6 +63,16 @@ AM_CONDITIONAL(HAVE_IBV_DEVICE_LIBRARY_EXTENSION,
test $IBV_DEVICE_LIBRARY_EXTENSION != IBV_DEVICE_LIBRARY_EXTENSION)
AC_SUBST(IBV_DEVICE_LIBRARY_EXTENSION)
+# Check whether ibv_gid has a member called u32.
+
+AC_CHECK_MEMBER([ibv_gid.u32],
+ [AC_DEFINE([HAVE_IBV_GID_U32],
+ 1,
+ [Define to 1 if ibv_gid has a member called u32.])
+ ],
+ [],
+ [#include <infiniband/verbs.h>])
+
AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
[if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
ac_cv_version_script=yes
diff --git a/src/verbs.c b/src/verbs.c
index 408fc6d..c7a08a5 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -624,8 +624,13 @@ int mlx4_destroy_qp(struct ibv_qp *ibqp)
static int link_local_gid(const union ibv_gid *gid)
{
+#ifdef HAVE_IBV_GID_M32
+ uint32_t hi = gid->u32[0];
+ uint32_t lo = gid->u32[1];
+#else
uint32_t hi = *(uint32_t *)(gid->raw);
uint32_t lo = *(uint32_t *)(gid->raw + 4);
+#endif
if (hi == htonl(0xfe800000) && lo == 0)
return 1;
--
1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-04-01 19:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-10 17:47 [PATCH] libmlx4: Fix a compiler warning Bart Van Assche
[not found] ` <201110101947.34035.bvanassche-HInyCGIudOg@public.gmane.org>
2011-10-11 0:41 ` Roland Dreier
[not found] ` <CAL1RGDVNoh1Fdm5pvDaeB9YykRpfXMe-s+P_iHs=8Z_r5_DpBQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-01 19:09 ` Bart Van Assche [this message]
[not found] ` <4F78A7F2.7020903-HInyCGIudOg@public.gmane.org>
2012-04-02 15:56 ` Bart Van Assche
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=4F78A7F2.7020903@acm.org \
--to=bvanassche-hinycgiudog@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=roland-BHEL68pLQRGGvPXPguhicg@public.gmane.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