Skip to contentSkip to conversation

fs: cramfs_fs.h: Fix shifting signed 32-bit value by 31 bits problem

PATCH RESEND Superseded Puranjay Mohan 2 participants 2 messages Jun 18, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 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.

Signed-off-by Puranjay Mohan <puranjay12 at gmail.com>

---
RESEND - Added required mailing list in CC

 include/uapi/linux/cramfs_fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/cramfs_fs.h +1 -1
index 6713669aa2ed..31df3e185b62 100644
@@ -98,7 +98,7 @@ 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_UNCOMPRESSED	(1U << 31)
 #define CRAMFS_BLK_FLAG_DIRECT_PTR	(1 << 30)
 
 #define CRAMFS_BLK_FLAGS	( CRAMFS_BLK_FLAG_UNCOMPRESSED \
Signature · 1 line
2.21.0
#1 lore raw

include/uapi/linux/cramfs_fs.h struct cramfs_super { · line 102

Quoted 3 lines
include/uapi/linux/cramfs_fs.h +1 -1
-#define CRAMFS_BLK_FLAG_UNCOMPRESSED	(1 << 31)
+#define CRAMFS_BLK_FLAG_UNCOMPRESSED	(1U << 31)
 #define CRAMFS_BLK_FLAG_DIRECT_PTR	(1 << 30)

Please use the unsigned constants for all flags, not just one.