From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0047.outbound.protection.outlook.com [104.47.32.47]) by dpdk.org (Postfix) with ESMTP id E0B5F106A for ; Fri, 9 Dec 2016 08:33:56 +0100 (CET) Received: from BN6PR03CA0018.namprd03.prod.outlook.com (10.168.230.156) by BY2PR0301MB0744.namprd03.prod.outlook.com (10.160.63.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Fri, 9 Dec 2016 07:33:55 +0000 Received: from BL2FFO11FD042.protection.gbl (2a01:111:f400:7c09::181) by BN6PR03CA0018.outlook.office365.com (2603:10b6:404:23::28) 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; Fri, 9 Dec 2016 07:33:54 +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 BL2FFO11FD042.mail.protection.outlook.com (10.173.161.138) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.761.6 via Frontend Transport; Fri, 9 Dec 2016 07:33:54 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:884; 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 uB97Xo71029601; Fri, 9 Dec 2016 00:33:51 -0700 To: Jan Blunck References: <1479747322-5774-1-git-send-email-jblunck@infradead.org> CC: , , Jan Viktorin From: Shreyansh Jain Message-ID: Date: Fri, 9 Dec 2016 13:06:38 +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: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131257424346495132; (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)(39860400002)(39850400002)(39400400002)(39410400002)(39450400003)(39380400002)(39840400002)(2980300002)(1109001)(1110001)(336004)(339900001)(377454003)(199003)(24454002)(189002)(229853002)(5660300001)(2906002)(47776003)(8676002)(38730400001)(77096006)(33646002)(626004)(15395725005)(64126003)(36756003)(50466002)(189998001)(83506001)(8936002)(305945005)(81166006)(104016004)(86362001)(85426001)(81156014)(110136003)(65826007)(97736004)(65956001)(65806001)(356003)(4001350100001)(6916009)(4326007)(105606002)(2950100002)(31696002)(68736007)(6666003)(106466001)(23746002)(50986999)(54356999)(76176999)(92566002)(31686004)(230700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0744; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD042; 1:7ZPxsIy30m7QLK3VkA0KubxfMeOD1UQv3+EssKdyyJ5DBIx0YCkd8oIlBCoupVcNe4pXDY8B0iabbjXnXD5wA3CB3UaxN19vCgGI15d52ChcMdNW1gmo8oAMoTUYXz/PzMVZwo2vODpARmYixOncg33U3XK1aqBUiy3MLmOYEiwaj5kX2pISgah9qWzBVhlpJiUbJ+0BSFkkPY0AunEgSWK8xAB8XAtBBB2gd2MKB0uxtQMQ/edOQN8Ecz1Di1ZWfMSlj/8fgcgE6eGESPQd5a0+i69yzdFIxNOPMFRR4Yc4gKkn6m9nnjKuMc0cqhMdmN/9QZBxOghgINYWHnTZvH1l/wgpgXSTam2IDWq3MtibR+KxKVI1ebTbkzQDsdyW19MxVQDt7KRa2UMyHyAnEP7M6869unJQjQ2UYlv5tblYWel5fEfJdhJytd8RMGqhD3qsn93dnPVuTrcJUk83kbmxrqTwp9iVY19sANcGKDUS0UDCXkuXX3Qs8wjO+0r3AZvcXZBG+BDrmktKWV9shIrhxClpc9QCFja3DQ9jTj5BPa/uZB1Vfk/lAqOq8lCx58r21hH1FWbdYyy/IdNdO0WZdrqoo4bm9iYZqZ0gfAE= X-MS-Office365-Filtering-Correlation-Id: c2cc0f0c-d8bd-4076-389c-08d42005bac5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR0301MB0744; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0744; 3:JFuNdP0uZhVk++/bQNFVfe+ScNpjGuo++lCsi1//5mLNx78CNK5VIYvGYwg+OWOckMxJX8oP1qs2W5c9coeTQBirMYd+bzsOA5cVb92Jeohr2o0Nb5UlgGTV3KFXsBnMFYj1RqwIdc5TUqzINw3NtJfsoFAn5DJUVueefBqoXPdU7z1Qt/sdO97PQuZod7TUjZMSj8AFy3WOA847GaEZZKPJAHzy9lfLKb5+kQL1XcacSm+yL75yAsFfwaXZEfJRCb6mNNfwDpMhovlTiPIuxKnHvtdSkcj9BFuG3C0vaME+pWu9CwN6Iov7KT2aBE37YwTm+6+5qgkHn0UXmOCKzmEIIPf0rV1DcGLiGTm6bsyCMuMLyuTMr+2SdNrUe845 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0744; 25:DhZgGQPcqKjhduCVhhN6/dR3sRv4RcnBCNj5HZZQ+ZkmrpY8cv9whumDmYSPaJARA3/PYnS5QHwI6/kCQtcqumoLrG0c1DS2jl/e37+YKkfcElwNY867LpnqZfMH0Fw7i00KglT/oqcB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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)(13017025)(13023025)(13024025)(13018025)(13015025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123559025)(20161123556025)(20161123561025)(20161123563025); SRVR:BY2PR0301MB0744; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0744; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0744; 4:rN4xyk9zomWSjjrFsy526SbBgAoSHhtorONEJ9upsDqC2xRbJLxCFVMk+dokqyaCm9miVXkvT8ZBYYN1RgS52op3kqelkbu4bptW9Xf5/lyl1J48znuFd5iqWmA/evzpGKZKsqbWUTSxKn7na4pK9GdJsVf+qeXX5cEuyZatFh+cOb2Z8oLwzQYAB7uhxliFOHO4LHHxvOukTPN2hc4Z4vlX0scJzM7PVcSiwrXps9n4qaZ4yDSJqnm/dnpMCrCPuFSXJFXHbvHU1v7OIgs6ZpE/T83g6LlufotG76Gs4mrqtETEwgLRSSXhIz23gTq4ZZB2bSijT7WPJcGFQZ+JX2FtxLmW6jSJl6vE5LUS4n7+j9f1YqVg7pg7NIQNt0qMFEUyKk/EYOZ+ZDUzN8jyYw3QkpJaOMyKGMD10dm5DQLgo0vBkOCSjxPRp+v4EkCK/2B5iTzVrZoyf1nqILZgq+DDNnX9BCGulrtcZvUF6M31l0Jevr9PTmcSbU18aF5flD7+7qBq8T+rohqxJAr7u0sZIF2TijW4zN97+ON7XsGfKEdqeg3E3oee9IqKEp+Xs+w2idTMNNTw9Nh4GQ0AXR+hi3yiQva12VcOzT/f5RrX67OYTA5C5DqQJJTY+0YmygX67A0mUVnbSUR3iTlMvBkbSddgERsM6Y/TH/KfeDHc5OfNoOjc7n4dLPZBV5QD/gR19xhhL0ZE5JD/lB+dY42p7F1uI74Kn4G6ZtVit+d/O7TmzOvjK2MUMl6u4dNkPMCI6ynNQwkxcEJX22Vu5g== X-Forefront-PRVS: 015114592F X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; BY2PR0301MB0744; 23:01n7/c1y7u0JVoLrWav7eYbV82PWd9LBrIC?= =?Windows-1252?Q?StxI8q4xd9Vot5LVBOYjJ2syki204nYUkDtA9wxVegsv6X9e6Vdt6Hgq?= =?Windows-1252?Q?7A8u23A9zrC414YXUrqvTFK6XTjGBpa9dU+WiJRggkcwM4G0pkZ0/0B4?= =?Windows-1252?Q?qX8mR9LUpQ2GDqk71eAMND/TU0cqGgdm9LqLuREEl7gGWVJURonkaYPJ?= =?Windows-1252?Q?cbR1u067OaN7Oe5IVH5tLfza4Wnp4UJ9aEJdMQbhrBZViSfiI0+IlSlf?= =?Windows-1252?Q?l9rxi0J2nEmOoscud6a5qFkKNfga9lCd15OhaxXH9RCt+kZUbCVcXlBK?= =?Windows-1252?Q?HEB7UgDM62fg3ws575hEhgq8feFZVbpaQfN0/bSA2v36GYscB+wHrM03?= =?Windows-1252?Q?/VsfF+qGqNH56g9Iayh6DEyLsIfkiUb0tiIJKrLwFIIXTDh+Al2p0Ffr?= =?Windows-1252?Q?IW4cIriwYYQDDFsD+Yyam0U0KlwedJ89sz1tMA3ctZOfxY/mFU8zl7a8?= =?Windows-1252?Q?Oy8qEADwsoSyWno8lXDyQfN2p35AYxlK62cLrntOGpyGtKT+hHt97ZUu?= =?Windows-1252?Q?mRSJp74CeuT2/LoFp6NmcY8yaSiKP60IANbSmrcptSdytVYrs6+JWiWa?= =?Windows-1252?Q?dEsN//rXekwR4nolRQDImQMFrvFLcpwernjbtpsKg6gRPTx25UUibhLX?= =?Windows-1252?Q?Oig/X4XHQMjfmq7d9eMg35mkoDJnvpuQPPkez6scR7qbCXomNj/5Jruz?= =?Windows-1252?Q?LlatG1IB+YzMMqmhKpwHmRg7GDE3G2TnCFyiYU7IwBh8v8bTchLBLHvF?= =?Windows-1252?Q?l3Ntre/6eJ2zr1NdhHhxw1iFMuuqoaWO+6y10Uo6GddVaSzpBP4Qsomd?= =?Windows-1252?Q?Ez9DQGz3X2/Sc9lnooBqr4XCOCkkXxwq7IyW5nOEeAkUctDszIFfEeb+?= =?Windows-1252?Q?Kksx87RW3cdUCV/d292QanQecT5hA6saVtS6+FgD1x/oYpuAOdss5KyB?= =?Windows-1252?Q?63FZXNs0FiYSyMD8RraIjxZbsBSeduT/s8sTQmYhs+LhLPxHBr/JcP2x?= =?Windows-1252?Q?PqLlc5KqTbb6YR5m+wGBRGDEhQ3zk4YG2MvvNJsM4BHlZ1PwL5wEWUsA?= =?Windows-1252?Q?TCwoYXQi6JkzRyP4+lwxD2hJBJdKUY0wQt/2fJV1CtzfV3DUKMdT3RYD?= =?Windows-1252?Q?ooEVHe6F861q6VLJ/s3rZYkJ+kktKcI0b7Eoh9nmb/SugzubaVFSIphO?= =?Windows-1252?Q?qFTiFPBD4KfziHNDvW0mhxM6zWZpOnIX+na/kqPq5zKEmXGpqsQc8JFD?= =?Windows-1252?Q?+BziUMxlltnAoIJVfFoTTxcXiyxx+rvzx+mFrsm8LCWS09tj9V+FWQzi?= =?Windows-1252?Q?5Zcu5vOybfyVyNM5PltFyOpJd9iDNc8qSnX9/woXSV6pRx0mt/vyGpgR?= =?Windows-1252?Q?tFBS5wBGYkdY9qlqtAJhquCay0R+xoaMrXLwFi8KRQmT7MeDjxq7X0RJ?= =?Windows-1252?Q?zA0TB+cickR6uRHJnLC3GABsngS/rnEwa5oWSytgiDXtmENDia1kv6nZ?= =?Windows-1252?Q?Z+hVjfQEdAPwjxwY+/+70uVZHe5rcjXQnfs8z6OZgfY6O17sUqYzy0vF?= =?Windows-1252?Q?bf2pu0nTdNvegVQdI/Y7Ov80=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0744; 6:UdiTFU9enFpZiHYLqiIuCA9BpW+WkuOg1WnQuBeSProyoLRdIlElZ7MejgGNDyddSuYypEXAiuKCHEAULnhFFdTbd4/i9oLBgM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x5hwKClj603rhyKuA2pIaQ6sOJ3XN5wz6qyJKGORGelr2yIpHAI3C2dsdGkcFx2fHNf5KoCZz6CfIHLsQ0Zsdq3+WvHRfSyphMrLPWHHnJBLz83HPFqpnZkb9qliFNA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2016 07:33:54.4779 (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: BY2PR0301MB0744 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: Fri, 09 Dec 2016 07:33:57 -0000 On Thursday 08 December 2016 12:31 PM, Shreyansh Jain wrote: > 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? My bad. obviously a 'do{ .. } while(0)' will not work in case of assignment. Any other hints as to how to remove this checkpatch issue? > >> + >> #define _RTE_STR(x) #x >> /** Take a macro value and get a string version of it */ >> #define RTE_STR(x) _RTE_STR(x) >> > > - > Shreyansh > > >