Skip to contentSkip to conversation

remove some variable shadowing

PATCH Applied Daniel P. Berrangé 3 participants 6 messages Sep 22, 2023 – Sep 29, 2023 Crypto API

lore
Share & tools
lore
#3 lore raw

PATCH 2/2 seccomp: avoid shadowing of 'action' variable

In reply to Daniel P. Berrangé

This is confusing as one 'action' variable is used for storing a SCMP_ enum value, while the other 'action' variable is used for storing a SECCOMP_ enum value.

---
 softmmu/qemu-seccomp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
softmmu/qemu-seccomp.c +2 -2
index d66a2a1226..4d7439e7f7 100644
@@ -283,9 +283,9 @@ static uint32_t qemu_seccomp_update_action(uint32_t action)
     if (action == SCMP_ACT_TRAP) {
         static int kill_process = -1;
         if (kill_process == -1) {
-            uint32_t action = SECCOMP_RET_KILL_PROCESS;
+            uint32_t testaction = SECCOMP_RET_KILL_PROCESS;
 
-            if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &action) == 0) {
+            if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &testaction) == 0) {
                 kill_process = 1;
             } else {
                 kill_process = 0;
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/2 crypto: remove shadowed 'ret' variable

In reply to Daniel P. Berrangé

Both instances of 'ret' are used to store a gnutls API return code.

---
 crypto/tls-cipher-suites.c | 1 -
 1 file changed, 1 deletion(-)
crypto/tls-cipher-suites.c +0 -1
index 5e4f597464..d0df4badc0 100644
@@ -52,7 +52,6 @@ GByteArray *qcrypto_tls_cipher_suites_get_data(QCryptoTLSCipherSuites *obj,
     byte_array = g_byte_array_new();
 
     for (i = 0;; i++) {
-        int ret;
         unsigned idx;
         const char *name;
         IANA_TLS_CIPHER cipher;
Signature · 1 line
2.41.0
#0 lore raw

cover remove some variable shadowing

Daniel P. Berrangé (2):
crypto: remove shadowed 'ret' variable
seccomp: avoid shadowing of 'action' variable

 crypto/tls-cipher-suites.c | 1 -
 softmmu/qemu-seccomp.c     | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] seccomp: avoid shadowing of 'action' variable

In reply to Daniel P. Berrangé
Quoted 15 lines · Daniel P. Berrangé

This is confusing as one 'action' variable is used for storing a SCMP_ enum value, while the other 'action' variable is used for storing a SECCOMP_ enum value.

---
 softmmu/qemu-seccomp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
softmmu/qemu-seccomp.c +0 -0
index d66a2a1226..4d7439e7f7 100644
@@ -283,9 +283,9 @@ static uint32_t qemu_seccomp_update_action(uint32_t action)
     if (action == SCMP_ACT_TRAP) {

softmmu/qemu-seccomp.c static uint32_t qemu_seccomp_update_action(uint32_t action) · line 291

Quoted 10 lines
softmmu/qemu-seccomp.c +2 -2
         static int kill_process = -1;
         if (kill_process == -1) {
-            uint32_t action = SECCOMP_RET_KILL_PROCESS;
+            uint32_t testaction = SECCOMP_RET_KILL_PROCESS;
 
-            if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &action) == 0) {
+            if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &testaction) == 0) {
                 kill_process = 1;
             } else {
                 kill_process = 0;

I'd prefer @test_action. Regardless: