Commit eb9bc8e7 authored by Tim Chen's avatar Tim Chen Committed by Herbert Xu

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: default avatarTim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent bd76ad4a
...@@ -304,7 +304,7 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr, ...@@ -304,7 +304,7 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
* Or if the user's buffer contains less than a whole block, * Or if the user's buffer contains less than a whole block,
* append as much as possible to the extra block. * append as much as possible to the extra block.
*/ */
if ((ctx->partial_block_buffer_length) | (len < SHA1_BLOCK_SIZE)) { if (ctx->partial_block_buffer_length || len < SHA1_BLOCK_SIZE) {
/* /*
* Compute how many bytes to copy from user buffer into * Compute how many bytes to copy from user buffer into
* extra block * extra block
......
...@@ -283,7 +283,8 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr, ...@@ -283,7 +283,8 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
ctx->incoming_buffer = buffer; ctx->incoming_buffer = buffer;
ctx->incoming_buffer_length = len; ctx->incoming_buffer_length = len;
/* Store the user's request flags and mark this ctx as currently /*
* Store the user's request flags and mark this ctx as currently
* being processed. * being processed.
*/ */
ctx->status = (flags & HASH_LAST) ? ctx->status = (flags & HASH_LAST) ?
...@@ -299,8 +300,9 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr, ...@@ -299,8 +300,9 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
* Or if the user's buffer contains less than a whole block, * Or if the user's buffer contains less than a whole block,
* append as much as possible to the extra block. * append as much as possible to the extra block.
*/ */
if ((ctx->partial_block_buffer_length) | (len < SHA256_BLOCK_SIZE)) { if (ctx->partial_block_buffer_length || len < SHA256_BLOCK_SIZE) {
/* Compute how many bytes to copy from user buffer into /*
* Compute how many bytes to copy from user buffer into
* extra block * extra block
*/ */
uint32_t copy_len = SHA256_BLOCK_SIZE - 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,7 +325,8 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
/* The extra block should never contain more than 1 block */ /* The extra block should never contain more than 1 block */
assert(ctx->partial_block_buffer_length <= SHA256_BLOCK_SIZE); assert(ctx->partial_block_buffer_length <= SHA256_BLOCK_SIZE);
/* If the extra block buffer contains exactly 1 block, /*
* If the extra block buffer contains exactly 1 block,
* it can be hashed. * it can be hashed.
*/ */
if (ctx->partial_block_buffer_length >= SHA256_BLOCK_SIZE) { if (ctx->partial_block_buffer_length >= SHA256_BLOCK_SIZE) {
......
...@@ -253,7 +253,8 @@ static struct sha512_hash_ctx ...@@ -253,7 +253,8 @@ static struct sha512_hash_ctx
int flags) int flags)
{ {
if (flags & (~HASH_ENTIRE)) { if (flags & (~HASH_ENTIRE)) {
/* User should not pass anything other than FIRST, UPDATE, or /*
* User should not pass anything other than FIRST, UPDATE, or
* LAST * LAST
*/ */
ctx->error = HASH_CTX_ERROR_INVALID_FLAGS; ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
...@@ -284,7 +285,8 @@ static struct sha512_hash_ctx ...@@ -284,7 +285,8 @@ static struct sha512_hash_ctx
ctx->partial_block_buffer_length = 0; ctx->partial_block_buffer_length = 0;
} }
/* If we made it here, there were no errors during this call to /*
* If we made it here, there were no errors during this call to
* submit * submit
*/ */
ctx->error = HASH_CTX_ERROR_NONE; ctx->error = HASH_CTX_ERROR_NONE;
...@@ -293,7 +295,8 @@ static struct sha512_hash_ctx ...@@ -293,7 +295,8 @@ static struct sha512_hash_ctx
ctx->incoming_buffer = buffer; ctx->incoming_buffer = buffer;
ctx->incoming_buffer_length = len; ctx->incoming_buffer_length = len;
/* Store the user's request flags and mark this ctx as currently being /*
* Store the user's request flags and mark this ctx as currently being
* processed. * processed.
*/ */
ctx->status = (flags & HASH_LAST) ? ctx->status = (flags & HASH_LAST) ?
...@@ -309,7 +312,7 @@ static struct sha512_hash_ctx ...@@ -309,7 +312,7 @@ static struct sha512_hash_ctx
* Or if the user's buffer contains less than a whole block, * Or if the user's buffer contains less than a whole block,
* append as much as possible to the extra block. * append as much as possible to the extra block.
*/ */
if ((ctx->partial_block_buffer_length) | (len < SHA512_BLOCK_SIZE)) { if (ctx->partial_block_buffer_length || len < SHA512_BLOCK_SIZE) {
/* Compute how many bytes to copy from user buffer into extra /* Compute how many bytes to copy from user buffer into extra
* block * block
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment