* [PATCH]btrfs: avoid comparing with NULL pointer
@ 2010-01-27 6:27 Liuwenyi
2010-01-27 8:00 ` Yan, Zheng
0 siblings, 1 reply; 3+ messages in thread
From: Liuwenyi @ 2010-01-27 6:27 UTC (permalink / raw)
To: chris.mason, zheng.yan, jbacik, jens.axboe, linux-btrfs,
linux-kernel, strongzgy
In this patch, I adjust the seqence of if-conditions.
It will assess the page->private situation.
First, we make sure the page->private is not null.
And then, we can do some with this page->private.
---
Signed-off-by: Liuwenyi <qingshenlwy@gmail.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Yan Zheng <zheng.yan@oracle.com>
Cc: Josef Bacik <jbacik@redhat.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: linux-btrfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
fs/btrfs/disk-io.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 009e3bd..a300dca 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1407,11 +1407,11 @@ static int bio_ready_for_csum(struct bio *bio)
bio_for_each_segment(bvec, bio, i) {
page = bvec->bv_page;
- if (page->private == EXTENT_PAGE_PRIVATE) {
+ if (!page->private) {
length += bvec->bv_len;
continue;
}
- if (!page->private) {
+ if (page->private == EXTENT_PAGE_PRIVATE) {
length += bvec->bv_len;
continue;
}
--
1.6.6
---
Best Regards,
Liuwenyi
2010-01-277
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH]btrfs: avoid comparing with NULL pointer
2010-01-27 6:27 [PATCH]btrfs: avoid comparing with NULL pointer Liuwenyi
@ 2010-01-27 8:00 ` Yan, Zheng
2010-01-27 14:19 ` Liuwenyi
0 siblings, 1 reply; 3+ messages in thread
From: Yan, Zheng @ 2010-01-27 8:00 UTC (permalink / raw)
To: Liuwenyi
Cc: chris.mason, jbacik, jens.axboe, linux-btrfs, linux-kernel,
strongzgy
2010/1/27 Liuwenyi <qingshenlwy@gmail.com>:
> In this patch, I adjust the seqence of if-conditions.
> It will assess the page->private situation.
> First, we make sure the page->private is not null.
> And then, we can do some with this page->private.
>
> ---
> Signed-off-by: Liuwenyi <qingshenlwy@gmail.com>
> Cc: Chris Mason <chris.mason@oracle.com>
> Cc: Yan Zheng <zheng.yan@oracle.com>
> Cc: Josef Bacik <jbacik@redhat.com>
> Cc: Jens Axboe <jens.axboe@oracle.com>
> Cc: linux-btrfs@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
>
> ---
> fs/btrfs/disk-io.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 009e3bd..a300dca 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -1407,11 +1407,11 @@ static int bio_ready_for_csum(struct bio *bio)
>
> bio_for_each_segment(bvec, bio, i) {
> page = bvec->bv_page;
> - if (page->private == EXTENT_PAGE_PRIVATE) {
> + if (!page->private) {
> length += bvec->bv_len;
> continue;
> }
> - if (!page->private) {
> + if (page->private == EXTENT_PAGE_PRIVATE) {
> length += bvec->bv_len;
> continue;
> }
> --
Why do you want to do this? The code is perfect safe even
page->private is NULL. Furthermore, your patch is malformed.
Yan, Zheng
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH]btrfs: avoid comparing with NULL pointer
2010-01-27 8:00 ` Yan, Zheng
@ 2010-01-27 14:19 ` Liuwenyi
0 siblings, 0 replies; 3+ messages in thread
From: Liuwenyi @ 2010-01-27 14:19 UTC (permalink / raw)
To: Yan, Zheng
Cc: chris.mason, jbacik, jens.axboe, linux-btrfs, linux-kernel,
strongzgy
于 2010年01月27日 16:00, Yan, Zheng 写道:
> 2010/1/27 Liuwenyi<qingshenlwy@gmail.com>:
>
>> In this patch, I adjust the seqence of if-conditions.
>> It will assess the page->private situation.
>> First, we make sure the page->private is not null.
>> And then, we can do some with this page->private.
>>
>> ---
>> Signed-off-by: Liuwenyi<qingshenlwy@gmail.com>
>> Cc: Chris Mason<chris.mason@oracle.com>
>> Cc: Yan Zheng<zheng.yan@oracle.com>
>> Cc: Josef Bacik<jbacik@redhat.com>
>> Cc: Jens Axboe<jens.axboe@oracle.com>
>> Cc: linux-btrfs@vger.kernel.org
>> Cc: linux-kernel@vger.kernel.org
>>
>> ---
>> fs/btrfs/disk-io.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
>> index 009e3bd..a300dca 100644
>> --- a/fs/btrfs/disk-io.c
>> +++ b/fs/btrfs/disk-io.c
>> @@ -1407,11 +1407,11 @@ static int bio_ready_for_csum(struct bio *bio)
>>
>> bio_for_each_segment(bvec, bio, i) {
>> page = bvec->bv_page;
>> - if (page->private == EXTENT_PAGE_PRIVATE) {
>> + if (!page->private) {
>> length += bvec->bv_len;
>> continue;
>> }
>> - if (!page->private) {
>> + if (page->private == EXTENT_PAGE_PRIVATE) {
>> length += bvec->bv_len;
>> continue;
>> }
>> --
>>
> Why do you want to do this? The code is perfect safe even
> page->private is NULL. Furthermore, your patch is malformed.
>
> Yan, Zheng
>
Yes, I agree with you, this code is safe.
But I think we should check whether the pointer is available first.
It is unnecessary judge the "(page->private == EXTENT_PAGE_PRIVATE)"
while page->private is null.
---
Best Regards,
Liuwenyi
2010-1-27
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-27 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-27 6:27 [PATCH]btrfs: avoid comparing with NULL pointer Liuwenyi
2010-01-27 8:00 ` Yan, Zheng
2010-01-27 14:19 ` Liuwenyi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox