[PATCH] udf: uint32_t can't be less than zero

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

 



Here's a patch that removes a few bits from fs/udf/balloc.c that 
test uint32_t values for being less than zero, which is impossible.

I know not everyone agree with this sort of cleanup, but I figured I'd do 
the patch in any case, then leave it up to the maintainer to apply it or 
drop it.

Please keep me on CC: when replying.



Signed-Off-by: Jesper Juhl <[email protected]>


--- linux-2.6.12-rc2-mm3-orig/fs/udf/balloc.c	2005-03-02 08:37:52.000000000 +0100
+++ linux-2.6.12-rc2-mm3/fs/udf/balloc.c	2005-04-23 20:38:31.000000000 +0200
@@ -158,8 +158,7 @@ static void udf_bitmap_free_blocks(struc
 	unsigned long overflow;
 
 	down(&sbi->s_alloc_sem);
-	if (bloc.logicalBlockNum < 0 ||
-		(bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
+	if ((bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
 	{
 		udf_debug("%d < %d || %d + %d > %d\n",
 			bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
@@ -232,7 +231,7 @@ static int udf_bitmap_prealloc_blocks(st
 	struct buffer_head *bh;
 
 	down(&sbi->s_alloc_sem);
-	if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
+	if (first_block >= UDF_SB_PARTLEN(sb, partition))
 		goto out;
 
 	if (first_block + block_count > UDF_SB_PARTLEN(sb, partition))
@@ -299,7 +298,7 @@ static int udf_bitmap_new_block(struct s
 	down(&sbi->s_alloc_sem);
 
 repeat:
-	if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
+	if (goal >= UDF_SB_PARTLEN(sb, partition))
 		goal = 0;
 
 	nr_groups = bitmap->s_nr_groups;
@@ -439,8 +438,7 @@ static void udf_table_free_blocks(struct
 	int i;
 
 	down(&sbi->s_alloc_sem);
-	if (bloc.logicalBlockNum < 0 ||
-		(bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
+	if ((bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
 	{
 		udf_debug("%d < %d || %d + %d > %d\n",
 			bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
@@ -688,7 +686,7 @@ static int udf_table_prealloc_blocks(str
 	struct buffer_head *bh;
 	int8_t etype = -1;
 
-	if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
+	if (first_block >= UDF_SB_PARTLEN(sb, partition))
 		return 0;
 
 	if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT)
@@ -768,7 +766,7 @@ static int udf_table_new_block(struct su
 		return newblock;
 
 	down(&sbi->s_alloc_sem);
-	if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
+	if (goal >= UDF_SB_PARTLEN(sb, partition))
 		goal = 0;
 
 	/* We search for the closest matching block to goal. If we find a exact hit,




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux