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 B56CE4548D; Tue, 18 Jun 2024 13:43:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 349FC4275C; Tue, 18 Jun 2024 13:42:20 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by mails.dpdk.org (Postfix) with ESMTP id C137A40ECF for ; Tue, 18 Jun 2024 13:42:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718710935; x=1750246935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aWsgZ4lqPu5oMlRqHAYj+E1UG8bHfsPjyyn4tnMrjv4=; b=QHLuWrx2SjnlXdRaOrQvwBBPkhGoI280voXf+sZze+ViN1LwVB4QlqvF 73KDiflso2tbji0AXXrmct4OlRisEnf5YOUJVG1EVQGi9IOBJlIVPhM1j /1berfCF9suR6lc45h0s42/k+836dSlXlycPDRRtENZeR9AckKZNpN407 4Uglh1UaClHVDZMGzGLKziGVbNdZFR6HnKkKBnfcHDTMa7qF99nfsBQs4 cd7ZhEGKPgu3PTFum2fmO4daQRdEGLb5rwZkDdIPL2hB4WmjCu/xceDC3 yiLuFmCH2dvS4pTsDUyls7gVE3ZDFNxZfVRShIQ6pFQIAIDLk+s3cONPn A==; X-CSE-ConnectionGUID: Pu9EEU01QXWEjptcsywO4g== X-CSE-MsgGUID: H0bv9E3hQ5Orbui+c81Oyw== X-IronPort-AV: E=McAfee;i="6700,10204,11106"; a="19443313" X-IronPort-AV: E=Sophos;i="6.08,247,1712646000"; d="scan'208";a="19443313" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2024 04:42:15 -0700 X-CSE-ConnectionGUID: Xdl/2CZmT5KilPGB2dtT5g== X-CSE-MsgGUID: LjerjsxkSEa6SRI5ODTVVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,247,1712646000"; d="scan'208";a="41621122" Received: from unknown (HELO npf-hyd-clx-03..) ([10.145.170.182]) by fmviesa009.fm.intel.com with ESMTP; 18 Jun 2024 04:42:13 -0700 From: Soumyadeep Hore To: bruce.richardson@intel.com, anatoly.burakov@intel.com Cc: dev@dpdk.org Subject: [PATCH v4 08/21] common/idpf: refactor size check macro Date: Tue, 18 Jun 2024 10:57:09 +0000 Message-ID: <20240618105722.2326987-9-soumyadeep.hore@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240618105722.2326987-1-soumyadeep.hore@intel.com> References: <20240612035257.2245824-11-soumyadeep.hore@intel.com> <20240618105722.2326987-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