Skip to contentSkip to conversation

block: remove unnecessary NULL checks in bioset_integrity_free()

PATCH Applied Tim Hansen 4 participants 6 messages Oct 5, 2017 – Oct 9, 2017 Block layer

lore
Share & tools
lore

Tim Hansen

author
#0 lore raw

PATCH 1/1 block: remove unnecessary NULL checks in bioset_integrity_free()

mempool_destroy() already checks for a NULL value being passed in, this eliminates duplicate checks.

This was caught by running make coccicheck M=block/ on linus' tree on commit 77ede3a014a32746002f7889211f0cecf4803163 (current head as of this patch).

---
 block/bio-integrity.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
block/bio-integrity.c +2 -5
index 5df3290..23b42e8 100644
@@ -485,11 +485,8 @@ EXPORT_SYMBOL(bioset_integrity_create);
 
 void bioset_integrity_free(struct bio_set *bs)
 {
-	if (bs->bio_integrity_pool)
-		mempool_destroy(bs->bio_integrity_pool);
-
-	if (bs->bvec_integrity_pool)
-		mempool_destroy(bs->bvec_integrity_pool);
+	mempool_destroy(bs->bio_integrity_pool);
+	mempool_destroy(bs->bvec_integrity_pool);
 }
 EXPORT_SYMBOL(bioset_integrity_free);
 
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw

Hi Tim,

Quoted 2 lines · Tim Hansen

=20
mempool_destroy() already checks for a NULL value being passed in, =

this eliminates duplicate checks.

Quoted 2 lines

=20
This was caught by running make coccicheck M=3Dblock/ on linus' tree =

on commit 77ede3a014a32746002f7889211f0cecf4803163 (current head as of = this patch).

Quoted 21 lines

=20

---
block/bio-integrity.c | 7 ++-----

1 file changed, 2 insertions(+), 5 deletions(-)

=20

block/bio-integrity.c +0 -0
index 5df3290..23b42e8 100644
@@ -485,11 +485,8 @@ EXPORT_SYMBOL(bioset_integrity_create);

=20
void bioset_integrity_free(struct bio_set *bs)
{

block/bio-integrity.c +2 -5
-	if (bs->bio_integrity_pool)
-		mempool_destroy(bs->bio_integrity_pool);
-
-	if (bs->bvec_integrity_pool)
-		mempool_destroy(bs->bvec_integrity_pool);
+	mempool_destroy(bs->bio_integrity_pool);
+	mempool_destroy(bs->bvec_integrity_pool);
Quoted 5 lines

}
EXPORT_SYMBOL(bioset_integrity_free);
=20
--=20
2.1.4

Looks good.

maintainer Applied
#3 lore raw
In reply to Tim Hansen
Quoted 3 lines · Tim Hansen

mempool_destroy() already checks for a NULL value being passed in, this eliminates duplicate checks.

This was caught by running make coccicheck M=block/ on linus' tree on commit 77ede3a014a32746002f7889211f0cecf4803163 (current head as of this patch).

Applied, but I had to fix up your commit message. Please line wrap at 72 chars, otherwise it turns into an unreadable mess when people try to view them.

Signature · 1 line
Jens Axboe
author
#4 lore raw
Quoted 12 lines · Jens Axboe
Quoted 3 lines · Tim Hansen

mempool_destroy() already checks for a NULL value being passed in, this eliminates duplicate checks.

This was caught by running make coccicheck M=block/ on linus' tree on commit 77ede3a014a32746002f7889211f0cecf4803163 (current head as of this patch).

Applied, but I had to fix up your commit message. Please line wrap at 72 chars, otherwise it turns into an unreadable mess when people try to view them.

Signature · 1 line
Jens Axboe

Noted! Thanks for the heads up on the char limit.

#5 lore raw
Quoted 3 lines · Tim Hansen
Quoted 2 lines · Jens Axboe
Quoted 1 line · Tim Hansen

mempool_destroy() already checks for a NULL value being passed in, =

this eliminates duplicate checks.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

=20
This was caught by running make coccicheck M=3Dblock/ on linus' tree =

on commit 77ede3a014a32746002f7889211f0cecf4803163 (current head as of = this patch).

Quoted 10 lines
Quoted 8 lines

=20
Applied, but I had to fix up your commit message. Please line wrap at 72 chars, otherwise it turns into an unreadable mess when people try to view them.
=20
--=20
Jens Axboe
=20

=20
Noted! Thanks for the heads up on the char limit.

scripts/checkpatch.pl would have caught it too

--
Kyle Fortin - Oracle Linux Engineering