Skip to contentSkip to conversation

Three trivial patchs

PATCH Applied Chen Qun 5 participants 13 messages Mar 25, 2020 – May 4, 2020 Crypto API

lore
Share & tools
lore

Chen Qun

author
#0 lore raw

cover Three trivial patchs

Patch1: For g_autofree type initialized.
Patch2: Juest 80-char limit for virtio-crypto.
Patch3: Redundant type conversion for crypto.

Chen Qun (3):
gdbstub: prevent uninitialized warning
virtio-crypto: fix 80-char limit violations in
virtio_crypto_device_realize()
crypto: Redundant type conversion for AES_KEY pointer

 crypto/cipher-builtin.c   | 6 ++----
 gdbstub.c                 | 4 ++--
 hw/virtio/virtio-crypto.c | 3 ++-
 3 files changed, 6 insertions(+), 7 deletions(-)
Signature · 1 line
2.23.0
author
#1 lore raw

PATCH 1/3 gdbstub: prevent uninitialized warning

According to the glib function requirements, we need initialise
the variable. Otherwise there will be compilation warnings:

qemu/gdbstub.c: In function ‘handle_query_thread_extra’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: warning:
‘cpu_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]
g_free (*pp);
^~~~~~~~~~~~

---
Cc: "Alex Bennée" <[email protected]>
Cc: "Philippe Mathieu-Daudé" <[email protected]>

---
 gdbstub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gdbstub.c +2 -2
index 013fb1ac0f..171e150950 100644
@@ -2060,8 +2060,8 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx)
         /* Print the CPU model and name in multiprocess mode */
         ObjectClass *oc = object_get_class(OBJECT(cpu));
         const char *cpu_model = object_class_get_name(oc);
-        g_autofree char *cpu_name;
-        cpu_name  = object_get_canonical_path_component(OBJECT(cpu));
+        g_autofree char *cpu_name =
+            object_get_canonical_path_component(OBJECT(cpu));
         g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name,
                         cpu->halted ? "halted " : "running");
     } else {
Signature · 1 line
2.23.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] gdbstub: prevent uninitialized warning

Quoted 38 lines · Chen Qun

According to the glib function requirements, we need initialise
the variable. Otherwise there will be compilation warnings:

qemu/gdbstub.c: In function ‘handle_query_thread_extra’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: warning:
‘cpu_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]

   g_free (*pp);
   ^~~~~~~~~~~~

---
Cc: "Alex Bennée" <[email protected]>
Cc: "Philippe Mathieu-Daudé" <[email protected]>

---
 gdbstub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gdbstub.c +2 -2
index 013fb1ac0f..171e150950 100644
@@ -2060,8 +2060,8 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx)
         /* Print the CPU model and name in multiprocess mode */
         ObjectClass *oc = object_get_class(OBJECT(cpu));
         const char *cpu_model = object_class_get_name(oc);
-        g_autofree char *cpu_name;
-        cpu_name  = object_get_canonical_path_component(OBJECT(cpu));
+        g_autofree char *cpu_name =
+            object_get_canonical_path_component(OBJECT(cpu));
         g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name,
                         cpu->halted ? "halted " : "running");
     } else {
Signature · 1 line
2.23.0

Fixing broken build with -Wall.

#3 lore raw

Re: [PATCH 1/3] gdbstub: prevent uninitialized warning

In reply to Chen Qun
Quoted 11 lines · Chen Qun

According to the glib function requirements, we need initialise
the variable. Otherwise there will be compilation warnings:

qemu/gdbstub.c: In function ‘handle_query_thread_extra’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: warning:
‘cpu_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]

   g_free (*pp);
   ^~~~~~~~~~~~

Thanks,

I've pulled in a duplicate fix from:

Message-Id: <[email protected]>

and added your Reported-by's

Quoted 22 lines

---
Cc: "Alex Bennée" <[email protected]>
Cc: "Philippe Mathieu-Daudé" <[email protected]>

---
 gdbstub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gdbstub.c +2 -2
index 013fb1ac0f..171e150950 100644
@@ -2060,8 +2060,8 @@ static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx)
         /* Print the CPU model and name in multiprocess mode */
         ObjectClass *oc = object_get_class(OBJECT(cpu));
         const char *cpu_model = object_class_get_name(oc);
