qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array)
@ 2013-12-07 13:48 Stefan Weil
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible Stefan Weil
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Stefan Weil @ 2013-12-07 13:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

These patches were previously sent as single patches instead of
a patch series. They all replace sizeof(array) / sizeof(*array)
by macros.

v2: Fix typos in commit messages (thanks to Peter Maydell).

[PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible
[PATCH v2 2/5] ui/cocoa: Use macro ARRAY_SIZE where possible
[PATCH v2 3/5] exynos4210: Use macro ARRAY_SIZE where possible
[PATCH v2 4/5] target-mips: Use macro ARRAY_SIZE where possible
[PATCH v2 5/5] linux-user: Use macro TARGET_NSIG_WORDS where possible

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible
  2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
@ 2013-12-07 13:48 ` Stefan Weil
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 2/5] ui/cocoa: " Stefan Weil
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Stefan Weil @ 2013-12-07 13:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Stefan Weil, Stefan Hajnoczi, Gerd Hoffmann,
	Anthony Liguori

This improves readability and simplifies the code.

Cc: Anthony Liguori <aliguori@amazon.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/audio/intel-hda.c |    4 ++--
 net/net.c            |    2 +-
 qemu-char.c          |    3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 4327264..8fe5d87 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -899,7 +899,7 @@ static const IntelHDAReg *intel_hda_reg_find(IntelHDAState *d, hwaddr addr)
 {
     const IntelHDAReg *reg;
 
-    if (addr >= sizeof(regtab)/sizeof(regtab[0])) {
+    if (addr >= ARRAY_SIZE(regtab)) {
         goto noreg;
     }
     reg = regtab+addr;
@@ -1024,7 +1024,7 @@ static void intel_hda_regs_reset(IntelHDAState *d)
     uint32_t *addr;
     int i;
 
-    for (i = 0; i < sizeof(regtab)/sizeof(regtab[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE(regtab); i++) {
         if (regtab[i].name == NULL) {
             continue;
         }
diff --git a/net/net.c b/net/net.c
index 0a88e68..d677606 100644
--- a/net/net.c
+++ b/net/net.c
@@ -850,7 +850,7 @@ static int net_host_check_device(const char *device)
                                        ,"vde"
 #endif
     };
-    for (i = 0; i < sizeof(valid_param_list) / sizeof(char *); i++) {
+    for (i = 0; i < ARRAY_SIZE(valid_param_list); i++) {
         if (!strncmp(valid_param_list[i], device,
                      strlen(valid_param_list[i])))
             return 1;
diff --git a/qemu-char.c b/qemu-char.c
index e00f84c..362a02d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1975,8 +1975,7 @@ static void win_stdio_wait_func(void *opaque)
     DWORD              dwSize;
     int                i;
 
-    ret = ReadConsoleInput(stdio->hStdIn, buf, sizeof(buf) / sizeof(*buf),
-                           &dwSize);
+    ret = ReadConsoleInput(stdio->hStdIn, buf, ARRAY_SIZE(buf), &dwSize);
 
     if (!ret) {
         /* Avoid error storm */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 2/5] ui/cocoa: Use macro ARRAY_SIZE where possible
  2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible Stefan Weil
@ 2013-12-07 13:48 ` Stefan Weil
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 3/5] exynos4210: " Stefan Weil
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Stefan Weil @ 2013-12-07 13:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Stefan Weil, Andreas Färber, Anthony Liguori

This improves readability and simplifies the code.

