[Btrfs-devel] In correct usage of IS_ERR() in extent_io.c
Peter Teoh
htmldeveloper at gmail.com
Sat Mar 15 19:33:21 PDT 2008
Please correct me if wrong. kmem_cache_alloc() based API should not
call IS_ERR() to check on error. Similarly, many usage of IS_ERR()
is not correct, as it will lead to returning an error condition when
there is no error. Self-explanatory as in the following err.h header
declaration:
#define MAX_ERRNO 4095
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
static inline long IS_ERR(const void *ptr)
{
return IS_ERR_VALUE((unsigned long)ptr);
}
Signed-off-by: Peter Teoh <htmldeveloper at gmail.com>
--- extent_io.c.orig 2008-03-15 12:33:37.000000000 +0800
+++ extent_io.c 2008-03-16 10:32:23.000000000 +0800
@@ -111,7 +111,7 @@ struct extent_state *alloc_extent_state(
struct extent_state *state;
state = kmem_cache_alloc(extent_state_cache, mask);
- if (!state || IS_ERR(state))
+ if (!state)
return state;
state->state = 0;
state->private = 0;
@@ -941,7 +941,7 @@ int find_first_extent_bit(struct extent_
* our range starts.
*/
node = tree_search(tree, start);
- if (!node || IS_ERR(node)) {
+ if (!node) {
goto out;
}
@@ -974,7 +974,7 @@ struct extent_state *find_first_extent_b
* our range starts.
*/
node = tree_search(tree, start);
- if (!node || IS_ERR(node)) {
+ if (!node) {
goto out;
}
@@ -1008,7 +1008,7 @@ u64 find_lock_delalloc_range(struct exte
*/
search_again:
node = tree_search(tree, cur_start);
- if (!node || IS_ERR(node)) {
+ if (!node) {
*end = (u64)-1;
goto out;
}
@@ -1096,7 +1096,7 @@ u64 count_range_bits(struct extent_io_tr
* our range starts.
*/
node = tree_search(tree, cur_start);
- if (!node || IS_ERR(node)) {
+ if (!node) {
goto out;
}
@@ -1197,7 +1197,7 @@ int set_state_private(struct extent_io_t
* our range starts.
*/
node = tree_search(tree, start);
- if (!node || IS_ERR(node)) {
+ if (!node) {
ret = -ENOENT;
goto out;
}
@@ -1224,7 +1224,7 @@ int get_state_private(struct extent_io_t
* our range starts.
*/
node = tree_search(tree, start);
- if (!node || IS_ERR(node)) {
+ if (!node) {
ret = -ENOENT;
goto out;
}
@@ -2616,7 +2616,7 @@ struct extent_buffer *alloc_extent_buffe
int uptodate = 1;
eb = __alloc_extent_buffer(tree, start, len, mask);
- if (!eb || IS_ERR(eb))
+ if (!eb)
return NULL;
if (eb->flags & EXTENT_BUFFER_FILLED)
@@ -2691,7 +2691,7 @@ struct extent_buffer *find_extent_buffer
int uptodate = 1;
eb = __alloc_extent_buffer(tree, start, len, mask);
- if (!eb || IS_ERR(eb))
+ if (!eb)
return NULL;
if (eb->flags & EXTENT_BUFFER_FILLED)
--
Regards,
Peter Teoh
More information about the Btrfs-devel
mailing list