qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <sw@weilnetz.de>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: qemu-trivial@nongnu.org, Stefan Weil <sw@weilnetz.de>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PATCH v2 1/5] misc: Use macro ARRAY_SIZE where possible
Date: Sat,  7 Dec 2013 14:48:04 +0100	[thread overview]
Message-ID: <1386424088-23196-2-git-send-email-sw@weilnetz.de> (raw)
In-Reply-To: <1386424088-23196-1-git-send-email-sw@weilnetz.de>

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

  reply	other threads:[~2013-12-07 13:48 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 ` Stefan Weil [this message]
2013-12-07 13:48 ` [Qemu-devel] [PATCH v2 2/5] ui/cocoa: Use macro ARRAY_SIZE where possible 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

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=1386424088-23196-2-git-send-email-sw@weilnetz.de \
    --to=sw@weilnetz.de \
    --cc=aliguori@amazon.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).