Cc: Andreas Färber <andreas.faerber@web.de>
Cc: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 ui/cocoa.m |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index be49179..2524f18 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -240,9 +240,8 @@ int keymap[] =
 
 static int cocoa_keycode_to_qemu(int keycode)
 {
-    if((sizeof(keymap)/sizeof(int)) <= keycode)
-    {
-        printf("(cocoa) warning unknow keycode 0x%x\n", keycode);
+    if (ARRAY_SIZE(keymap) <= keycode) {
+        printf("(cocoa) warning unknown keycode 0x%x\n", keycode);
         return 0;
     }
     return keymap[keycode];
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 3/5] exynos4210: Use macro ARRAY_SIZE where possible
  2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible Stefan Weil
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 2/5] ui/cocoa: " Stefan Weil
@ 2013-12-07 13:48 ` Stefan Weil
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 4/5] target-mips: " Stefan Weil
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Stefan Weil @ 2013-12-07 13:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Evgeny Voevodin, qemu-trivial, Stefan Weil, Igor Mitsyanko,
	Dmitry Solodkiy, Maksim Kozlov

This improves readability and simplifies the code.

Cc: Dmitry Solodkiy <d.solodkiy@samsung.com>
Cc: Evgeny Voevodin <e.voevodin@samsung.com>
Cc: Igor Mitsyanko <i.mitsyanko@gmail.com>
Cc: Maksim Kozlov <m.kozlov@samsung.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/char/exynos4210_uart.c |    6 ++----
 hw/misc/exynos4210_pmu.c  |    3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index eef23a0..19b59cc 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -192,10 +192,9 @@ typedef struct Exynos4210UartState {
 static const char *exynos4210_uart_regname(hwaddr  offset)
 {
 
-    int regs_number = sizeof(exynos4210_uart_regs) / sizeof(Exynos4210UartReg);
     int i;
 
-    for (i = 0; i < regs_number; i++) {
+    for (i = 0; i < ARRAY_SIZE(exynos4210_uart_regs); i++) {
         if (offset == exynos4210_uart_regs[i].offset) {
             return exynos4210_uart_regs[i].name;
         }
@@ -544,10 +543,9 @@ static void exynos4210_uart_event(void *opaque, int event)
 static void exynos4210_uart_reset(DeviceState *dev)
 {
     Exynos4210UartState *s = EXYNOS4210_UART(dev);
-    int regs_number = sizeof(exynos4210_uart_regs)/sizeof(Exynos4210UartReg);
     int i;
 
-    for (i = 0; i < regs_number; i++) {
+    for (i = 0; i < ARRAY_SIZE(exynos4210_uart_regs); i++) {
         s->reg[I_(exynos4210_uart_regs[i].offset)] =
                 exynos4210_uart_regs[i].reset_value;
     }
diff --git a/hw/misc/exynos4210_pmu.c b/hw/misc/exynos4210_pmu.c
index cbf0795..5ec14d1 100644
--- a/hw/misc/exynos4210_pmu.c
+++ b/hw/misc/exynos4210_pmu.c
@@ -383,8 +383,7 @@ static const Exynos4210PmuReg exynos4210_pmu_regs[] = {
     {"GPS_ALIVE_OPTION", GPS_ALIVE_OPTION, 0x00000001},
 };
 
-#define PMU_NUM_OF_REGISTERS     \
-    (sizeof(exynos4210_pmu_regs) / sizeof(Exynos4210PmuReg))
+#define PMU_NUM_OF_REGISTERS ARRAY_SIZE(exynos4210_pmu_regs)
 
 #define TYPE_EXYNOS4210_PMU "exynos4210.pmu"
 #define EXYNOS4210_PMU(obj) \
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 4/5] target-mips: Use macro ARRAY_SIZE where possible
  2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
                   ` (2 preceding siblings ...)
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 3/5] exynos4210: " Stefan Weil
@ 2013-12-07 13:48 ` Stefan Weil
  2013-12-09 15:58   ` Aurelien Jarno
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 5/5] linux-user: Use macro TARGET_NSIG_WORDS " Stefan Weil
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Stefan Weil @ 2013-12-07 13:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Aurelien Jarno

