From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: [PATCH v1 1/4] net/mlx4: move rdma-core calls to separate file Date: Thu, 25 Jan 2018 12:31:41 +0100 Message-ID: <20180125113141.GO4256@6wind.com> References: <20180124223625.1928-1-adrien.mazarguil@6wind.com> <20180124223625.1928-2-adrien.mazarguil@6wind.com> <20180124155857.52457b9d@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Shahaf Shuler , Nelio Laranjeiro , dev@dpdk.org, Marcelo Ricardo Leitner To: Stephen Hemminger Return-path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 1A7E12BB5 for ; Thu, 25 Jan 2018 12:31:55 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id r78so14330239wme.0 for ; Thu, 25 Jan 2018 03:31:55 -0800 (PST) Content-Disposition: inline In-Reply-To: <20180124155857.52457b9d@xeon-e3> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Jan 24, 2018 at 03:58:57PM -0800, Stephen Hemminger wrote: > On Thu, 25 Jan 2018 00:25:00 +0100 > Adrien Mazarguil wrote: > > > +const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){ > > + .fork_init = mlx4_glue_fork_init, > > + .get_async_event = mlx4_glue_get_async_event, > > The cast should not be necessary here. It's not a mere cast but a compound literal. The mlx4_glue symbol represents a pointer to this structure, not the structure itself. This syntax is equivalent to: static const struct mlx4_glue mlx4_glue_internal = { ... }; const struct mlx4_glue *mlx4_glue = &mlx4_glue_internal; The reason I chose to expose a pointer instead of that structure directly is seamless transition to dlsym() in the next patch, otherwise all mlx4_glue->foo() need to be first written mlx4_glue.foo() and then modified as mlx4_glue->foo(). -- Adrien Mazarguil 6WIND