From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63FFFA04A5; Wed, 9 Feb 2022 14:17:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFD5B41143; Wed, 9 Feb 2022 14:17:48 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id BFFD940140 for ; Wed, 9 Feb 2022 14:17:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644412667; x=1675948667; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=vlQR8wanqcJRW4flBypPsHN7dZCTwvhuXoLu1CSa0Qg=; b=aGd+ih7kPcf0Nkgo2rvfKZsW1jToKl3FchgUKA2XQlEsPe5lxWzhb10i brzik3f/rnQnurC4qjP3v3d0W+ZifffwI6Gxvss1zayZXZYzAXC6bUHkY cjtRQbkk+CNxZcPpbMI66NMpTpTdPfkSjwE/MBSdBLyMnLjIZafnwAiq6 c/KH7Y9AjVoJjkYW6SuiSH9NAfWoiCjCpHugWLE/9+NJ1CB4zCTUPHHHH Yy+Yvl/OTWxNbhxOCzc/pX5cS2hh5hz9fKRQR1patX+m7HgNajEVV4hzU LxMMaJIRCfuEwE8MHnF0QJBgEVFXsC8/bYGtgz9uaDARNqUffNv95QO9z Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10252"; a="249149444" X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="249149444" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 05:17:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="622272303" Received: from npg-dpdk-haiyue-2.sh.intel.com ([10.67.118.240]) by FMSMGA003.fm.intel.com with ESMTP; 09 Feb 2022 05:17:45 -0800 From: Haiyue Wang To: dev@dpdk.org Cc: Haiyue Wang , Ciara Loftus , Qi Zhang Subject: [PATCH v1] net/af_xdp: make umem configure code more readable Date: Wed, 9 Feb 2022 20:43:58 +0800 Message-Id: <20220209124358.137807-1-haiyue.wang@intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The below compile time defined style make the code not so readable, the first function end block is after "#endif" segment. #if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG) xdp_umem_configure() { #else xdp_umem_configure() { #endif 'shared code block' } Signed-off-by: Haiyue Wang --- drivers/net/af_xdp/rte_eth_af_xdp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c index 1b6192fa44..802f912cb7 100644 --- a/drivers/net/af_xdp/rte_eth_af_xdp.c +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c @@ -1078,6 +1078,12 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals, __atomic_store_n(&umem->refcnt, 1, __ATOMIC_RELEASE); } + return umem; + +err: + xdp_umem_destroy(umem); + return NULL; +} #else static struct xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals, @@ -1138,13 +1144,13 @@ xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals, } umem->mz = mz; -#endif return umem; err: xdp_umem_destroy(umem); return NULL; } +#endif static int load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map) -- 2.35.1