diff options
author | Tim Chen <tim.c.chen@linux.intel.com> | 2016-07-08 12:28:03 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-07-12 01:02:00 -0400 |
commit | eb9bc8e7afaa9f062105dad55ec1c0663d961bb3 (patch) | |
tree | ee3fdfcaa6e1dcbb0522bd8861ec26505c4d20b5 | |
parent | bd76ad4abfdccd26a9ac11214aa715e83bc8e808 (diff) |
crypto: sha-mb - Cleanup code to use || instead of |
for condition comparison and cleanup multiline comment style
In sha*_ctx_mgr_submit, we currently use the | operator instead of ||
((ctx->partial_block_buffer_length) | (len < SHA1_BLOCK_SIZE))
Switching it to || and remove extraneous paranthesis to
adhere to coding style.
Also cleanup inconsistent multiline comment style.
Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | arch/x86/crypto/sha1-mb/sha1_mb.c | 2 | ||||
-rw-r--r-- | arch/x86/crypto/sha256-mb/sha256_mb.c | 11 | ||||
-rw-r--r-- | arch/x86/crypto/sha512-mb/sha512_mb.c | 11 |
3 files changed, 15 insertions, 9 deletions
diff --git a/arch/x86/crypto/sha1-mb/sha1_mb.c b/arch/x86/crypto/sha1-mb/sha1_mb.c index 561b2867b878..9e5b67127a09 100644 --- a/arch/x86/crypto/sha1-mb/sha1_mb.c +++ b/arch/x86/crypto/sha1-mb/sha1_mb.c | |||
@@ -304,7 +304,7 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr, | |||
304 | * Or if the user's buffer contains less than a whole block, | 304 | * Or if the user's buffer contains less than a whole block, |
305 | * append as much as possible to the extra block. | 305 | * append as much as possible to the extra block. |
306 | */ | 306 | */ |
307 | if ((ctx->partial_block_buffer_length) | (len < SHA1_BLOCK_SIZE)) { | 307 | if (ctx->partial_block_buffer_length || len < SHA1_BLOCK_SIZE) { |
308 | /* | 308 | /* |
309 | * Compute how many bytes to copy from user buffer into | 309 | * Compute how many bytes to copy from user buffer into |
310 | * extra block | 310 | * extra block |
diff --git a/arch/x86/crypto/sha256-mb/sha256_mb.c b/arch/x86/crypto/sha256-mb/sha256_mb.c index c9d5dcc81c96..89fa85e8b10c 100644 --- a/arch/x86/crypto/sha256-mb/sha256_mb.c +++ b/arch/x86/crypto/sha256-mb/sha256_mb.c | |||
@@ -283,7 +283,8 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr, | |||
283 | ctx->incoming_buffer = buffer; | 283 | ctx->incoming_buffer = buffer; |
284 | ctx->incoming_buffer_length = len; | 284 | ctx->incoming_buffer_length = len; |
285 | 285 | ||
286 | /* Store the user's request flags and mark this ctx as currently | 286 | /* |
287 | * Store the user's request flags and mark this ctx as currently | ||
287 | * being processed. | 288 | * being processed. |
288 | */ | 289 | */ |
289 | ctx->status = (flags & HASH_LAST) ? | 290 | ctx->status = (flags & HASH_LAST) ? |
@@ -299,8 +300,9 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr, | |||
299 | * Or if the user's buffer contains less than a whole block, | 300 | * Or if the user's buffer contains less than a whole block, |
300 | * append as much as possible to the extra block. | 301 | * append as much as possible to the extra block. |
301 | */ | 302 | */ |
302 | if ((ctx->partial_block_buffer_length) | (len < SHA256_BLOCK_SIZE)) { | 303 | if (ctx->partial_block_buffer_length || len < SHA256_BLOCK_SIZE) { |
303 | /* Compute how many bytes to copy from user buffer into | 304 | /* |
305 | * Compute how many bytes to copy from user buffer into | ||
304 | * extra block | 306 | * extra block |
305 | */ | 307 | */ |
306 | uint32_t copy_len = SHA256_BLOCK_SIZE - | 308 | uint32_t copy_len = SHA256_BLOCK_SIZE - |
@@ -323,7 +325,8 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr, | |||
323 | /* The extra block should never contain more than 1 block */ | 325 | /* The extra block should never contain more than 1 block */ |
324 | assert(ctx->partial_block_buffer_length <= SHA256_BLOCK_SIZE); | 326 | assert(ctx->partial_block_buffer_length <= SHA256_BLOCK_SIZE); |
325 | 327 | ||
326 | /* If the extra block buffer contains exactly 1 block, | 328 | /* |
329 | * If the extra block buffer contains exactly 1 block, | ||
327 | * it can be hashed. | 330 | * it can be hashed. |
328 | */ | 331 | */ |
329 | if (ctx->partial_block_buffer_length >= SHA256_BLOCK_SIZE) { | 332 | if (ctx->partial_block_buffer_length >= SHA256_BLOCK_SIZE) { |
diff --git a/arch/x86/crypto/sha512-mb/sha512_mb.c b/arch/x86/crypto/sha512-mb/sha512_mb.c index 676f0f272f2b..f4cf5b78fd36 100644 --- a/arch/x86/crypto/sha512-mb/sha512_mb.c +++ b/arch/x86/crypto/sha512-mb/sha512_mb.c | |||
@@ -253,7 +253,8 @@ static struct sha512_hash_ctx | |||
253 | int flags) | 253 | int flags) |
254 | { | 254 | { |
255 | if (flags & (~HASH_ENTIRE)) { | 255 | if (flags & (~HASH_ENTIRE)) { |
256 | /* User should not pass anything other than FIRST, UPDATE, or | 256 | /* |
257 | * User should not pass anything other than FIRST, UPDATE, or | ||
257 | * LAST | 258 | * LAST |
258 | */ | 259 | */ |
259 | ctx->error = HASH_CTX_ERROR_INVALID_FLAGS; | 260 | ctx->error = HASH_CTX_ERROR_INVALID_FLAGS; |
@@ -284,7 +285,8 @@ static struct sha512_hash_ctx | |||
284 | ctx->partial_block_buffer_length = 0; | 285 | ctx->partial_block_buffer_length = 0; |
285 | } | 286 | } |
286 | 287 | ||
287 | /* If we made it here, there were no errors during this call to | 288 | /* |
289 | * If we made it here, there were no errors during this call to | ||
288 | * submit | 290 | * submit |
289 | */ | 291 | */ |
290 | ctx->error = HASH_CTX_ERROR_NONE; | 292 | ctx->error = HASH_CTX_ERROR_NONE; |
@@ -293,7 +295,8 @@ static struct sha512_hash_ctx | |||
293 | ctx->incoming_buffer = buffer; | 295 | ctx->incoming_buffer = buffer; |
294 | ctx->incoming_buffer_length = len; | 296 | ctx->incoming_buffer_length = len; |
295 | 297 | ||
296 | /* Store the user's request flags and mark this ctx as currently being | 298 | /* |
299 | * Store the user's request flags and mark this ctx as currently being | ||
297 | * processed. | 300 | * processed. |
298 | */ | 301 | */ |
299 | ctx->status = (flags & HASH_LAST) ? | 302 | ctx->status = (flags & HASH_LAST) ? |
@@ -309,7 +312,7 @@ static struct sha512_hash_ctx | |||
309 | * Or if the user's buffer contains less than a whole block, | 312 | * Or if the user's buffer contains less than a whole block, |
310 | * append as much as possible to the extra block. | 313 | * append as much as possible to the extra block. |
311 | */ | 314 | */ |
312 | if ((ctx->partial_block_buffer_length) | (len < SHA512_BLOCK_SIZE)) { | 315 | if (ctx->partial_block_buffer_length || len < SHA512_BLOCK_SIZE) { |
313 | /* Compute how many bytes to copy from user buffer into extra | 316 | /* Compute how many bytes to copy from user buffer into extra |
314 | * block | 317 | * block |
315 | */ | 318 | */ |