From: Theodore Ts'o Date: Mon, 26 May 2025 01:37:38 +0000 (-0400) Subject: libext2fs: fix Coverity type warnings from ext2fs_inode_xtime_set() X-Git-Tag: v1.47.3-rc1~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86f11317429bd424ef61dc287566c0e3c4a4298c;p=thirdparty%2Fe2fsprogs.git libext2fs: fix Coverity type warnings from ext2fs_inode_xtime_set() The ext2fs_inode_xtime_set() C preprocessor macro needs to cast to __u32 before assigning to the time field. This fixes a number of integer handling issues reported by Coverity. Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 301312e4..bb2170b7 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -619,11 +619,11 @@ static inline __u32 __decode_extra_nsec(__u32 extra) do { \ if (ext2fs_inode_includes(ext2fs_inode_actual_size(inode), \ field ## _extra)) { \ - (inode)->field = (__s32)(sec & 0xfffffff); \ + (inode)->field = (__u32)(sec & 0xfffffff); \ ((struct ext2_inode_large *)(inode))->field ## _extra = \ __encode_extra_time(sec, 0); \ } else { \ - (inode)->field = clamp(sec, INT32_MIN, INT32_MAX); \ + (inode)->field = (__u32) clamp(sec, INT32_MIN, INT32_MAX); \ } \ } while (0) #define ext2fs_inode_xtime_get(inode, field) \