From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D819C432C0 for ; Fri, 22 Nov 2019 06:55:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B5B12070A for ; Fri, 22 Nov 2019 06:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574405714; bh=7EGdTKMiF04g+c8c5BLKCt/DvPw+KQa1TP6i3r82QhM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=J3sJBwVMiSbT5SWTY8/o0KsqNNfIB9ARNQCeTnTMu1MBQbUxi6aFnLumyJPaCkps0 4Cz8pAVrLSKncw16N1MZYUf0OmcxO1UQnLJS4TkYtH4Qm53xviscJ+zhu2NDb8ONhK 9WD1m8jdJI+zhec4Az2gaxqZ699T/cg3zLT3we3g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbfKVGzN (ORCPT ); Fri, 22 Nov 2019 01:55:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:45732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbfKVGzN (ORCPT ); Fri, 22 Nov 2019 01:55:13 -0500 Received: from localhost (unknown [5.29.147.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 567882068E; Fri, 22 Nov 2019 06:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574405713; bh=7EGdTKMiF04g+c8c5BLKCt/DvPw+KQa1TP6i3r82QhM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=t/HHqH1lnO4LFAO1wAfNDCfaQZCwkI9fyUZ/j9c+2RZiVoIVltredJ0HXeHnwQ+F1 WZR8arruhcfUZTf9PhqSsVizbSHsXaaxN9a73OvOulCjT2q7pE0sDo6t+OTXUxvlZq k9FjIo8iYNjH8ZOykAjtKzw8H9E2tchjAJnau+GA= Date: Fri, 22 Nov 2019 08:55:09 +0200 From: Leon Romanovsky To: Jason Gunthorpe Cc: Doug Ledford , RDMA mailing list , Bart Van Assche , Sean Hefty Subject: Re: [PATCH rdma-next v1 04/48] RDMA/cm: Add SET/GET implementations to hide IBA wire format Message-ID: <20191122065509.GC136476@unreal> References: <20191121181313.129430-1-leon@kernel.org> <20191121181313.129430-5-leon@kernel.org> <20191121203836.GK7481@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191121203836.GK7481@mellanox.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Thu, Nov 21, 2019 at 08:38:40PM +0000, Jason Gunthorpe wrote: > On Thu, Nov 21, 2019 at 08:12:29PM +0200, Leon Romanovsky wrote: > > +#define _IBA_GET_MEM(field_struct, field_offset, byte_size, ptr, out, bytes) \ > > + ({ \ > > + WARN_ON(bytes > byte_size); \ > > + if (out && bytes) { \ > > Why check for null? Caller should handle > > > + const field_struct *_ptr = ptr; \ > > + memcpy(out, (void *)_ptr + (field_offset), bytes); \ > > + } \ > > + }) > > +#define IBA_GET_MEM(field, ptr, out, bytes) _IBA_GET_MEM(field, ptr, out, bytes) > > This should really have some type safety, ie check that out is > something like 'struct ibv_guid *'a This GET_MEM is not used yet, because I didn't find a way to model properly access to private_data, ari, info and GIDs at the same time. We can drop this chunk if it bothers you. Thanks > > Jason