]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
misc: ubsan fixes
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 2 Feb 2018 15:32:43 +0000 (09:32 -0600)
committerEric Sandeen <sandeen@redhat.com>
Fri, 2 Feb 2018 15:32:43 +0000 (09:32 -0600)
Fix a few things the undefined behavior sanitizer complained about.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/bit.c
repair/sb.c

index a20b6ba5f5a9b77d0afd3f642c25cbaa6c00627a..bf8d80efb10618fd716d47203bcf376db0180990 100644 (file)
--- a/db/bit.c
+++ b/db/bit.c
@@ -112,11 +112,11 @@ getbitval(
 #if __BYTE_ORDER == LITTLE_ENDIAN
                        if (i == 0 && signext && nbits < 64)
                                rval = -1LL << nbits;
-                       rval |= 1LL << (nbits - i - 1);
+                       rval |= 1ULL << (nbits - i - 1);
 #else
                        if ((i == (nbits - 1)) && signext && nbits < 64)
                                rval |= (-1LL << nbits);
-                       rval |= 1LL << (nbits - i - 1);
+                       rval |= 1ULL << (nbits - i - 1);
 #endif
                }
        }
index f40cdeab2d1d3e8dc7e4d88d6355b72c3db502e9..3dc6538bb4ffc64578e29076364ac0ab10bf9739 100644 (file)
@@ -89,11 +89,11 @@ verify_sb_blocksize(xfs_sb_t *sb)
        /* check to make sure blocksize is legal 2^N, 9 <= N <= 16 */
        if (sb->sb_blocksize == 0)
                return XR_BAD_BLOCKSIZE;
-       if (sb->sb_blocksize != (1 << sb->sb_blocklog))
-               return XR_BAD_BLOCKLOG;
        if (sb->sb_blocklog < XFS_MIN_BLOCKSIZE_LOG ||
            sb->sb_blocklog > XFS_MAX_BLOCKSIZE_LOG)
                return XR_BAD_BLOCKLOG;
+       if (sb->sb_blocksize != (1 << sb->sb_blocklog))
+               return XR_BAD_BLOCKLOG;
 
        return 0;
 }