Skip to contentSkip to conversation

target/ppc: Rename variables to avoid local variable shadowing in VUPKPX

PATCH Applied Cédric Le Goater 3 participants 3 messages Sep 29, 2023 – Oct 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/ppc: Rename variables to avoid local variable shadowing in VUPKPX

and fix such warnings :

../target/ppc/int_helper.c: In function ‘helper_vupklpx’:
../target/ppc/int_helper.c:2025:21: warning: declaration of ‘r’ shadows a parameter [-Wshadow=local]
2025 | uint8_t r = (e >> 10) & 0x1f; \
| ^
../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
2033 | VUPKPX(lpx, UPKLO)

        | ^~~~~~
  ../target/ppc/int_helper.c:2017:41: note: shadowed declaration is here
   2017 |     void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_t *b)                \
        |                              ~~~~~~~~~~~^
  ../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
   2033 | VUPKPX(lpx, UPKLO)
        | ^~~~~~

---

v2: changed all locals to start with '_' (Michael)

 target/ppc/int_helper.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
target/ppc/int_helper.c +6 -6
index 6fd00684a5b9..0a5c3e78a413 100644
@@ -2020,13 +2020,13 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
         ppc_avr_t result;                                               \
                                                                         \
         for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
-            uint16_t e = b->u16[hi ? i : i + 4];                        \
-            uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
-            uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint16_t _e = b->u16[hi ? i : i + 4];                       \
+            uint8_t _a = (_e >> 15) ? 0xff : 0;                         \
+            uint8_t _r = (_e >> 10) & 0x1f;                             \
+            uint8_t _g = (_e >> 5) & 0x1f;                              \
+            uint8_t _b = _e & 0x1f;                                     \
                                                                         \
-            result.u32[i] = (a << 24) | (r << 16) | (g << 8) | b;       \
+            result.u32[i] = (_a << 24) | (_r << 16) | (_g << 8) | _b;   \
         }                                                               \
         *r = result;                                                    \
     }
Signature · 1 line
2.41.0
Reviewed-by on v2 1/1
#1 lore raw

29.09.2023 11:31, Cédric Le Goater пишет:

Quoted 38 lines

and fix such warnings :

   ../target/ppc/int_helper.c: In function ‘helper_vupklpx’:
   ../target/ppc/int_helper.c:2025:21: warning: declaration of ‘r’ shadows a parameter [-Wshadow=local]
    2025 |             uint8_t r = (e >> 10) & 0x1f;                               \
         |                     ^
   ../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
    2033 | VUPKPX(lpx, UPKLO)
         | ^~~~~~
   ../target/ppc/int_helper.c:2017:41: note: shadowed declaration is here
    2017 |     void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_t *b)                \
         |                              ~~~~~~~~~~~^
   ../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
    2033 | VUPKPX(lpx, UPKLO)
         | ^~~~~~

---

v2: changed all locals to start with '_' (Michael)

  target/ppc/int_helper.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
target/ppc/int_helper.c +1 -5
index 6fd00684a5b9..0a5c3e78a413 100644
@@ -2020,13 +2020,13 @@ void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
          ppc_avr_t result;                                               \
                                                                          \
          for (i = 0; i < ARRAY_SIZE(r->u32); i++) {                      \
-            uint16_t e = b->u16[hi ? i : i + 4];                        \
-            uint8_t a = (e >> 15) ? 0xff : 0;                           \
-            uint8_t r = (e >> 10) & 0x1f;                               \
-            uint8_t g = (e >> 5) & 0x1f;                                \
-            uint8_t b = e & 0x1f;                                       \
+            uint16_t _e = b->u16[hi ? i : i + 4];                       \

target/ppc/int_helper.c void helper_vsum4ubs(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) · line 2032

Quoted 10 lines
target/ppc/int_helper.c +5 -1
+            uint8_t _a = (_e >> 15) ? 0xff : 0;                         \
+            uint8_t _r = (_e >> 10) & 0x1f;                             \
+            uint8_t _g = (_e >> 5) & 0x1f;                              \
+            uint8_t _b = _e & 0x1f;                                     \
                                                                          \
-            result.u32[i] = (a << 24) | (r << 16) | (g << 8) | b;       \
+            result.u32[i] = (_a << 24) | (_r << 16) | (_g << 8) | _b;   \
          }                                                               \
          *r = result;                                                    \
      }

/mjt

#2 lore raw
In reply to Cédric Le Goater
Quoted 16 lines · Cédric Le Goater

and fix such warnings :

../target/ppc/int_helper.c: In function ‘helper_vupklpx’:
../target/ppc/int_helper.c:2025:21: warning: declaration of ‘r’ shadows a parameter [-Wshadow=local]
2025 | uint8_t r = (e >> 10) & 0x1f; \
| ^
../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
2033 | VUPKPX(lpx, UPKLO)

        | ^~~~~~
  ../target/ppc/int_helper.c:2017:41: note: shadowed declaration is here
   2017 |     void helper_vupk##suffix(ppc_avr_t *r, ppc_avr_t *b)                \
        |                              ~~~~~~~~~~~^
  ../target/ppc/int_helper.c:2033:1: note: in expansion of macro ‘VUPKPX’
   2033 | VUPKPX(lpx, UPKLO)
        | ^~~~~~
Quoted 1 line

Queued. Thanks!