From patchwork Thu Jul 13 17:34:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Scheurich X-Patchwork-Id: 787932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x7jcV0FDkz9sNx for ; Fri, 14 Jul 2017 03:34:33 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C11FABD0; Thu, 13 Jul 2017 17:34:31 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 23DECBCA for ; Thu, 13 Jul 2017 17:34:31 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 39C6ECD for ; Thu, 13 Jul 2017 17:34:29 +0000 (UTC) X-AuditID: c1b4fb3a-81bff70000001b2f-8c-5967af2452a9 Received: from ESESSHC017.ericsson.se (Unknown_Domain [153.88.183.69]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 73.10.06959.42FA7695; Thu, 13 Jul 2017 19:34:28 +0200 (CEST) Received: from ESESSMB107.ericsson.se ([169.254.7.42]) by ESESSHC017.ericsson.se ([153.88.183.69]) with mapi id 14.03.0352.000; Thu, 13 Jul 2017 19:34:27 +0200 From: Jan Scheurich To: Ben Pfaff , =?iso-8859-1?Q?Zolt=E1n_Balogh?= Thread-Topic: [PATCH 1/4] Add OF actions for generic encap and decap Thread-Index: AdLxsw+EykZoY8ykSh+EXUeZmPMIAgIyzIMAAFo7VYAAASiIgAAEeIhA Date: Thu, 13 Jul 2017 17:34:26 +0000 Message-ID: References: <20170711214532.GV29918@ovn.org> <20170713172219.GV29918@ovn.org> In-Reply-To: <20170713172219.GV29918@ovn.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [153.88.183.154] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRmVeSWpSXmKPExsUyM2K7q67K+vRIg1vfJC1eTW5gtDh6eg+z xYpNp5ktfn/dxuTA4rF4z0smj2c3/zN6PL/Ww+Lxft9VtgCWKC6blNSczLLUIn27BK6M209n shfsFq44/vU4SwPjZv4uRk4OCQETiYn/DrF2MXJxCAkcYZQ48GoTlLOYUWLeswtsXYwcHGwC BhKzdzuAmCICMRIHD7qB9DILHGCUOHyvEsQWFnCWeHF6BzuILSLgIrHw0kVmCNtN4smHy2A2 i4CqxOLmRkYQm1fAV2L17JNsEKu+Mkp032kFS3AK6Eq0tM0EG8QoICbx/dQaJohl4hK3nsxn gjhaQGLJnvPMELaoxMvH/1ghbCWJRbc/Q9XrSdyYOoUNwtaWWLbwNTPEYkGJkzOfsExgFJ2F ZOwsJC2zkLTMQtKygJFlFaNocWpxcW66kZFealFmcnFxfp5eXmrJJkZgPB3c8ttqB+PB546H GAU4GJV4eMsWpkcKsSaWFVfmHmKU4GBWEuE9tBwoxJuSWFmVWpQfX1Sak1p8iFGag0VJnNdh 34UIIYH0xJLU7NTUgtQimCwTB6dUA2P8u3Py6c6v5kS15712ehoocUnibc5tkUeNIpYTP7Cw ldfe2pexeaLCfDMtCdYdr6evWDjjgL0I98LW2U9Cf/esPDjzZ9M2pSNqC2eJBRfO5r1ht2J/ sNG9oOOe2ZceWq7z2Rq86Iagg+GMzdMZTxexC873f7xRtI3l8J7cggOLlr2PWZM6b0WLEktx RqKhFnNRcSIAFzwr8KMCAAA= X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: "'dev@openvswitch.org'" , "Jiri Benc \(jbenc@redhat.com\)" Subject: Re: [ovs-dev] [PATCH 1/4] Add OF actions for generic encap and decap X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The simple way out is to use ALIGNED_CAST instead. format_ed_prop_value(s, prop); ds_put_cstr(s, ")"); p += ROUND_UP(prop->len, 8); - prop = (const struct ofpact_ed_prop *) p; + prop = ALIGNED_CAST(const struct ofpact_ed_prop *, p); } } While I'm sure this is correct for the second case, I don't understand enough of the ofpbuf implementation to be certain that the buffer has the same alignment after a re-allocation. If that was guaranteed, the ALIGNED_CAST should be safe as the start_ofs does not change. /Jan > -----Original Message----- > From: Ben Pfaff [mailto:blp@ovn.org] > Sent: Thursday, 13 July, 2017 19:22 > To: Zoltán Balogh > Cc: 'dev@openvswitch.org' ; Jan Scheurich ; Georg Schmuecking > ; Jiri Benc (jbenc@redhat.com) ; Yang, Yi Y > Subject: Re: [PATCH 1/4] Add OF actions for generic encap and decap > > On Thu, Jul 13, 2017 at 04:49:09PM +0000, Zoltán Balogh wrote: > > Hello Ben, > > > > > > > GCC says: > > > > > > ../lib/ofp-actions.c:4189:13: error: cast from 'char *' to 'struct ofpact_encap *' increases required alignment > > > from 1 to 4 [-Werror,-Wcast-align] > > > ../lib/ofp-actions.c:4222:16: error: cast from 'const uint8_t *' (aka 'const unsigned char *') to 'const struct > > > ofpact_ed_prop *' increases required alignment from 1 to 2 [-Werror,-Wcast-align] > > > > I cannot see these errors. I've tested with GCC 4.8.4 on Ubuntu 14.04.5 LTS and with GCC 6.3.0 on Ubuntu 17.04. > > Which version of GCC and Linux distro did you use? Did you pass any special args to make or to the configure script? > > It might be specific to 32-bit builds, since I build and test on i386. diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 04dd048..cc19db4 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -4189,7 +4189,8 @@ parse_ENCAP(char *arg, return error; } /* ofbuf out may have been re-allocated. */ - encap = (struct ofpact_encap *) ((char *)out->data + start_ofs); + encap = ALIGNED_CAST(struct ofpact_encap *, (char *)out->data + start_ofs); encap->n_props = n_props; ofpact_finish_ENCAP(out, &encap); return NULL; @@ -4224,7 +4225,7 @@ format_ed_props(struct ds *s, uint16_t n_props,