* [PATCH] udf: remove redundant tests on unsigned
@ 2009-06-22 21:12 Roel Kluin
2009-06-24 11:48 ` Jan Kara
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-06-22 21:12 UTC (permalink / raw)
To: jack, LKML, Andrew Morton
first_block and goal are unsigned. When negative they are wrapped and caught by
the other test.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index e48e9a3..1e06853 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -238,7 +238,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
mutex_lock(&sbi->s_alloc_mutex);
part_len = sbi->s_partmaps[partition].s_partition_len;
- if (first_block < 0 || first_block >= part_len)
+ if (first_block >= part_len)
goto out;
if (first_block + block_count > part_len)
@@ -297,7 +297,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
mutex_lock(&sbi->s_alloc_mutex);
repeat:
- if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
+ if (goal >= sbi->s_partmaps[partition].s_partition_len)
goal = 0;
nr_groups = bitmap->s_nr_groups;
@@ -666,8 +666,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
int8_t etype = -1;
struct udf_inode_info *iinfo;
- if (first_block < 0 ||
- first_block >= sbi->s_partmaps[partition].s_partition_len)
+ if (first_block >= sbi->s_partmaps[partition].s_partition_len)
return 0;
iinfo = UDF_I(table);
@@ -743,7 +742,7 @@ static int udf_table_new_block(struct super_block *sb,
return newblock;
mutex_lock(&sbi->s_alloc_mutex);
- if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
+ if (goal >= sbi->s_partmaps[partition].s_partition_len)
goal = 0;
/* We search for the closest matching block to goal. If we find
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] udf: remove redundant tests on unsigned
2009-06-22 21:12 [PATCH] udf: remove redundant tests on unsigned Roel Kluin
@ 2009-06-24 11:48 ` Jan Kara
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2009-06-24 11:48 UTC (permalink / raw)
To: Roel Kluin; +Cc: LKML, Andrew Morton
On Mon 22-06-09 23:12:29, Roel Kluin wrote:
> first_block and goal are unsigned. When negative they are wrapped and caught by
> the other test.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Thanks for the patch. I've merged it in UDF tree.
Honza
> ---
> diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
> index e48e9a3..1e06853 100644
> --- a/fs/udf/balloc.c
> +++ b/fs/udf/balloc.c
> @@ -238,7 +238,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
>
> mutex_lock(&sbi->s_alloc_mutex);
> part_len = sbi->s_partmaps[partition].s_partition_len;
> - if (first_block < 0 || first_block >= part_len)
> + if (first_block >= part_len)
> goto out;
>
> if (first_block + block_count > part_len)
> @@ -297,7 +297,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
> mutex_lock(&sbi->s_alloc_mutex);
>
> repeat:
> - if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
> + if (goal >= sbi->s_partmaps[partition].s_partition_len)
> goal = 0;
>
> nr_groups = bitmap->s_nr_groups;
> @@ -666,8 +666,7 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
> int8_t etype = -1;
> struct udf_inode_info *iinfo;
>
> - if (first_block < 0 ||
> - first_block >= sbi->s_partmaps[partition].s_partition_len)
> + if (first_block >= sbi->s_partmaps[partition].s_partition_len)
> return 0;
>
> iinfo = UDF_I(table);
> @@ -743,7 +742,7 @@ static int udf_table_new_block(struct super_block *sb,
> return newblock;
>
> mutex_lock(&sbi->s_alloc_mutex);
> - if (goal < 0 || goal >= sbi->s_partmaps[partition].s_partition_len)
> + if (goal >= sbi->s_partmaps[partition].s_partition_len)
> goal = 0;
>
> /* We search for the closest matching block to goal. If we find
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-24 11:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-22 21:12 [PATCH] udf: remove redundant tests on unsigned Roel Kluin
2009-06-24 11:48 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox