Skip to contentSkip to conversation

crypto: Add spaces around operator

PATCH New shiliyang 2 participants 2 messages Nov 3, 2020 Crypto API

lore
Share & tools
lore

shiliyang

author
#0 lore raw

PATCH 1/1 crypto: Add spaces around operator

I am reading crypto related code, find some code style problems while using checkpatch.pl to check crypto folder. Fix the error style problems.

---
 crypto/aes.c          | 6 +++---
 crypto/desrfb.c       | 2 +-
 crypto/tlscredsx509.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
crypto/aes.c +3 -3
index 159800df65..af72ff7779 100644
@@ -1080,9 +1080,9 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
 
         rk = key->rd_key;
 
-        if (bits==128)
+        if (bits == 128)
                 key->rounds = 10;
-        else if (bits==192)
+        else if (bits == 192)
                 key->rounds = 12;
         else
                 key->rounds = 14;
@@ -1182,7 +1182,7 @@ int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
         rk = key->rd_key;
 
         /* invert the order of the round keys: */
-        for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
+        for (i = 0, j = 4 * (key->rounds); i < j; i += 4, j -= 4) {
                 temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;
                 temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
                 temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
crypto/desrfb.c +1 -1
index 3274c36510..14288fcf96 100644
@@ -93,7 +93,7 @@ void deskey(unsigned char *key, int edf)
                     }
                 for( j = 0; j < 24; j++ ) {
                         if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
-                        if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
+                        if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];
                         }
                 }
         cookey(kn);
crypto/tlscredsx509.c +1 -1
index dd7267ccdb..c89dd62435 100644
@@ -143,7 +143,7 @@ qcrypto_tls_creds_check_cert_key_usage(QCryptoTLSCredsX509 *creds,
     if (status < 0) {
         if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
             usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN :
-                GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT;
+                GNUTLS_KEY_DIGITAL_SIGNATURE | GNUTLS_KEY_KEY_ENCIPHERMENT;
         } else {
             error_setg(errp,
                        "Unable to query certificate %s key usage: %s",
Signature · 1 line
2.17.1.windows.2
#1 lore raw
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH] crypto: Add spaces around operator

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
53a011e crypto: Add spaces around operator

=== OUTPUT BEGIN ===
ERROR: braces {} are necessary for all arms of this statement #24: FILE: crypto/aes.c:1083:
+ if (bits == 128)
[...]
- else if (bits==192)
[...]

                 key->rounds = 12;

[...]

ERROR: braces {} are necessary for all arms of this statement #27: FILE: crypto/aes.c:1085:
+ else if (bits == 192)
[...]
else
[...]

ERROR: space prohibited after that open parenthesis '(' #49: FILE: crypto/desrfb.c:96:
+ if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];

ERROR: space prohibited before that close parenthesis ')' #49: FILE: crypto/desrfb.c:96:
+ if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];

ERROR: space required before the open parenthesis '(' #49: FILE: crypto/desrfb.c:96:
+ if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];

ERROR: trailing statements should be on next line
#49: FILE: crypto/desrfb.c:96:
+ if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];

ERROR: braces {} are necessary for all arms of this statement #49: FILE: crypto/desrfb.c:96:
+ if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];
[...]

total: 7 errors, 0 warnings, 35 lines checked

Commit 53a011edf848 (crypto: Add spaces around operator) has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]