From patchwork Thu Dec 14 22:35:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10113389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3947960352 for ; Thu, 14 Dec 2017 22:37:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B30229D23 for ; Thu, 14 Dec 2017 22:37:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2013B29D2D; Thu, 14 Dec 2017 22:37:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FE9129D23 for ; Thu, 14 Dec 2017 22:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754167AbdLNWhJ (ORCPT ); Thu, 14 Dec 2017 17:37:09 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35120 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753916AbdLNWhI (ORCPT ); Thu, 14 Dec 2017 17:37:08 -0500 Received: by mail-wr0-f193.google.com with SMTP id g53so6485963wra.2 for ; Thu, 14 Dec 2017 14:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SqvdPxYpFRppAJIG4QZ49jAtA7pL76HuGEbUG+eqh88=; b=XGVNaS1Ijr+qX0NFwYVMOPbR+cbZdqX0HX09WVX1NHeWEvmIqybuAv1HTKQhmvXQd9 vxospBXvBnSRwDRxR2Z+8eMwaf/RUSJpfFOxTxDjFvo6mFbyFIAcE+sUN+KtMEFLw7o0 ufUrNymBkSPs0miB6wrb4VHwp73IqtGSAVKn/xsd4+MyhOGiPs3sKClZtCCEw4rUusc5 ZMx9aRaadbiFZjjf9+UN+PYttNtowMLm5SqX2tu4AJVvOj+5eTppT6FC0zq2nLdaoo0n 3VULdIgiRCwFfmmG9h0KNQepnwDXUPFARR0jOap268M5/VeoIe29C2wAlcW1qcx3hQMr m8Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SqvdPxYpFRppAJIG4QZ49jAtA7pL76HuGEbUG+eqh88=; b=BFnUiAvtPI1y6Yx4EhQ9dcnuN9pv+ppR5+nCccz+PZx4iCqeSuI5PYnBg74AvhQpar xLINMD87BhNh0edX3QoyZqQRSnPcvEtH8jsQrfFjNfiMSM2n3/qiI03rPDebUMfZayOq eiA8mB3o3GcoDZ/zOf11HUHUPGxRevx58igJ/U2xWtNdQDP4YmhSWOSQu8WHQXbQ2W1a e6bcK9rGIfX8ebopzuueKj79f1aROJuaI/w+9CFKQWRY4AFEHyAGB7VnUZ9418GdyFPO RBPKnS4cv+gRhk3bTwMWEC8ODAN0DjfriVwLMZ9uKDt6djsYe9foy3RirT0lt/JdNr9o MKqw== X-Gm-Message-State: AKGB3mKpFkyMNkSJvVc+4PEVu5rjgtJdiiN2F8Hcszn3Qq8Ioto9Bkq/ viiKXuOWSF17ordva9fz+9inmS5sBLs= X-Google-Smtp-Source: ACJfBotpjD8KQMpUyEkqkSbe+va/ApJbcbgdYlVaGqUflzMLaohTTGmeuhQVm/6F2BmdSfTBLJ0GVw== X-Received: by 10.223.186.67 with SMTP id t3mr6785823wrg.276.1513291026855; Thu, 14 Dec 2017 14:37:06 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [70.74.179.152]) by smtp.gmail.com with ESMTPSA id f132sm2570817wmf.17.2017.12.14.14.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 14:37:06 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1ePc7k-0007uR-87; Thu, 14 Dec 2017 15:37:04 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH rdma-core 2/5] verbs: Remove container_of from the public verbs.h Date: Thu, 14 Dec 2017 15:35:40 -0700 Message-Id: <20171214223544.30117-3-jgg@ziepe.ca> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171214223544.30117-1-jgg@ziepe.ca> References: <20171214223544.30117-1-jgg@ziepe.ca> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe This is only used in one place in the header, go ahead and open code it. Not only does the definition pollute the global namespace, but our inferior implementation does not do the same type checking as the ccan version that we really want to be using, so this was causing bugs. Signed-off-by: Jason Gunthorpe --- libibverbs/verbs.h | 21 +++++++-------------- librdmacm/rsocket.c | 1 + 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/libibverbs/verbs.h b/libibverbs/verbs.h index 7fec7218182259..775bad52601781 100644 --- a/libibverbs/verbs.h +++ b/libibverbs/verbs.h @@ -67,18 +67,6 @@ union ibv_gid { } global; }; -#ifndef container_of -/** - * container_of - cast a member of a structure out to the containing structure - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) \ - ((type *) ((uint8_t *)(ptr) - offsetof(type, member))) -#endif - #define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz)) #ifdef __cplusplus @@ -1690,8 +1678,13 @@ struct verbs_context { static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx) { - return (ctx->abi_compat != __VERBS_ABI_IS_EXTENDED) ? - NULL : container_of(ctx, struct verbs_context, context); + if (ctx->abi_compat != __VERBS_ABI_IS_EXTENDED) + return NULL; + + /* open code container_of to not pollute the global namespace */ + return (struct verbs_context *)(((uint8_t *)ctx) - + offsetof(struct verbs_context, + context)); } #define verbs_get_ctx_op(ctx, op) ({ \ diff --git a/librdmacm/rsocket.c b/librdmacm/rsocket.c index 2ce716272d6a6b..48f30717e02d53 100644 --- a/librdmacm/rsocket.c +++ b/librdmacm/rsocket.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include