On 12.03.2024 12:48, Federico Serafini wrote:
> Place an "#if 0" before grep fodder definitions and remove the
> "#undef".
>
> This addresses several violations of MISRA C:2012 Rule 5.5
> ("Identifiers shall be distinct from macro names").
>
> No functional change.
>
> Signed-off-by: Federico Serafini <[email protected]>
> ---
> Hello, I would like to know what you think about this change.
> If you want to keep grep fodders as they are, an alternative could be to
> deviate violations of Rule 5.5 involving the TYPE_SAFE macro.
I think the original intention was to allow for some (arch?) override.
But we have lived without for long enough that I think we could do as
you suggest. One question though: Wasn't there also a rule against the
use of #undef, violations of which would then be eliminate here as well?
If so, I think that would want mentioning in the description. If not,
I'd like to give it a couple of days before ack-ing, just in case other
opinions would be voiced.
> --- a/xen/include/xen/iommu.h
> +++ b/xen/include/xen/iommu.h
> @@ -33,13 +33,10 @@ TYPE_SAFE(uint64_t, dfn);
> #define PRI_dfn PRIx64
> #define INVALID_DFN _dfn(~0ULL)
>
> -#ifndef dfn_t
> +#if 0
> #define dfn_t /* Grep fodder: dfn_t, _dfn() and dfn_x() are defined above */
> #define _dfn
> #define dfn_x
> -#undef dfn_t
> -#undef _dfn
> -#undef dfn_x
> #endif
I have to admit that I'm a little surprised that Misra (Eclair) is
happy with this: The #define-s are all still there, after all.
Jan