[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <558D0A27.7010905@users.sourceforge.net>
Date: Fri, 26 Jun 2015 10:15:35 +0200
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: linux-kernel@...r.kernel.org
CC: kernel-janitors@...r.kernel.org,
Julia Lawall <julia.lawall@...6.fr>
Subject: [PATCH] lib/mpi: Delete unnecessary checks before the function call
"mpi_free_limb_space"
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 26 Jun 2015 10:11:19 +0200
The mpi_free_limb_space() function tests whether its argument is NULL and
then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
lib/mpi/mpi-pow.c | 15 +++++----------
lib/mpi/mpih-mul.c | 21 +++++++--------------
2 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
index 5464c87..c28882f 100644
--- a/lib/mpi/mpi-pow.c
+++ b/lib/mpi/mpi-pow.c
@@ -308,16 +308,11 @@ leave:
enomem:
if (assign_rp)
mpi_assign_limb_space(res, rp, size);
- if (mp_marker)
- mpi_free_limb_space(mp_marker);
- if (bp_marker)
- mpi_free_limb_space(bp_marker);
- if (ep_marker)
- mpi_free_limb_space(ep_marker);
- if (xp_marker)
- mpi_free_limb_space(xp_marker);
- if (tspace)
- mpi_free_limb_space(tspace);
+ mpi_free_limb_space(mp_marker);
+ mpi_free_limb_space(bp_marker);
+ mpi_free_limb_space(ep_marker);
+ mpi_free_limb_space(xp_marker);
+ mpi_free_limb_space(tspace);
return rc;
}
EXPORT_SYMBOL_GPL(mpi_powm);
diff --git a/lib/mpi/mpih-mul.c b/lib/mpi/mpih-mul.c
index 7c84171..ff021cc 100644
--- a/lib/mpi/mpih-mul.c
+++ b/lib/mpi/mpih-mul.c
@@ -339,8 +339,7 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
mpi_limb_t cy;
if (!ctx->tspace || ctx->tspace_size < vsize) {
- if (ctx->tspace)
- mpi_free_limb_space(ctx->tspace);
+ mpi_free_limb_space(ctx->tspace);
ctx->tspace = mpi_alloc_limb_space(2 * vsize);
if (!ctx->tspace)
return -ENOMEM;
@@ -354,12 +353,10 @@ mpihelp_mul_karatsuba_case(mpi_ptr_t prodp,
usize -= vsize;
if (usize >= vsize) {
if (!ctx->tp || ctx->tp_size < vsize) {
- if (ctx->tp)
- mpi_free_limb_space(ctx->tp);
+ mpi_free_limb_space(ctx->tp);
ctx->tp = mpi_alloc_limb_space(2 * vsize);
if (!ctx->tp) {
- if (ctx->tspace)
- mpi_free_limb_space(ctx->tspace);
+ mpi_free_limb_space(ctx->tspace);
ctx->tspace = NULL;
return -ENOMEM;
}
@@ -407,16 +404,12 @@ void mpihelp_release_karatsuba_ctx(struct karatsuba_ctx *ctx)
{
struct karatsuba_ctx *ctx2;
- if (ctx->tp)
- mpi_free_limb_space(ctx->tp);
- if (ctx->tspace)
- mpi_free_limb_space(ctx->tspace);
+ mpi_free_limb_space(ctx->tp);
+ mpi_free_limb_space(ctx->tspace);
for (ctx = ctx->next; ctx; ctx = ctx2) {
ctx2 = ctx->next;
- if (ctx->tp)
- mpi_free_limb_space(ctx->tp);
- if (ctx->tspace)
- mpi_free_limb_space(ctx->tspace);
+ mpi_free_limb_space(ctx->tp);
+ mpi_free_limb_space(ctx->tspace);
kfree(ctx);
}
}
--
2.4.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists