[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] misc: Make grub_min() and grub_max() more resilient.
From: |
Robbie Harwood |
Subject: |
Re: [PATCH] misc: Make grub_min() and grub_max() more resilient. |
Date: |
Thu, 24 Mar 2022 18:43:16 -0400 |
Peter Jones <pjones@redhat.com> writes:
> grub_min(a,b) and grub_max(a,b) use a relatively naive implementation
> which leads to several problems:
> - they evaluate their parameters more than once
> - the naive way to address this, to declare temporary variables in a
> statement-expression, isn't resilient against nested uses, because
> MIN(a,MIN(b,c)) results in the temporary variables being declared in
> two nested scopes, which may result in a build warning depending on
> your build options.
>
> This patch changes our implementation to use a statement-expression
> inside a helper macro, and creates the symbols for the temporary
> variables with __COUNTER__ (A GNU C cpp extension) and token pasting to
> create uniquely named internal variables.
>
> Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
Be well,
--Robbie
signature.asc
Description: PGP signature