[PATCH] linux: Fix integer overflow warnings when including <sys/mount.h> [BZ #32708]
Carlos O'Donell
carlos@redhat.com
Tue Mar 25 16:56:39 GMT 2025
On 2/17/25 12:56 AM, Collin Funk wrote:
> Using gcc -Wshift-overflow=2 -Wsystem-headers to compile a file
> including <sys/mount.h> will cause a warning since 1 << 31 is undefined
> behavior on platforms where int is 32-bits.
>
> Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Tested on i686 and x86_64 with no regressions and this matches a similar termios.h
change we made.
LGTM. I'll push this shortly when my other regression testers complete.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> ---
> sysdeps/unix/sysv/linux/sys/mount.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
> index 7c6d0805d7..b549e75148 100644
> --- a/sysdeps/unix/sysv/linux/sys/mount.h
> +++ b/sysdeps/unix/sysv/linux/sys/mount.h
> @@ -121,7 +121,7 @@ enum
> MS_ACTIVE = 1 << 30,
> #define MS_ACTIVE MS_ACTIVE
> #undef MS_NOUSER
> - MS_NOUSER = 1 << 31
> + MS_NOUSER = 1U << 31
> #define MS_NOUSER MS_NOUSER
> };
>
--
Cheers,
Carlos.
More information about the Libc-alpha
mailing list