From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8F2024608F;
	Wed, 15 Jan 2025 10:05:22 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 2ECE14025F;
	Wed, 15 Jan 2025 10:05:22 +0100 (CET)
Received: from dkmailrelay1.smartsharesystems.com
 (smartserver.smartsharesystems.com [77.243.40.215])
 by mails.dpdk.org (Postfix) with ESMTP id 37C2F4003C
 for <dev@dpdk.org>; Wed, 15 Jan 2025 10:05:20 +0100 (CET)
Received: from smartserver.smartsharesystems.com
 (smartserver.smartsharesys.local [192.168.4.10])
 by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id E236820582;
 Wed, 15 Jan 2025 10:05:19 +0100 (CET)
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Subject: RE: [PATCH v12 1/3] lib/eal: add diagnostics macros to make code
 portable
X-MimeOLE: Produced By Microsoft Exchange V6.5
Date: Wed, 15 Jan 2025 10:05:18 +0100
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F9B2@smartserver.smartshare.dk>
In-Reply-To: <1736915238-779-2-git-send-email-andremue@linux.microsoft.com>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: [PATCH v12 1/3] lib/eal: add diagnostics macros to make code
 portable
Thread-Index: AdtnBcna9R0b85BKTomkvWMkb+UDTgAIY6mQ
References: <1735263196-2809-1-git-send-email-andremue@linux.microsoft.com>
 <1736915238-779-1-git-send-email-andremue@linux.microsoft.com>
 <1736915238-779-2-git-send-email-andremue@linux.microsoft.com>
From: =?iso-8859-1?Q?Morten_Br=F8rup?= <mb@smartsharesystems.com>
To: "Andre Muezerie" <andremue@linux.microsoft.com>
Cc: <dev@dpdk.org>, <stephen@networkplumber.org>, <bruce.richardson@intel.com>
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

> +/*
> + * Macro to ignore whenever a pointer is cast so as to remove a type
> + * qualifier from the target type.
> + */

This description could be better, something like the push/pop =
description:
"Macro to disable compiler warnings about ..."

> +#if !defined __INTEL_COMPILER && !defined RTE_TOOLCHAIN_MSVC

Prefer defined(NAME) over defined NAME.
Same for the description of push/pop below.
(I see both in rte_common.h, so perhaps it's just my personal =
preference.)

> +#define __rte_diagnostic_ignored_wcast_qual \
> +		_Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
> +#else
> +#define __rte_diagnostic_ignored_wcast_qual
> +#endif
> +
> +/*
> + * Macros to cause the compiler to remember the state of the =
diagnostics as of
> + * each push, and restore to that point at each pop.
> + */
> +#if !defined __INTEL_COMPILER && !defined RTE_TOOLCHAIN_MSVC
> +#define __rte_diagnostic_push _Pragma("GCC diagnostic push")
> +#define __rte_diagnostic_pop  _Pragma("GCC diagnostic pop")
> +#else
> +#define __rte_diagnostic_push
> +#define __rte_diagnostic_pop
> +#endif


> +#define RTE_IGNORE_CAST_QUAL(X) \
> +	((uintptr_t)(X))

A description of this macro is missing.
Rather than assign a name that refers to the name of compiler's warning, =
could you come up with a name that describes what the macro does to X, =
i.e. discards qualifiers.
And if the macro is exclusively for pointers, perhaps it should have PTR =
somewhere in its name.

And do we really need this macro? Can't RTE_CAST_FIELD() be used =
instead?

Or can we make the macro more like RTE_CAST_FIELD()?
Perhaps RTE_CAST(var, type)?

Or maybe, inspired by RTE_PTR_ADD():
#define RTE_PTR(var) ((void*)((uintptr_t)(ptr)))
#define RTE_CONST_PTR(var) ((const void*)((uintptr_t)(ptr)))