grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 02/17] misc: Add parentheses around ALIGN_UP and ALIGN_DOW


From: Patrick Steinhardt
Subject: Re: [PATCH v7 02/17] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN arguments
Date: Sun, 6 Dec 2020 14:24:43 +0100

On Fri, Dec 04, 2020 at 10:43:31AM -0600, Glenn Washburn wrote:
> This ensures that expected order of operations is preserved when arguments
> are expressions.
> 
> Signed-off-by: Glenn Washburn <development@efficientek.com>

Reviewed-by: Patrick Steinhardt <ps@pks.im>

> ---
>  include/grub/misc.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/grub/misc.h b/include/grub/misc.h
> index b7ca6dd58..780a34e90 100644
> --- a/include/grub/misc.h
> +++ b/include/grub/misc.h
> @@ -28,10 +28,10 @@
>  #include <grub/compiler.h>
>  
>  #define ALIGN_UP(addr, align) \
> -     ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
> +     (((addr) + (typeof (addr)) (align) - 1) & ~((typeof (addr)) (align) - 
> 1))
>  #define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) 
> - 1))
>  #define ALIGN_DOWN(addr, align) \
> -     ((addr) & ~((typeof (addr)) align - 1))
> +     ((addr) & ~((typeof (addr)) (align) - 1))
>  #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
>  #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
>  
> -- 
> 2.27.0
> 

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]