fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem
PATCH v2 1/1 fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem
Fix CRAMFS_BLK_FLAG_UNCOMPRESSED to use "U" cast to avoid shifting signed 32-bit value by 31 bits problem. This isn't a problem for kernel builds with gcc.
This could be problem since this header is part of public API which could be included for builds using compilers that don't handle this condition safely resulting in undefined behavior.
---
V2 - use the unsigned constants for all flags, not just one
include/uapi/linux/cramfs_fs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/cramfs_fs.h +2 -2
@@ -98,8 +98,8 @@ struct cramfs_super {* * That leaves room for 3 flag bits in the block pointer table. */ -#define CRAMFS_BLK_FLAG_UNCOMPRESSED (1 << 31) -#define CRAMFS_BLK_FLAG_DIRECT_PTR (1 << 30) +#define CRAMFS_BLK_FLAG_UNCOMPRESSED (1U << 31) +#define CRAMFS_BLK_FLAG_DIRECT_PTR (1U << 30)#define CRAMFS_BLK_FLAGS ( CRAMFS_BLK_FLAG_UNCOMPRESSED \ | CRAMFS_BLK_FLAG_DIRECT_PTR )
Signature · 1 line
2.21.0
Looks good,
Quoted 9 lines · Puranjay Mohan
Fix
CRAMFS_BLK_FLAG_UNCOMPRESSEDto use "U" cast to avoid shifting signed 32-bit value by 31 bits problem. This isn't a problem for kernel builds with gcc.This could be problem since this header is part of public API which could be included for builds using compilers that don't handle this condition safely resulting in undefined behavior.
Signed-off-by Puranjay Mohan <puranjay12 at gmail.com>
You should resend this and cc: Nicolas Pitre <nico at fluxnic.net> as he is the cramfs maintainer.
thanks,
greg k-h
Shuah Khan
Reviewed-byQuoted 9 lines · Greg KH
Quoted 8 lines · Puranjay Mohan
Fix
CRAMFS_BLK_FLAG_UNCOMPRESSEDto use "U" cast to avoid shifting signed 32-bit value by 31 bits problem. This isn't a problem for kernel builds with gcc.This could be problem since this header is part of public API which could be included for builds using compilers that don't handle this condition safely resulting in undefined behavior.
Quoted 7 lines
Quoted 1 line
Signed-off-by Puranjay Mohan <puranjay12 at gmail.com>Reviewed-by Greg Kroah-Hartman <gregkh at linuxfoundation.org>You should resend this and cc: Nicolas Pitre <nico at fluxnic.net> as he is the cramfs maintainer.
Puranjay! You can add all the Reviewed-by tags when you resend the patch with Nicolas Pitre <nico at fluxnic.net> on the thread.
thanks,
-- Shuah
Quoted 18 lines · Shuah Khan
Quoted 9 lines · Greg KH
Quoted 8 lines · Puranjay Mohan
Fix
CRAMFS_BLK_FLAG_UNCOMPRESSEDto use "U" cast to avoid shifting signed 32-bit value by 31 bits problem. This isn't a problem for kernel builds with gcc.This could be problem since this header is part of public API which could be included for builds using compilers that don't handle this condition safely resulting in undefined behavior.
Quoted 7 lines
Quoted 1 line
Signed-off-by Puranjay Mohan <puranjay12 at gmail.com>Reviewed-by Greg Kroah-Hartman <gregkh at linuxfoundation.org>You should resend this and cc: Nicolas Pitre <nico at fluxnic.net> as he is the cramfs maintainer.
Quoted 8 lines
Puranjay! You can add all the Reviewed-by tags when you resend the patch with Nicolas Pitre <nico at fluxnic.net> on the thread.
Reviewed-by Shuah Khan <skhan at linuxfoundation.org>thanks,
-- Shuah
Thanks, I have sent the mail with Nicolas Pitre in CC.
--Puranjay