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 25ED0A04C7; Mon, 14 Sep 2020 17:36:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CD3901BE95; Mon, 14 Sep 2020 17:36:04 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 7262A2BAB for ; Mon, 14 Sep 2020 17:36:03 +0200 (CEST) IronPort-SDR: 7bKax1uxkk6YTbo1Y0ynu9eq1jjRp/bpI8HKf4BCXnqhEbkL589zjOm8aX/bUobbIDSYRASYep kWgWg5ITuNoQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="138603126" X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="138603126" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 08:36:00 -0700 IronPort-SDR: fXgYtQr8IRKKHGaBNaixxzpJ3GG9HxtWTl9zkUW/IyL1wgaHa99Q1cKdeq/Q3nyAk0L3aeI7+f D9lIi04nmqwA== X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="482385057" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.251.82.108]) ([10.251.82.108]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 08:35:59 -0700 To: Stephen Hemminger Cc: dev@dpdk.org References: <20200904221143.19744-1-stephen@networkplumber.org> From: "Burakov, Anatoly" Message-ID: <6a912a3a-81c2-7740-5f89-815d2e5fba5d@intel.com> Date: Mon, 14 Sep 2020 16:35:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200904221143.19744-1-stephen@networkplumber.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] 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" On 04-Sep-20 11:11 PM, Stephen Hemminger wrote: > 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 > --- This is a very cool feature! LGTM Acked-by: Anatoly Burakov > void * > -rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket); > +rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket) > + __rte_alloc_size(2); > > /** > * Replacement function for calloc(), using huge-page memory. Memory area is > @@ -239,9 +243,9 @@ rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket); > * align is not a power of two). > * - Otherwise, the pointer to the allocated object. > */ > -__rte_malloc > void * Where did this come from? > -rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, int socket); > +rte_calloc_socket(const char *type, size_t num, size_t size, unsigned align, int socket) > + __rte_alloc_size(2, 3); > > /** > * Frees the memory space pointed to by the provided pointer. > -- Thanks, Anatoly