This improves readability and simplifies the code.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 target-mips/dsp_helper.c |   30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c
index b088a25..a2f46d9 100644
--- a/target-mips/dsp_helper.c
+++ b/target-mips/dsp_helper.c
@@ -1088,12 +1088,11 @@ static inline int32_t mipsdsp_cmpu_lt(uint32_t a, uint32_t b)
 target_ulong helper_##name(target_ulong rt, CPUMIPSState *env)             \
 {                                                                          \
     DSP32Value dt;                                                         \
-    unsigned int i, n;                                                     \
+    unsigned int i;                                                     \
                                                                            \
-    n = sizeof(DSP32Value) / sizeof(dt.element[0]);                        \
     dt.sw[0] = rt;                                                         \
                                                                            \
-    for (i = 0; i < n; i++) {                                              \
+    for (i = 0; i < ARRAY_SIZE(dt.element); i++) {                         \
         dt.element[i] = mipsdsp_##func(dt.element[i], env);                \
     }                                                                      \
                                                                            \
@@ -1109,12 +1108,11 @@ MIPSDSP32_UNOP_ENV(absq_s_w, sat_abs32, sw)
 target_ulong helper_##name(target_ulong rt, CPUMIPSState *env)             \
 {                                                                          \
     DSP64Value dt;                                                         \
-    unsigned int i, n;                                                     \
+    unsigned int i;                                                        \
                                                                            \
-    n = sizeof(DSP64Value) / sizeof(dt.element[0]);                        \
     dt.sl[0] = rt;                                                         \
                                                                            \
-    for (i = 0; i < n; i++) {                                              \
+    for (i = 0; i < ARRAY_SIZE(dt.element); i++) {                         \
         dt.element[i] = mipsdsp_##func(dt.element[i], env);                \
     }                                                                      \
                                                                            \
@@ -1130,13 +1128,12 @@ MIPSDSP64_UNOP_ENV(absq_s_pw, sat_abs32, sw)
 target_ulong helper_##name(target_ulong rs, target_ulong rt)               \
 {                                                                          \
     DSP32Value ds, dt;                                                     \
-    unsigned int i, n;                                                     \
+    unsigned int i;                                                        \
                                                                            \
-    n = sizeof(DSP32Value) / sizeof(ds.element[0]);                        \
     ds.sw[0] = rs;                                                         \
     dt.sw[0] = rt;                                                         \
                                                                            \
-    for (i = 0; i < n; i++) {                                              \
+    for (i = 0; i < ARRAY_SIZE(ds.element); i++) {                         \
         ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i]);      \
     }                                                                      \
                                                                            \
@@ -1159,13 +1156,12 @@ target_ulong helper_##name(target_ulong rs, target_ulong rt,               \
                            CPUMIPSState *env)                              \
 {                                                                          \
     DSP32Value ds, dt;                                                     \
-    unsigned int i, n;                                                     \
+    unsigned int i;                                                        \
                                                                            \
-    n = sizeof(DSP32Value) / sizeof(ds.element[0]);                        \
     ds.sw[0] = rs;                                                         \
     dt.sw[0] = rt;                                                         \
                                                                            \
-    for (i = 0 ; i < n ; i++) {                                            \
+    for (i = 0 ; i < ARRAY_SIZE(ds.element); i++) {                        \
         ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i], env); \
     }                                                                      \
                                                                            \
@@ -1192,13 +1188,12 @@ MIPSDSP32_BINOP_ENV(subu_s_qb, satu8_sub, ub);
 target_ulong helper_##name(target_ulong rs, target_ulong rt)               \
 {                                                                          \
     DSP64Value ds, dt;                                                     \
-    unsigned int i, n;                                                     \
+    unsigned int i;                                                        \
                                                                            \
-    n = sizeof(DSP64Value) / sizeof(ds.element[0]);                        \
     ds.sl[0] = rs;                                                         \
     dt.sl[0] = rt;                                                         \
                                                                            \
-    for (i = 0 ; i < n ; i++) {                                            \
+    for (i = 0 ; i < ARRAY_SIZE(ds.element); i++) {                        \
         ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i]);      \
     }                                                                      \
                                                                            \
@@ -1215,13 +1210,12 @@ target_ulong helper_##name(target_ulong rs, target_ulong rt,               \
                            CPUMIPSState *env)                              \
 {                                                                          \
     DSP64Value ds, dt;                                                     \
-    unsigned int i, n;                                                     \
+    unsigned int i;                                                        \
                                                                            \
-    n = sizeof(DSP64Value) / sizeof(ds.element[0]);                        \
     ds.sl[0] = rs;                                                         \
     dt.sl[0] = rt;                                                         \
                                                                            \
-    for (i = 0 ; i < n ; i++) {                                            \
+    for (i = 0 ; i < ARRAY_SIZE(ds.element); i++) {                        \
         ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i], env); \
     }                                                                      \
                                                                            \
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 5/5] linux-user: Use macro TARGET_NSIG_WORDS where possible
  2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
                   ` (3 preceding siblings ...)
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 4/5] target-mips: " Stefan Weil
@ 2013-12-07 13:48 ` Stefan Weil
  2013-12-07 16:41 ` [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Peter Maydell
  2013-12-07 19:00 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  6 siblings, 0 replies; 9+ messages in thread
From: Stefan Weil @ 2013-12-07 13:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Riku Voipio

This improves readability and simplifies the code.

Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 linux-user/signal.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 7751c47..8f692cd 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -2537,9 +2537,9 @@ void sparc64_set_context(CPUSPARCState *env)
             abi_ulong *src, *dst;
             src = ucp->tuc_sigmask.sig;
             dst = target_set.sig;
-            for (i = 0; i < sizeof(target_sigset_t) / sizeof(abi_ulong);
-                 i++, dst++, src++)
+            for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) {
                 err |= __get_user(*dst, src);
+            }
             if (err)
                 goto do_sigsegv;
         }
@@ -2642,9 +2642,9 @@ void sparc64_get_context(CPUSPARCState *env)
         abi_ulong *src, *dst;
         src = target_set.sig;
         dst = ucp->tuc_sigmask.sig;
-        for (i = 0; i < sizeof(target_sigset_t) / sizeof(abi_ulong);
-             i++, dst++, src++)
+        for (i = 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) {
             err |= __put_user(*src, dst);
+        }
         if (err)
             goto do_sigsegv;
     }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array)
  2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
                   ` (4 preceding siblings ...)
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 5/5] linux-user: Use macro TARGET_NSIG_WORDS " Stefan Weil
@ 2013-12-07 16:41 ` Peter Maydell
  2013-12-07 19:00 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  6 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2013-12-07 16:41 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Trivial, qemu-devel

On 7 December 2013 13:48, Stefan Weil <sw@weilnetz.de> wrote:
> These patches were previously sent as single patches instead of
> a patch series. They all replace sizeof(array) / sizeof(*array)
> by macros.
>
> v2: Fix typos in commit messages (thanks to Peter Maydell).

Whole series:
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array)
  2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
                   ` (5 preceding siblings ...)
  2013-12-07 16:41 ` [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Peter Maydell
@ 2013-12-07 19:00 ` Michael Tokarev
  6 siblings, 0 replies; 9+ messages in thread