-        g_autofree char *cpu_name;
-        cpu_name  = object_get_canonical_path_component(OBJECT(cpu));
+        g_autofree char *cpu_name =
+            object_get_canonical_path_component(OBJECT(cpu));
         g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name,
                         cpu->halted ? "halted " : "running");
     } else {
Signature · 1 line
Alex Bennée
#4 lore raw

RE: [PATCH 1/3] gdbstub: prevent uninitialized warning

Quoted 24 lines

-----Original Message-----
From: Alex Bennée [mailto:[email protected]]
Sent: Friday, March 27, 2020 5:13 PM
To: Chenqun (kuhn) <[email protected]>
Cc: [email protected]; [email protected]; Zhanghailiang <[email protected]>; [email protected]; Euler Robot <[email protected]>; Philippe Mathieu-Daudé <[email protected]>
Subject: Re: [PATCH 1/3] gdbstub: prevent uninitialized warning

Quoted 11 lines · Chen Qun

According to the glib function requirements, we need initialise
the variable. Otherwise there will be compilation warnings:

qemu/gdbstub.c: In function ‘handle_query_thread_extra’:
/usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: warning:
‘cpu_name’ may be used uninitialized in this function [-Wmaybe-uninitialized]

   g_free (*pp);
   ^~~~~~~~~~~~
Quoted 7 lines

Thanks,

I've pulled in a duplicate fix from:

Message-Id: <[email protected]>

and added your Reported-by's

OK, If possible, bring Miroslav Rezanina's "Reviewed-by" tag.

https://lists.gnu.org/archive/html/qemu-devel/2020-03/msg07651.html

Thanks.

Quoted 28 lines

gdbstub.c static void

Quoted 13 lines

---
Cc: "Alex Bennée" <[email protected]>
Cc: "Philippe Mathieu-Daudé" <[email protected]>

---
 gdbstub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gdbstub.c +0 -0
index 013fb1ac0f..171e150950 100644
@@ -2060,8 +2060,8 @@ static void

handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx)

gdbstub.c static void handle_query_thread_extra(GdbCmdContext *gdb_ctx, void *user_ctx) · line 2067

Quoted 10 lines
gdbstub.c +2 -2
         /* Print the CPU model and name in multiprocess mode */
         ObjectClass *oc = object_get_class(OBJECT(cpu));
         const char *cpu_model = object_class_get_name(oc);
-        g_autofree char *cpu_name;
-        cpu_name  = object_get_canonical_path_component(OBJECT(cpu));
+        g_autofree char *cpu_name =
+            object_get_canonical_path_component(OBJECT(cpu));
         g_string_printf(rs, "%s %s [%s]", cpu_model, cpu_name,
                         cpu->halted ? "halted " : "running");
     } else {

--
Alex Bennée

author
#5 lore raw

PATCH 2/3 virtio-crypto: fix 80-char limit violations in virtio_crypto_device_realize()

In reply to Chen Qun

Fix: aa8f057e74ae

---
 hw/virtio/virtio-crypto.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/virtio-crypto.c +2 -1
index 4c65114de5..eb4a9e4e85 100644
@@ -786,7 +786,8 @@ static void virtio_crypto_device_realize(DeviceState *dev, Error **errp)
         error_setg(errp, "'cryptodev' parameter expects a valid object");
         return;
     } else if (cryptodev_backend_is_used(vcrypto->cryptodev)) {
-        char *path = object_get_canonical_path_component(OBJECT(vcrypto->conf.cryptodev));
+        char *path = object_get_canonical_path_component(
+            OBJECT(vcrypto->conf.cryptodev));
         error_setg(errp, "can't use already used cryptodev backend: %s", path);
         g_free(path);
         return;
Signature · 1 line
2.23.0
author
#6 lore raw

PATCH 3/3 crypto: Redundant type conversion for AES_KEY pointer

In reply to Chen Qun

Fix: eaec903c5b8

---
Cc: "Daniel P. Berrangé" <[email protected]>

---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/cipher-builtin.c +2 -4
index bf8413e71a..99d6280a16 100644
@@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 
@@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }
 
 
Signature · 1 line
2.23.0
#7 lore raw

Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

Le 25/03/2020 à 10:21, Chen Qun a écrit :

Quoted 2 lines

Fix: eaec903c5b8

Did you run the coccinelle script scripts/coccinelle/typecast.cocci ?

Thanks,
Laurent

Quoted 33 lines

---
Cc: "Daniel P. Berrangé" <[email protected]>

---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/cipher-builtin.c +2 -4
index bf8413e71a..99d6280a16 100644
@@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 
@@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }
 
 
#8 lore raw

RE: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

Quoted 9 lines

-----Original Message-----
From: Laurent Vivier [mailto:[email protected]]
Sent: Wednesday, March 25, 2020 5:45 PM
To: Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Daniel P. Berrangé <[email protected]>
Subject: Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

Quoted 6 lines

Le 25/03/2020 à 10:21, Chen Qun a écrit :

Quoted 2 lines

Fix: eaec903c5b8

Did you run the coccinelle script scripts/coccinelle/typecast.cocci ?

Yes, I run it and plan to integrate it into EulerRobot so that similar issues can be discovered sooner.

Thanks.

Quoted 34 lines
Quoted 34 lines

---
Cc: "Daniel P. Berrangé" <[email protected]>

---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/cipher-builtin.c index renamed from crypto/cipher-builtin.c +0 -0

bf8413e71a..99d6280a16 100644

