Skip to content

Commit eb9bc8e

Browse files
pdxChenherbertx
authored andcommitted
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>
1 parent bd76ad4 commit eb9bc8e

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎arch/x86/crypto/sha1-mb/sha1_mb.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
304304
* Or if the user's buffer contains less than a whole block,
305305
* append as much as possible to the extra block.
306306
*/
307-
if ((ctx->partial_block_buffer_length) | (len < SHA1_BLOCK_SIZE)) {
307+
if (ctx->partial_block_buffer_length || len < SHA1_BLOCK_SIZE) {
308308
/*
309309
* Compute how many bytes to copy from user buffer into
310310
* extra block

‎arch/x86/crypto/sha256-mb/sha256_mb.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
283283
ctx->incoming_buffer = buffer;
284284
ctx->incoming_buffer_length = len;
285285

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
287288
* being processed.
288289
*/
289290
ctx->status = (flags & HASH_LAST) ?
@@ -299,8 +300,9 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
299300
* Or if the user's buffer contains less than a whole block,
300301
* append as much as possible to the extra block.
301302
*/
302-
if ((ctx->partial_block_buffer_length) | (len < SHA256_BLOCK_SIZE)) {
303-
/* Compute how many bytes to copy from user buffer into
303+
if (ctx->partial_block_buffer_length || len < SHA256_BLOCK_SIZE) {
304+
/*
305+
* Compute how many bytes to copy from user buffer into
304306
* extra block
305307
*/
306308
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,
323325
/* The extra block should never contain more than 1 block */
324326
assert(ctx->partial_block_buffer_length <= SHA256_BLOCK_SIZE);
325327

326-
/* If the extra block buffer contains exactly 1 block,
328+
/*
329+
* If the extra block buffer contains exactly 1 block,
327330
* it can be hashed.
328331
*/
329332
if (ctx->partial_block_buffer_length >= SHA256_BLOCK_SIZE) {

‎arch/x86/crypto/sha512-mb/sha512_mb.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ static struct sha512_hash_ctx
253253
int flags)
254254
{
255255
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
257258
* LAST
258259
*/
259260
ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
@@ -284,7 +285,8 @@ static struct sha512_hash_ctx
284285
ctx->partial_block_buffer_length = 0;
285286
}
286287

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
288290
* submit
289291
*/
290292
ctx->error = HASH_CTX_ERROR_NONE;
@@ -293,7 +295,8 @@ static struct sha512_hash_ctx
293295
ctx->incoming_buffer = buffer;
294296
ctx->incoming_buffer_length = len;
295297

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
297300
* processed.
298301
*/
299302
ctx->status = (flags & HASH_LAST) ?
@@ -309,7 +312,7 @@ static struct sha512_hash_ctx
309312
* Or if the user's buffer contains less than a whole block,
310313
* append as much as possible to the extra block.
311314
*/
312-
if ((ctx->partial_block_buffer_length) | (len < SHA512_BLOCK_SIZE)) {
315+
if (ctx->partial_block_buffer_length || len < SHA512_BLOCK_SIZE) {
313316
/* Compute how many bytes to copy from user buffer into extra
314317
* block
315318
*/

0 commit comments

Comments
 (0)