diff options
author | Julien Brunel <brunel@diku.dk> | 2008-08-21 13:46:30 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2008-08-21 13:46:39 -0400 |
commit | 0983e56835cbf4796e8f5780c549c32ac1c3afac (patch) | |
tree | d0a98012929abcd12d95c7a96184a69b1b1d4c6b | |
parent | 6a55617ed5d1aa62b850de2cf66f5ede2eef4825 (diff) |
[S390] drivers/s390: Use an IS_ERR test rather than a NULL test
In case of error, functions dasd_kmalloc_request and idal_buffer_alloc
return an ERR pointer, but never return the NULL pointer. So after a
call to one of these functions, a NULL test should be replaced by an
IS_ERR test.
A simplified version of the semantic patch that makes this change is
as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@correct_null_test@
expression x,E;
statement S1, S2;
@@
x =
(
dasd_kmalloc_request(...)
|
idal_buffer_alloc(...)
)
<... when != x = E
if (
(
- x@p2 != NULL
+ ! IS_ERR ( x )
|
- x@p2 == NULL
+ IS_ERR( x )
)
)
S1
else S2
...>
? x = E;
// </smpl>
Signed-off-by: Julien Brunel <brunel@diku.dk>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r-- | drivers/s390/block/dasd_eer.c | 3 | ||||
-rw-r--r-- | drivers/s390/char/tape_char.c | 2 | ||||
-rw-r--r-- | drivers/s390/char/tape_std.c | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c index 29da4413ad43..bf512ac75b9e 100644 --- a/drivers/s390/block/dasd_eer.c +++ b/drivers/s390/block/dasd_eer.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/poll.h> | 16 | #include <linux/poll.h> |
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
18 | #include <linux/smp_lock.h> | 18 | #include <linux/smp_lock.h> |
19 | #include <linux/err.h> | ||
19 | 20 | ||
20 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
21 | #include <asm/atomic.h> | 22 | #include <asm/atomic.h> |
@@ -457,7 +458,7 @@ int dasd_eer_enable(struct dasd_device *device) | |||
457 | 458 | ||
458 | cqr = dasd_kmalloc_request("ECKD", 1 /* SNSS */, | 459 | cqr = dasd_kmalloc_request("ECKD", 1 /* SNSS */, |
459 | SNSS_DATA_SIZE, device); | 460 | SNSS_DATA_SIZE, device); |
460 | if (!cqr) | 461 | if (IS_ERR(cqr)) |
461 | return -ENOMEM; | 462 | return -ENOMEM; |
462 | 463 | ||
463 | cqr->startdev = device; | 464 | cqr->startdev = device; |
diff --git a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c index 687720b552d1..be0ce2215c8d 100644 --- a/drivers/s390/char/tape_char.c +++ b/drivers/s390/char/tape_char.c | |||
@@ -109,7 +109,7 @@ tapechar_check_idalbuffer(struct tape_device *device, size_t block_size) | |||
109 | 109 | ||
110 | /* The current idal buffer is not correct. Allocate a new one. */ | 110 | /* The current idal buffer is not correct. Allocate a new one. */ |
111 | new = idal_buffer_alloc(block_size, 0); | 111 | new = idal_buffer_alloc(block_size, 0); |
112 | if (new == NULL) | 112 | if (IS_ERR(new)) |
113 | return -ENOMEM; | 113 | return -ENOMEM; |
114 | 114 | ||
115 | if (device->char_data.idal_buf != NULL) | 115 | if (device->char_data.idal_buf != NULL) |
diff --git a/drivers/s390/char/tape_std.c b/drivers/s390/char/tape_std.c index 2a1af4e60be0..cc8fd781ee22 100644 --- a/drivers/s390/char/tape_std.c +++ b/drivers/s390/char/tape_std.c | |||
@@ -248,7 +248,7 @@ tape_std_mtsetblk(struct tape_device *device, int count) | |||
248 | 248 | ||
249 | /* Allocate a new idal buffer. */ | 249 | /* Allocate a new idal buffer. */ |
250 | new = idal_buffer_alloc(count, 0); | 250 | new = idal_buffer_alloc(count, 0); |
251 | if (new == NULL) | 251 | if (IS_ERR(new)) |
252 | return -ENOMEM; | 252 | return -ENOMEM; |
253 | if (device->char_data.idal_buf != NULL) | 253 | if (device->char_data.idal_buf != NULL) |
254 | idal_buffer_free(device->char_data.idal_buf); | 254 | idal_buffer_free(device->char_data.idal_buf); |