From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07DB9A04DC; Mon, 19 Oct 2020 16:22:37 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F148EE241; Mon, 19 Oct 2020 16:22:34 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 90503E240 for ; Mon, 19 Oct 2020 16:22:33 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 314FF5C01C4; Mon, 19 Oct 2020 10:22:32 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 19 Oct 2020 10:22:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= Oc5bOtnh1A4DxHgZCvPFDjerIsewW3RVNjR3DY7Kphc=; b=I7bArx+gBrgw1fu4 FJgeUzvTrZYaUXHiXK+DHhNuCkg3262EWSOKjC3t5GJWqy8BRjRnu38O2PLXFyUh dhk3U3y2gEiFV5SOitMZlQ4CcZNqmWddDkVvXV48kXRl6Up/FpQtErgjaf/piDSQ 0FiXf09tDLq9yuEYxGGLUGaGErRoyn8hDJq64ZMXmI3yFSyxrEaNYJNmHtVten4X aq/LOSyJAcMyocOWw2GLn0es0ouluVtyNC/y7YHY5pXUEJZEDqy17NgHC21EAfbt 9w4RKe4G6T/HE9zRR/lgZe7BGpXUmS//rTx4eoxhCDbj+NXVhNMeN7I17jLp0Rm7 mTJARQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=Oc5bOtnh1A4DxHgZCvPFDjerIsewW3RVNjR3DY7Kp hc=; b=qlAZGrbR42Y0e8l2UQb7kqkco9bhvilURxMqGItQQpbMPxK2NugVYNX9s CsFb8QK0Wv0AT0uNZLpO7y0wdN1FqeC1Ra24t9NOmO82+UpObQoKEPCw/qV0ttTC 9pq6mUq8Bvzea2YqT0fs8x/SsyOwNI8NUwWeyCCh5bjujjX9I/++xr6hKzKB3PLy zQmukUukCh7clpW9Q7hGvTZf9acofWF9yptyojTjjDiu5JBJwuItidCRrHsHHFOU WrBVwAwHIbJrR56gqhHUW7zWytfGFTTMFA3tL4PWu8INxu24eTfT4mHlUKjE0AEG Y4od4M9CC/5GEJHnNy5y6sIJl3sfg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrjedugdejjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdejueei iedvffegheenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id DE214328006F; Mon, 19 Oct 2020 10:22:30 -0400 (EDT) From: Thomas Monjalon To: Stephen Hemminger Cc: dev@dpdk.org, anatoly.burakov@intel.com, david.marchand@redhat.com Date: Mon, 19 Oct 2020 16:22:29 +0200 Message-ID: <2268678.gA76BeBgmz@thomas> In-Reply-To: <11702768.X94JZly3y1@thomas> References: <20201015005524.24659-1-stephen@networkplumber.org> <11702768.X94JZly3y1@thomas> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v2] eal/rte_malloc: add alloc_size() attribute to allocation functions 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 19/10/2020 16:13, Thomas Monjalon: > 15/10/2020 02:55, Stephen Hemminger: > > By using the alloc_size() attribute the compiler can optimize > > better and detect errors at compile time. > > > > For example, Gcc will fail one of the invalid allocation examples > > in app/test/test_malloc.c because the allocation is outside the > > limits of memory. > > > > Signed-off-by: Stephen Hemminger > > --- > > v2 - rebase onto correct branch (main) > [...] > > +/** > > + * Tells compiler that the function returns a value that points to > > + * memory, where the size is given by the one or two arguments. > > + * Used by compiler to validate object size. > > + */ > > +#if defined(RTE_CC_GCC) || defined(RTE_CC_CLANG) > > +#define __rte_alloc_size(...) \ > > + __attribute__((alloc_size(__VA_ARGS__))) > > +#else > > +#define __rte_alloc_size(...) > > +#endif > > Not sure about the rebase: RTE_CC_GCC and RTE_CC_CLANG don't exist. Actually no, I forgot my 7-month old patch introducing them. Applied, thanks