From: Michael Tokarev @ 2013-12-07 19:00 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel

07.12.2013 17:48, Stefan Weil wrote:
> These patches were previously sent as single patches instead of
> a patch series. They all replace sizeof(array) / sizeof(*array)
> by macros.
> 
> v2: Fix typos in commit messages (thanks to Peter Maydell).

Applied to trivial-patches queue.

> [PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible
> [PATCH v2 2/5] ui/cocoa: Use macro ARRAY_SIZE where possible
> [PATCH v2 3/5] exynos4210: Use macro ARRAY_SIZE where possible
> [PATCH v2 4/5] target-mips: Use macro ARRAY_SIZE where possible

Especially this one is nice.  Original code was rather obscure,
copied into multiple places.

In this patch I fixed a minor formatting issue (uneven row of
backslashes in MIPSDSP32_UNOP_ENV macro definition).

> [PATCH v2 5/5] linux-user: Use macro TARGET_NSIG_WORDS where possible

All the changes appears to be fine and simple.

Stefan, at this rate, whole qemu-trivial becomes solely your baby.. ;)

Thanks!

/mjt

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v2 4/5] target-mips: Use macro ARRAY_SIZE where possible
  2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 4/5] target-mips: " Stefan Weil
@ 2013-12-09 15:58   ` Aurelien Jarno
  0 siblings, 0 replies; 9+ messages in thread
From: Aurelien Jarno @ 2013-12-09 15:58 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel

On Sat, Dec 07, 2013 at 02:48:07PM +0100, Stefan Weil wrote:
> This improves readability and simplifies the code.
> 
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  target-mips/dsp_helper.c |   30 ++++++++++++------------------
>  1 file changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c
> index b088a25..a2f46d9 100644
> --- a/target-mips/dsp_helper.c
> +++ b/target-mips/dsp_helper.c
> @@ -1088,12 +1088,11 @@ static inline int32_t mipsdsp_cmpu_lt(uint32_t a, uint32_t b)
>  target_ulong helper_##name(target_ulong rt, CPUMIPSState *env)             \
>  {                                                                          \
>      DSP32Value dt;                                                         \
> -    unsigned int i, n;                                                     \
> +    unsigned int i;                                                     \
>                                                                             \
> -    n = sizeof(DSP32Value) / sizeof(dt.element[0]);                        \
>      dt.sw[0] = rt;                                                         \
>                                                                             \
> -    for (i = 0; i < n; i++) {                                              \
> +    for (i = 0; i < ARRAY_SIZE(dt.element); i++) {                         \
>          dt.element[i] = mipsdsp_##func(dt.element[i], env);                \
>      }                                                                      \
>                                                                             \
> @@ -1109,12 +1108,11 @@ MIPSDSP32_UNOP_ENV(absq_s_w, sat_abs32, sw)
>  target_ulong helper_##name(target_ulong rt, CPUMIPSState *env)             \
>  {                                                                          \
>      DSP64Value dt;                                                         \
> -    unsigned int i, n;                                                     \
> +    unsigned int i;                                                        \
>                                                                             \
> -    n = sizeof(DSP64Value) / sizeof(dt.element[0]);                        \
>      dt.sl[0] = rt;                                                         \
>                                                                             \
> -    for (i = 0; i < n; i++) {                                              \
> +    for (i = 0; i < ARRAY_SIZE(dt.element); i++) {                         \
>          dt.element[i] = mipsdsp_##func(dt.element[i], env);                \
>      }                                                                      \
>                                                                             \
> @@ -1130,13 +1128,12 @@ MIPSDSP64_UNOP_ENV(absq_s_pw, sat_abs32, sw)
>  target_ulong helper_##name(target_ulong rs, target_ulong rt)               \
>  {                                                                          \
>      DSP32Value ds, dt;                                                     \
> -    unsigned int i, n;                                                     \
> +    unsigned int i;                                                        \
>                                                                             \
> -    n = sizeof(DSP32Value) / sizeof(ds.element[0]);                        \
>      ds.sw[0] = rs;                                                         \
>      dt.sw[0] = rt;                                                         \
>                                                                             \
> -    for (i = 0; i < n; i++) {                                              \
> +    for (i = 0; i < ARRAY_SIZE(ds.element); i++) {                         \
>          ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i]);      \
>      }                                                                      \
>                                                                             \
> @@ -1159,13 +1156,12 @@ target_ulong helper_##name(target_ulong rs, target_ulong rt,               \
>                             CPUMIPSState *env)                              \
>  {                                                                          \
>      DSP32Value ds, dt;                                                     \
> -    unsigned int i, n;                                                     \
> +    unsigned int i;                                                        \
>                                                                             \
> -    n = sizeof(DSP32Value) / sizeof(ds.element[0]);                        \
>      ds.sw[0] = rs;                                                         \
>      dt.sw[0] = rt;                                                         \
>                                                                             \
> -    for (i = 0 ; i < n ; i++) {                                            \
> +    for (i = 0 ; i < ARRAY_SIZE(ds.element); i++) {                        \
>          ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i], env); \
>      }                                                                      \
>                                                                             \
> @@ -1192,13 +1188,12 @@ MIPSDSP32_BINOP_ENV(subu_s_qb, satu8_sub, ub);
>  target_ulong helper_##name(target_ulong rs, target_ulong rt)               \
>  {                                                                          \
>      DSP64Value ds, dt;                                                     \
> -    unsigned int i, n;                                                     \
> +    unsigned int i;                                                        \
>                                                                             \
> -    n = sizeof(DSP64Value) / sizeof(ds.element[0]);                        \
>      ds.sl[0] = rs;                                                         \
>      dt.sl[0] = rt;                                                         \
>                                                                             \
> -    for (i = 0 ; i < n ; i++) {                                            \
> +    for (i = 0 ; i < ARRAY_SIZE(ds.element); i++) {                        \
>          ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i]);      \
>      }                                                                      \
>                                                                             \
> @@ -1215,13 +1210,12 @@ target_ulong helper_##name(target_ulong rs, target_ulong rt,               \
>                             CPUMIPSState *env)                              \
>  {                                                                          \
>      DSP64Value ds, dt;                                                     \
> -    unsigned int i, n;                                                     \
> +    unsigned int i;                                                        \
>                                                                             \
> -    n = sizeof(DSP64Value) / sizeof(ds.element[0]);                        \
>      ds.sl[0] = rs;                                                         \
>      dt.sl[0] = rt;                                                         \
>                                                                             \
> -    for (i = 0 ; i < n ; i++) {                                            \
> +    for (i = 0 ; i < ARRAY_SIZE(ds.element); i++) {                        \
>          ds.element[i] = mipsdsp_##func(ds.element[i], dt.element[i], env); \
>      }                                                                      \
>                                                                             \

Thanks, applied.


-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-12-09 15:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-07 13:48 [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Stefan Weil
2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible Stefan Weil
2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 2/5] ui/cocoa: " Stefan Weil
2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 3/5] exynos4210: " Stefan Weil
2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 4/5] target-mips: " Stefan Weil
2013-12-09 15:58   ` Aurelien Jarno
2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 5/5] linux-user: Use macro TARGET_NSIG_WORDS " Stefan Weil
2013-12-07 16:41 ` [Qemu-devel] [PATCH v2 0/5] Replace sizeof(array) / sizeof(*array) Peter Maydell
2013-12-07 19:00 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).