[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v14 NEW ALT 1/3] safemath: Add ALIGN_UP_OVF() that checks for
From: |
Daniel Kiper |
Subject: |
Re: [PATCH v14 NEW ALT 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over,under}flow |
Date: |
Mon, 20 May 2024 18:53:34 +0200 |
On Sun, May 19, 2024 at 11:48:24AM +0800, Gao Xiang wrote:
> The following EROFS patch will use this helper to handle overflow
> ALIGN_UP() cases.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
I think Vladimir is right.
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Please post v15 an I will merge it this week.
Thank you for adding EROFS support!
Daniel
> ---
> Hi Daniel,
>
> I've also made another patch to conform Vladimir's and
> Boyang's comments as much as I can.
>
> Thanks,
> Gao Xiang
>
> include/grub/safemath.h | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/include/grub/safemath.h b/include/grub/safemath.h
> index fbd9b5925..bb8a5b39c 100644
> --- a/include/grub/safemath.h
> +++ b/include/grub/safemath.h
> @@ -32,6 +32,22 @@
>
> #define grub_cast(a, res) grub_add ((a), 0, (res))
>
> +/*
> + * It's caller's responsibility that `align` should not equal to 0 and
> + * it must be a power of 2.
> + */
> +#define ALIGN_UP_OVF(v, align, res) \
> +({ \
> + bool __failed; \
> + typeof(v) __a = ((typeof(v))(align) - 1); \
> + \
> + __failed = grub_add (v, __a, res); \
> + if (__failed == false) \
> + { \
> + *(res) &= ~__a; \
> + } \
> +__failed;})
> +
> #else
> #error gcc 5.1 or newer or clang 8.0 or newer is required
> #endif
- [PATCH v14 0/3] Introduce EROFS support, Gao Xiang, 2024/05/17
- [PATCH v14 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over, under}flow, Gao Xiang, 2024/05/17
- Re: [PATCH v14 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over, under}flow, Vladimir 'phcoder' Serbinenko, 2024/05/17
- Re: [PATCH v14 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over,under}flow, Gao Xiang, 2024/05/17
- Re: [PATCH v14 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over, under}flow, Vladimir 'phcoder' Serbinenko, 2024/05/18
- Re: [PATCH v14 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over,under}flow, Gao Xiang, 2024/05/18
- Re: [PATCH v14 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over,under}flow, Gao Xiang, 2024/05/18
- [PATCH v14 NEW ALT 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over, under}flow, Gao Xiang, 2024/05/18
- Re: [PATCH v14 NEW ALT 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over,under}flow,
Daniel Kiper <=
- Re: [PATCH v14 NEW ALT 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over,under}flow, Gao Xiang, 2024/05/20
Re: [PATCH v14 1/3] safemath: Add ALIGN_UP_OVF() that checks for {over, under}flow, Zhang Boyang, 2024/05/18
[PATCH v14 3/3] fs/erofs: Add tests for EROFS in grub-fs-tester, Gao Xiang, 2024/05/17
[PATCH v14 2/3] fs/erofs: Add support for EROFS, Gao Xiang, 2024/05/17
Re: [PATCH v14 0/3] Introduce EROFS support, Yifan Zhao, 2024/05/17