Skip to content

Commit

Permalink
crypto: rmd320 - use swap macro in rmd320_transform
Browse files Browse the repository at this point in the history
Make use of the swap macro and remove unnecessary variable *tmp*.
This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
GustavoARSilva authored and herbertx committed Jul 27, 2018
1 parent d75f482 commit a478908
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crypto/rmd320.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct rmd320_ctx {

static void rmd320_transform(u32 *state, const __le32 *in)
{
u32 aa, bb, cc, dd, ee, aaa, bbb, ccc, ddd, eee, tmp;
u32 aa, bb, cc, dd, ee, aaa, bbb, ccc, ddd, eee;

/* Initialize left lane */
aa = state[0];
Expand Down Expand Up @@ -106,7 +106,7 @@ static void rmd320_transform(u32 *state, const __le32 *in)
ROUND(aaa, bbb, ccc, ddd, eee, F5, KK1, in[12], 6);

/* Swap contents of "a" registers */
tmp = aa; aa = aaa; aaa = tmp;
swap(aa, aaa);

/* round 2: left lane" */
ROUND(ee, aa, bb, cc, dd, F2, K2, in[7], 7);
Expand Down Expand Up @@ -145,7 +145,7 @@ static void rmd320_transform(u32 *state, const __le32 *in)
ROUND(eee, aaa, bbb, ccc, ddd, F4, KK2, in[2], 11);

/* Swap contents of "b" registers */
tmp = bb; bb = bbb; bbb = tmp;
swap(bb, bbb);

/* round 3: left lane" */
ROUND(dd, ee, aa, bb, cc, F3, K3, in[3], 11);
Expand Down Expand Up @@ -184,7 +184,7 @@ static void rmd320_transform(u32 *state, const __le32 *in)
ROUND(ddd, eee, aaa, bbb, ccc, F3, KK3, in[13], 5);

/* Swap contents of "c" registers */
tmp = cc; cc = ccc; ccc = tmp;
swap(cc, ccc);

/* round 4: left lane" */
ROUND(cc, dd, ee, aa, bb, F4, K4, in[1], 11);
Expand Down Expand Up @@ -223,7 +223,7 @@ static void rmd320_transform(u32 *state, const __le32 *in)
ROUND(ccc, ddd, eee, aaa, bbb, F2, KK4, in[14], 8);

/* Swap contents of "d" registers */
tmp = dd; dd = ddd; ddd = tmp;
swap(dd, ddd);

/* round 5: left lane" */
ROUND(bb, cc, dd, ee, aa, F5, K5, in[4], 9);
Expand Down Expand Up @@ -262,7 +262,7 @@ static void rmd320_transform(u32 *state, const __le32 *in)
ROUND(bbb, ccc, ddd, eee, aaa, F1, KK5, in[11], 11);

/* Swap contents of "e" registers */
tmp = ee; ee = eee; eee = tmp;
swap(ee, eee);

/* combine results */
state[0] += aa;
Expand Down

0 comments on commit a478908

Please sign in to comment.