From patchwork Fri Oct 23 23:45:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 55664 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9NNfoEK005694 for ; Fri, 23 Oct 2009 23:43:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752255AbZJWXm7 (ORCPT ); Fri, 23 Oct 2009 19:42:59 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752304AbZJWXm7 (ORCPT ); Fri, 23 Oct 2009 19:42:59 -0400 Received: from mail-ew0-f208.google.com ([209.85.219.208]:58307 "EHLO mail-ew0-f208.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752255AbZJWXm6 (ORCPT ); Fri, 23 Oct 2009 19:42:58 -0400 Received: by ewy4 with SMTP id 4so2111266ewy.37 for ; Fri, 23 Oct 2009 16:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:mime-version:content-type:content-disposition :user-agent; bh=gl4PjRZ3C01UftzDuB4KtbbBIwncRu7Iqq9vtSWqy84=; b=hxMWkcXk2j5DuwKMzAvtB00chx9DklM0JadUCM0aORVv8d8lc0pGqsWGs390WIcKdH 4i01yqumrAZesoEGADcwHFmK1vyBTZjRduDgBG/ZjnHEQk/DoINUMesDjrGLmCD+HUGs YWUOVokTFI5T01Q6npZ4q3+YSy+Ynjg/5pcA4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=VsMYbGyJYM1NyjihIQh6CEMOOncR1fLiPdFnqmFVY3RWyauxsWBnM4tnb8A800vQ9X jBxq8GUp6r7UbjmptnLwOk+PcaP4fsCdMKJUkYR2j5Yd5hkQk4lkndYE3N1cq21tXsTb YMcb2dFYikTCJLEVtPh2tn3j8HscFjaPTAveo= Received: by 10.211.143.9 with SMTP id v9mr1130093ebn.53.1256341382326; Fri, 23 Oct 2009 16:43:02 -0700 (PDT) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id 28sm4094580eyg.6.2009.10.23.16.43.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 23 Oct 2009 16:43:01 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id 8F0CE11F05; Sat, 24 Oct 2009 01:45:05 +0200 (IST) Date: Sat, 24 Oct 2009 01:45:05 +0200 From: Sasha Khapyorsky To: linux-rdma Cc: Itai Baz Subject: [PATCH] libibmad: fix strinct-aliasing breakage warnings Message-ID: <20091023234505.GL5764@me> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/libibmad/src/bm.c b/libibmad/src/bm.c index 2983855..7d53cf1 100644 --- a/libibmad/src/bm.c +++ b/libibmad/src/bm.c @@ -53,7 +53,11 @@ uint8_t *bm_call_via(void *data, ib_portid_t * portid, ib_bm_call_t * call, { ib_rpc_t rpc = { 0 }; int resp_expected; - char data_with_bkey[IB_BM_BKEY_AND_DATA_SZ] = { 0 }; + struct { + uint64_t bkey; + uint8_t reserved[32]; + uint8_t data[IB_BM_DATA_SZ]; + } bm_data; DEBUG("route %s data %p", portid2str(portid), data); if (portid->lid <= 0) { @@ -74,9 +78,9 @@ uint8_t *bm_call_via(void *data, ib_portid_t * portid, ib_bm_call_t * call, rpc.dataoffs = IB_BM_BKEY_OFFS; // copy data to a buffer which also includes the bkey - *((uint64_t *) data_with_bkey) = htonll(call->bkey); - memcpy(data_with_bkey + IB_BM_DATA_OFFS - IB_BM_BKEY_OFFS, data, - IB_BM_DATA_SZ); + bm_data.bkey = htonll(call->bkey); + memset(bm_data.reserved, 0, sizeof(bm_data.reserved)); + memcpy(bm_data.data, data, IB_BM_DATA_SZ); DEBUG ("method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d bkey 0x%08x%08x", @@ -89,17 +93,15 @@ uint8_t *bm_call_via(void *data, ib_portid_t * portid, ib_bm_call_t * call, if (resp_expected) { /* FIXME: no RMPP for now */ - if (mad_rpc - (srcport, &rpc, portid, data_with_bkey, data_with_bkey)) + if (mad_rpc(srcport, &rpc, portid, &bm_data, &bm_data)) goto return_ok; return NULL; } - if (mad_send_via(&rpc, portid, 0, data_with_bkey, srcport) < 0) + if (mad_send_via(&rpc, portid, 0, &bm_data, srcport) < 0) return NULL; return_ok: - memcpy(data, data_with_bkey + IB_BM_DATA_OFFS - IB_BM_BKEY_OFFS, - IB_BM_DATA_SZ); + memcpy(data, bm_data.data, IB_BM_DATA_SZ); return data; } diff --git a/libibmad/src/resolve.c b/libibmad/src/resolve.c index 3e07e8a..b89360c 100644 --- a/libibmad/src/resolve.c +++ b/libibmad/src/resolve.c @@ -98,7 +98,7 @@ int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid, ib_portid_t sm_portid; uint8_t buf[IB_SA_DATA_SIZE] = { 0 }; ib_portid_t self = { 0 }; - uint64_t selfguid; + uint64_t selfguid, prefix; ibmad_gid_t selfgid; uint8_t nodeinfo[64]; @@ -114,7 +114,8 @@ int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid, mad_set_field64(selfgid, 0, IB_GID_PREFIX_F, IB_DEFAULT_SUBN_PREFIX); mad_set_field64(selfgid, 0, IB_GID_GUID_F, selfguid); - if (*(uint64_t *) & portid->gid == 0) + memcpy(&prefix, portid->gid, sizeof(prefix)); + if (!prefix) mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F, IB_DEFAULT_SUBN_PREFIX); if (guid)