[PATCH] crypto: Add spaces around operator

shiliyang posted 1 patch 3 years, 6 months ago
Test checkpatch failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/bb45d748-01e4-2fde-9fe3-32a7db4b64e7@huawei.com
Maintainers: "Daniel P. Berrangé" <berrange@redhat.com>
crypto/aes.c          | 6 +++---
crypto/desrfb.c       | 2 +-
crypto/tlscredsx509.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
[PATCH] crypto: Add spaces around operator
Posted by shiliyang 3 years, 6 months ago
I am reading crypto related code, find some code style problems while
using checkpatch.pl to check crypto folder. Fix the error style
problems.

Signed-off-by: Liyang Shi <shiliyang@huawei.com>

---
 crypto/aes.c          | 6 +++---
 crypto/desrfb.c       | 2 +-
 crypto/tlscredsx509.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/crypto/aes.c b/crypto/aes.c
index 159800df65..af72ff7779 100644
--- a/crypto/aes.c
+++ b/crypto/aes.c
@@ -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;
diff --git a/crypto/desrfb.c b/crypto/desrfb.c
index 3274c36510..14288fcf96 100644
--- a/crypto/desrfb.c
+++ b/crypto/desrfb.c
@@ -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);
diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c
index dd7267ccdb..c89dd62435 100644
--- a/crypto/tlscredsx509.c
+++ b/crypto/tlscredsx509.c
@@ -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",
-- 
2.17.1.windows.2


Re: [PATCH] crypto: Add spaces around operator
Posted by no-reply@patchew.org 3 years, 6 months ago
Patchew URL: https://patchew.org/QEMU/bb45d748-01e4-2fde-9fe3-32a7db4b64e7@huawei.com/



Hi,

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

Type: series
Message-id: bb45d748-01e4-2fde-9fe3-32a7db4b64e7@huawei.com
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/bb45d748-01e4-2fde-9fe3-32a7db4b64e7@huawei.com -> patchew/bb45d748-01e4-2fde-9fe3-32a7db4b64e7@huawei.com
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/bb45d748-01e4-2fde-9fe3-32a7db4b64e7@huawei.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com