From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0041.outbound.protection.outlook.com [104.47.32.41]) by dpdk.org (Postfix) with ESMTP id 4D2872A66 for ; Thu, 8 Dec 2016 07:59:14 +0100 (CET) Received: from BN3PR0301CA0076.namprd03.prod.outlook.com (10.160.152.172) by CY4PR03MB2469.namprd03.prod.outlook.com (10.168.163.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Thu, 8 Dec 2016 06:59:13 +0000 Received: from BL2FFO11OLC010.protection.gbl (2a01:111:f400:7c09::173) by BN3PR0301CA0076.outlook.office365.com (2a01:111:e400:401e::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9 via Frontend Transport; Thu, 8 Dec 2016 06:59:13 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; infradead.org; dkim=none (message not signed) header.d=none;infradead.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11OLC010.mail.protection.outlook.com (10.173.160.154) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.734.4 via Frontend Transport; Thu, 8 Dec 2016 06:59:12 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:836; Count:13 Received: from [10.232.14.87] ([10.232.14.87]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id uB86x8BV021640; Wed, 7 Dec 2016 23:59:09 -0700 To: Jan Blunck , References: <1479747322-5774-1-git-send-email-jblunck@infradead.org> CC: , Jan Viktorin From: Shreyansh Jain Message-ID: Date: Thu, 8 Dec 2016 12:31:57 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1479747322-5774-1-git-send-email-jblunck@infradead.org> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131256539530856811; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39380400002)(39400400002)(39410400002)(39840400002)(39850400002)(39450400003)(39860400002)(2980300002)(1109001)(1110001)(339900001)(336004)(199003)(377454003)(189002)(24454002)(5001770100001)(97736004)(4001350100001)(189998001)(2950100002)(6666003)(4326007)(2906002)(104016004)(65826007)(92566002)(85426001)(7846002)(305945005)(86362001)(31696002)(83506001)(23746002)(36756003)(356003)(54356999)(31686004)(50466002)(105606002)(15395725005)(47776003)(33646002)(65806001)(76176999)(50986999)(65956001)(8936002)(8676002)(81156014)(81166006)(229853002)(230700001)(38730400001)(77096006)(64126003)(68736007)(5660300001)(626004)(106466001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB2469; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC010; 1:HHYYC0CsATsq/tZWfIDkXm5XUoosuBfnJ9QwdbfQwP/UvjuNpdUVDB06+nu6yOxjKDdVfMjWK8RByHT2YtHt/DwD79izax7JXHMBmghE9Q3b0fmnulsRoE9d8BYzphx0ilh9PP1xPtcfz1Cq7ohPGMBisht2pRFZMSz0qPNBouCXnjjsNOYtTftafcQfurHo3hRkB0aZ17RJbDjEl4xhS9u+wALTuH+IFU6H7mdR1ThZgZXYdJBe5rn+dyNUJ+NBxrQtivByhh2qpKFm3hX13RQevs6CU9nTBjO3j+MPr2FI/caCysRf3LVr40WMv4KHofnVbcMwONPBLuj9AWLuDJvWNfF5Oj3SA3DD+m3gWhMJ/rhomE5CageKMM1UqOSaQf/bJbBIyFnL9xfgK12/o7fNz4J2m3nxcng8p9IAeGBvdWcutCe5SKO9fIJxmJI/Lh2HUz7FtlhaYnOq8jlA+/ojDqW4kgS1mKwFlS31+rrkFQmHswC6PXaJ1STQTC+4K54UwZvWUoRpXVdmpc7MDi59ZKVcytS1wAvYEX1R7cvl0AKH7+DDGaxepIdAP7MFZTGFNVHJio17+Oxmt90TQf7rjlbYhRiz8P9j/3f9Wks= X-MS-Office365-Filtering-Correlation-Id: 5992675c-ec79-4e15-a80d-08d41f37b7a3 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR03MB2469; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2469; 3:EPldtv0THxI4JglyqBEL8M9QSSOnK2wU46LqKA2hreC3WlcXsK39R1fsSqoDNcfsFbepMOYZoM/vLL+JfamMZ8Lx5oukdcSR2K3OEi10abT8c7U2V1nEFB9tdtImuwVgK215EGHTBfhMKz7i5j0S5L0ObEs6Jov9XnF6Qw3KBlndt2vF/YtRkS3kDOv/UmhvlT85DZOmRoKbMLYp9gLcUCggL92I8bxiqVZPQ4oO6zg4NmenYsRVT2M4Nhst4LepMghn0RmEkKmoqnukOwZFxgEqev7pD4Vse8AOpiFO255VZ3AYW19AC+pb6z/E6CgiPUnMNi+BUCHmhShHOJLUCSKNJzXN5hUnC4ftSq2CE6pQcxakMmFAxruwI78GC86r X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2469; 25:ODBnmEaPE6mDp1dJ3dtBdpXh2QAmXBaALcKQiWEwCY66270IZ80IV56e5mhTVzKrVHXAqLFI7oitQjs36dbmfWjAJRSy1E7rS5joXXj09aCPyhqEb9xPDLP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X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(5005006)(8121501046)(13015025)(13017025)(13023025)(13024025)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123563025)(20161123556025)(20161123559025)(20161123561025); SRVR:CY4PR03MB2469; BCL:0; PCL:0; RULEID:(400006); SRVR:CY4PR03MB2469; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2469; 4:r6L226KQsd/nKTlAnA0dtD1fuKV3hcFJpg9HPn1277Tzrdlpd26nSCDNChr86ML7mQhJD2ZMtFPteBzJgxAmFqgXo1XhdCDGzGcgqg8FvBfqZpKa4h/SeP+2vvRl6ol5HJ8I8IxLYbqaAMwz12DWeleS5cW3YCvzsjYM+m+YnYpkM7e1PDHJuNkATg/GC/X1+spX9KB/bjitLqk6WpeYpmVbqqorfg7MMLa7+IVfa2SkQXdZsjaCE7FfoDIxDX8lS11TszIpSPHhWZrd7Kt1gWO5Yq9+i5DKDDiDQV+l3bK1sMfxEIYjE34CFl8kTITR94s/8wHvM7xAPF2xDxU1QlNVrl+EmXC62ht5UKqwXKbPIySRqr9AF/1dxeTx3Ei6NXdGaIutF/wwXlzjZjGTvcMiToe6V1EYvyt0J/YnSWzzdWJPPQpOPAfcU3vVejrp6OPFSSsiJuNES9cC0jdJoiwtB0cBUfuVaWoBcJs2sc8q+WhCJn+vBxURxxze+aQia69ghSsNbCDqTm3OCmuPSh0BCCBc2B8wnr3PIeBLkEtvQkElhHh0Sf9Z2tveRYqYZJZ8yvB0XpuLWB1Rv4cth0LRKLimXxmdLKG6SK6bWdyrS2IOhTxJyHJFDUbH4n30iV/kIXiO4gT5/lsUsi9u6IaPrKbHu+pLHiNo5CbJinFBfoczHkzjMSguzK8drGnCp8osGZOX4xH7dxRdKWCZO1Fz8kxBr5C5JZX+cJBa7ECTUGBW2NaJ/bL+A+LdlV9R3L3KqBV22pJLgv2fDjLmDQ== X-Forefront-PRVS: 0150F3F97D X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; CY4PR03MB2469; 23:P4lwZxzhWDOknKnrqwDZ5MEbP3TvfRfnAqWU5?= =?Windows-1252?Q?ndw3+UD/5DKoUA+HM60HZypJnQZh4KdlpRrLVPRCezRCSF0q8biK6woH?= =?Windows-1252?Q?wAgKzj4lHH4b+qPwFBVYNjx3TWQq5K7q56fiz+DqHoA6HsOgNkPMjLlj?= =?Windows-1252?Q?whpZ9cw64IjeaH+mvvOC43W+Wu8+gNVnWAWMqWWJJH5+ZOMyLaeOw/5p?= =?Windows-1252?Q?SzmTabSjUWzhVVZeHJdm3+JMlzfjp7hwgwbJinNlSljA7B4DBa/VPpwi?= =?Windows-1252?Q?Hs/V9e7QU3rWCRVlxSPyoPYMeM2pjcAwBHcf1vRrW2aJ7Y1IYEwtGq3r?= =?Windows-1252?Q?S2M/N3WIEpyfvCVORoOeeGVxAAkN6Db/yTYV31DJD1/qlXQUpzfJUqiT?= =?Windows-1252?Q?71tX9vG0sqsfL2iT36DPDk95wupcsCZaSiCCTHHeRb1RAA5PlIv+kmx7?= =?Windows-1252?Q?rwJqVAiSorydNtVd/hr6oSlmR3Vp4u7RC6JHdvwqO9Rh6556v5goWdQb?= =?Windows-1252?Q?fqfbauTmSkcgWp3pl+v9xhpnARSn00QiHJXJWVc77JFsRuubEsR4v3E2?= =?Windows-1252?Q?1obhKLMsQPrxs42Ru2xrYwctGlzLrYXApm85WuUinRmXew+7bllSzM9/?= =?Windows-1252?Q?Psl77LZ83TJ1XOMDTfARo+PdmqjmD/QmP6vVYqMGE7/6nVjajtOgeen+?= =?Windows-1252?Q?rhj9J4anIam6LwROPRLq11gGO3Ip+81AgnBwyIPDEybE/9T27nQRhagg?= =?Windows-1252?Q?xgyCSRRVONA57XoC6UAr1KqpVVdE/2V/xhtTLKvnCO7/LhtxWaL961gE?= =?Windows-1252?Q?T7ueK5Rh/6tV+7FCA8EGcFX2izBuV4PkVlZuDFKpPFWKQEVk5Q4oVjPM?= =?Windows-1252?Q?w3naF2b0/8sG+W4tJkdIYBCt/jmywHypVrwKC8gj/Bdcjbl8QaL8dOq5?= =?Windows-1252?Q?kEMCakjPnstUL2b+M/fYFX6CR1pVTgP474StqOUrfH3U5Li4ooQNo0qZ?= =?Windows-1252?Q?BqI0Y1Z95DfGRS4NBcv3butodKnn0BS7FEJfkVVZaMuB+8b1MQp8+0NH?= =?Windows-1252?Q?BGaL2BisF7y7SqcYig5T9ra/ILvPpjXkpIqSMBdSMd228QRHrjw1jNYd?= =?Windows-1252?Q?fM5Om0EFwO4eReH6+L2ziR3BT/vZYHQil6YrMbCOiuTjc0gq9t0bxn2B?= =?Windows-1252?Q?2ksEemtsmOK/YlqOtOzv1D6dRc5uHYCJVWp5ONnQnWqjnpkU8skU6V08?= =?Windows-1252?Q?yxNpVLmvW0rCiqbpqrZ0lmbVnzGQxfALqnh4F1xny4SRm13E5v7qyH9F?= =?Windows-1252?Q?CEtFBdVfBngkqahH4gtLvo3YGQ15F0QakycLe1R7F5on7aEikyvKGine?= =?Windows-1252?Q?YpurEKNP+yy9uyUxZ3mwk0wtN4QJAvS40AEdaRUG3V0/omfvfdrkh2qg?= =?Windows-1252?Q?wkPg4qeTcOsYWRYn4EQn9tGJe/z+fvXBVKx3GxWAaB4Ywi/6dMIVigtE?= =?Windows-1252?Q?dlIin5/W1esHdk+IzQzwRJTJlmFay7fY4ee2sPYTxw3Awv5WdBqrFJBA?= =?Windows-1252?Q?y27GmGV+q2Ie0Q/Zw+/2faiHJHHZvPEu4/dn65BGTkdHA7CLhzPuJrpC?= =?Windows-1252?Q?Z804/tS5Yz5Wx0DseZLlMs=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB2469; 6:UCylJow2Y8KlpTNAxgeEH+fDwEJGtfqkwubArjPiW7wYsDypAJm/JxeEQjiCKVt0aKKgf627kZxZ0/oHFgrjmj/JY5f0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iEFKJaVWbbfh6Dg7RmZWjMYGnr9IGb9t6h2VevmCLUWskKOAqC4frlPaV6r+6Zxg/J3wDGb+B/Lzi6/qClZ+N45XNg0UXAl3t/7xZFP2ZQqPn/cHkBSu5k6Bw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2016 06:59:12.8984 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB2469 Subject: Re: [dpdk-dev] [PATCH v2 1/8] eal: define container_of macro X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2016 06:59:14 -0000 Hello Jan, Need your help in resolving the checkpatch issue for this patch. I have used this in EAL Bus series [1]. [1] http://dpdk.org/ml/archives/dev/2016-December/051350.html On Monday 21 November 2016 10:25 PM, Jan Blunck wrote: > This macro is based on Jan Viktorin's original patch but also checks the > type of the passed pointer against the type of the member. > > Signed-off-by: Jan Viktorin > Signed-off-by: Shreyansh Jain > [jblunck@infradead.org: add type checking and __extension__] > Signed-off-by: Jan Blunck > --- > lib/librte_eal/common/include/rte_common.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h > index db5ac91..8dda3e2 100644 > --- a/lib/librte_eal/common/include/rte_common.h > +++ b/lib/librte_eal/common/include/rte_common.h > @@ -331,6 +331,26 @@ rte_bsf32(uint32_t v) > #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) > #endif > > +/** > + * Return pointer to the wrapping struct instance. > + * > + * Example: > + * > + * struct wrapper { > + * ... > + * struct child c; > + * ... > + * }; > + * > + * struct child *x = obtain(...); > + * struct wrapper *w = container_of(x, struct wrapper, c); > + */ > +#ifndef container_of > +#define container_of(ptr, type, member) __extension__ ({ \ > + typeof(((type *)0)->member) *_ptr = (ptr); \ > + (type *)(((char *)_ptr) - offsetof(type, member)); }) > +#endif (I think there was discussion in ML about this but where, I couldn't find it). Above code snippet doesn't go down well with the checkpatch script. It reports: ---->8---- ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #40: FILE: lib/librte_eal/common/include/rte_common.h:349: +#define container_of(ptr, type, member) __extension__ ({ \ + typeof(((type *)0)->member) *_ptr = (ptr); \ + (type *)(((char *)_ptr) - offsetof(type, member)); }) ERROR:SPACING: need consistent spacing around '*' (ctx:WxV) #41: FILE: lib/librte_eal/common/include/rte_common.h:350: + typeof(((type *)0)->member) *_ptr = (ptr); \ ---->8---- Second error is primarily because of '*_ptr' rather than '*_ptr'. Is do{ ... }while(0) the fix for the first one? This: ---->8---- #ifndef container_of #define container_of(ptr, type, member) do { \ __extension__ \ typeof(((type *)0)->member) * _ptr = (ptr); \ (type *)(((char *)_ptr) - offsetof(type, member));\ } while (0) #endif ---->8---- Seems to be ok with checkpatch. Do you see any technical/compiler issue with this? > + > #define _RTE_STR(x) #x > /** Take a macro value and get a string version of it */ > #define RTE_STR(x) _RTE_STR(x) > - Shreyansh