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 5EEEF454DF; Mon, 24 Jun 2024 12:03:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3703A40E17; Mon, 24 Jun 2024 12:02:51 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) by mails.dpdk.org (Postfix) with ESMTP id 1FF404026E for ; Mon, 24 Jun 2024 12:02:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719223341; x=1750759341; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aWsgZ4lqPu5oMlRqHAYj+E1UG8bHfsPjyyn4tnMrjv4=; b=n0OIX5MRSBga7uuB7n7L7beqoobZpQ1sSntqMhRwX+/s3kPGAvh31ZGH a+7eXjlamRGkQPBCQukHQmsAPC6cFi7CwnM9YPpqKj+Kwdv6EtX3kknYc fC5YvHfyJK0FtG2tAYQ+iKA/UkQYtBy/m9juSkXaKtGaYBXJyXC/w7mh6 Bh2YJVDE+45MkYBZeCpLQOamkv+Q3rT8u/NlyHQ87EA0BNH5qCtf+95Yf m+c9LnLzrOsO9Ef2yKEBKeJXdhSNs8n0kMlt7+lxGsNc4db6kehX9/5ni CIeI7F81qpJAcsDn21ZoyAxukmUUpqrxw8/R+EwsFI1txf8is62VOqKSa w==; X-CSE-ConnectionGUID: VShOIg56Qi+96UToNqLQcw== X-CSE-MsgGUID: SF+GbZXwTHSK2ir4YnqlWQ== X-IronPort-AV: E=McAfee;i="6700,10204,11112"; a="19086429" X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="19086429" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2024 03:02:20 -0700 X-CSE-ConnectionGUID: L39QBioHQaSZB4FMy3E7fw== X-CSE-MsgGUID: s4GISZloR4KFg/NXAaECWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,261,1712646000"; d="scan'208";a="74479076" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa001.fm.intel.com with ESMTP; 24 Jun 2024 03:02:19 -0700 From: Soumyadeep Hore To: bruce.richardson@intel.com, anatoly.burakov@intel.com Cc: dev@dpdk.org Subject: [PATCH v5 08/21] common/idpf: refactor size check macro Date: Mon, 24 Jun 2024 09:16:31 +0000 Message-ID: <20240624091644.2404658-9-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240624091644.2404658-1-soumyadeep.hore@intel.com> References: <20240618105722.2326987-22-soumyadeep.hore@intel.com> <20240624091644.2404658-1-soumyadeep.hore@intel.com> 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 Instead of using 'divide by 0' to check the struct length, use the static_assert macro Removed redundant CHECK_UNION_LEN macro. Signed-off-by: Soumyadeep Hore --- drivers/common/idpf/base/virtchnl2.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/common/idpf/base/virtchnl2.h b/drivers/common/idpf/base/virtchnl2.h index 1f59730297..f8b97f2e06 100644 --- a/drivers/common/idpf/base/virtchnl2.h +++ b/drivers/common/idpf/base/virtchnl2.h @@ -41,15 +41,12 @@ /* State Machine error - Command sequence problem */ #define VIRTCHNL2_STATUS_ERR_ESM 201 -/* These macros are used to generate compilation errors if a structure/union - * is not exactly the correct length. It gives a divide by zero error if the - * structure/union is not of the correct size, otherwise it creates an enum - * that is never used. +/* This macro is used to generate compilation errors if a structure + * is not exactly the correct length. */ -#define VIRTCHNL2_CHECK_STRUCT_LEN(n, X) enum virtchnl2_static_assert_enum_##X \ - { virtchnl2_static_assert_##X = (n)/((sizeof(struct X) == (n)) ? 1 : 0) } -#define VIRTCHNL2_CHECK_UNION_LEN(n, X) enum virtchnl2_static_asset_enum_##X \ - { virtchnl2_static_assert_##X = (n)/((sizeof(union X) == (n)) ? 1 : 0) } +#define VIRTCHNL2_CHECK_STRUCT_LEN(n, X) \ + static_assert((n) == sizeof(struct X), \ + "Structure length does not match with the expected value") /* New major set of opcodes introduced and so leaving room for * old misc opcodes to be added in future. Also these opcodes may only -- 2.43.0