crypto/cipher-builtin.c +2 -4
@@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const
 void *ctx,  {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 
@@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const
 void *ctx,  {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }
 
 
Reviewed-by
#9 lore raw

Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

Le 25/03/2020 à 11:06, Chenqun (kuhn) a écrit :

Quoted 45 lines
Quoted 9 lines

-----Original Message-----
From: Laurent Vivier [mailto:[email protected]]
Sent: Wednesday, March 25, 2020 5:45 PM
To: Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Daniel P. Berrangé <[email protected]>
Subject: Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

Quoted 6 lines

Le 25/03/2020 à 10:21, Chen Qun a écrit :

Quoted 2 lines

Fix: eaec903c5b8

Did you run the coccinelle script scripts/coccinelle/typecast.cocci ?

Yes, I run it and plan to integrate it into EulerRobot so that similar issues can be discovered sooner.

Thanks.

Quoted 27 lines
Quoted 27 lines

---
Cc: "Daniel P. Berrangé" <[email protected]>

---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/cipher-builtin.c index renamed from crypto/cipher-builtin.c +0 -0

bf8413e71a..99d6280a16 100644

crypto/cipher-builtin.c +1 -2
@@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const
 void *ctx,  {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 
@@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const
 void *ctx,  {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
Quoted 8 lines
Quoted 7 lines

crypto/cipher-builtin.c static void qcrypto_cipher_aes_xts_decrypt(const void *ctx, · line 150

Quoted 7 lines
crypto/cipher-builtin.c +1 -2
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }
 
 
Acked-by on v1 3/3
#10 lore raw

Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

In reply to Chen Qun
Quoted 9 lines · Chen Qun

Fix: eaec903c5b8

---
Cc: "Daniel P. Berrangé" <[email protected]>

---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Quoted 29 lines
crypto/cipher-builtin.c +2 -4
index bf8413e71a..99d6280a16 100644
@@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 
@@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }
 
 
Signature · 1 line
2.23.0

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#11 lore raw

Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

In reply to Chen Qun

Le 25/03/2020 à 10:21, Chen Qun a écrit :

Quoted 26 lines

Fix: eaec903c5b8

---
Cc: "Daniel P. Berrangé" <[email protected]>

---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/cipher-builtin.c +1 -2
index bf8413e71a..99d6280a16 100644
@@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 

crypto/cipher-builtin.c static void qcrypto_cipher_aes_xts_decrypt(const void *ctx, · line 150

Quoted 9 lines
crypto/cipher-builtin.c +1 -2
@@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }
 
 

Applied to my trivial-patches-for-5.1 branch.

Thanks,
Laurent

#12 lore raw

Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer

Le 03/04/2020 à 10:47, Laurent Vivier a écrit :

Quoted 29 lines

Le 25/03/2020 à 10:21, Chen Qun a écrit :

Quoted 28 lines

Fix: eaec903c5b8

---
Cc: "Daniel P. Berrangé" <[email protected]>

---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/cipher-builtin.c +1 -2
index bf8413e71a..99d6280a16 100644
@@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 
@@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
Quoted 9 lines

crypto/cipher-builtin.c static void qcrypto_cipher_aes_xts_decrypt(const void *ctx, · line 150

Quoted 7 lines
crypto/cipher-builtin.c +1 -2
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }
 
 

Applied to my trivial-patches-for-5.1 branch.

Removed from the queue because of build errors:

https://travis-ci.com/github/vivier/qemu/jobs/327261040

In file included from /home/travis/build/vivier/qemu/crypto/cipher.c:157:0:
1251/home/travis/build/vivier/qemu/crypto/cipher-builtin.c: In function ‘qcrypto_cipher_aes_xts_encrypt’:
1252/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:136:36:
error: passing argument 1 of ‘qcrypto_cipher_aes_ecb_encrypt’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
1253 qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
1254 ^
1255/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:77:13: note:
expected ‘AES_KEY * {aka struct aes_key_st *}’ but argument is of type ‘const AES_KEY * {aka const struct aes_key_st *}’
1256 static void qcrypto_cipher_aes_ecb_encrypt(AES_KEY *key,
1257 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1258/home/travis/build/vivier/qemu/crypto/cipher-builtin.c: In function ‘qcrypto_cipher_aes_xts_decrypt’:
1259/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:147:36:
error: passing argument 1 of ‘qcrypto_cipher_aes_ecb_decrypt’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
1260 qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
1261 ^
1262/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:103:13: note:
expected ‘AES_KEY * {aka struct aes_key_st *}’ but argument is of type ‘const AES_KEY * {aka const struct aes_key_st *}’
1263 static void qcrypto_cipher_aes_ecb_decrypt(AES_KEY *key,
1264 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1265cc1: all warnings being treated as errors 1266/home/travis/build/vivier/qemu/rules.mak:69: recipe for target 'crypto/cipher.o' failed
1267make: *** [crypto/cipher.o] Error 1
1268make: *** Waiting for unfinished jobs....