[PATCH 3/2] misc: ubsan fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

Fix a few things the undefined behavior sanitizer complained about.

Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
---
 db/bit.c    |    4 ++--
 repair/sb.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/db/bit.c b/db/bit.c
index a20b6ba..bf8d80e 100644
--- 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
 		}
 	}
diff --git a/repair/sb.c b/repair/sb.c
index f40cdea..3dc6538 100644
--- a/repair/sb.c
+++ b/repair/sb.c
@@ -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;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux