qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-trivial@nongnu.org, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2 4/5] target-mips: Use macro ARRAY_SIZE where possible
Date: Mon, 9 Dec 2013 16:58:55 +0100	[thread overview]
Message-ID: <20131209155855.GC5013@ohm.rr44.fr> (raw)
In-Reply-To: <1386424088-23196-5-git-send-email-sw@weilnetz.de>

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

  reply	other threads:[~2013-12-09 15:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131209155855.GC5013@ohm.rr44.fr \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).