* [Qemu-devel] [PATCH] misc: Use macro ARRAY_SIZE were possible
@ 2013-12-07 8:42 Stefan Weil
2013-12-07 9:04 ` Peter Maydell
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2013-12-07 8:42 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Stefan Weil, Stefan Hajnoczi, Gerd Hoffmann,
Anthony Liguori
This improves readability and simplifies the code.
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] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] misc: Use macro ARRAY_SIZE were possible
2013-12-07 8:42 [Qemu-devel] [PATCH] misc: Use macro ARRAY_SIZE were possible Stefan Weil
@ 2013-12-07 9:04 ` Peter Maydell
0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2013-12-07 9:04 UTC (permalink / raw)
To: Stefan Weil
Cc: QEMU Trivial, Anthony Liguori, qemu-devel, Stefan Hajnoczi,
Gerd Hoffmann
On 7 December 2013 08:42, Stefan Weil <sw@weilnetz.de> wrote:
> This improves readability and simplifies the code.
Typo in subject: should be "where", not "were" (ditto in the
other patches you've sent).
thanks
-- PMM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-07 9:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-07 8:42 [Qemu-devel] [PATCH] misc: Use macro ARRAY_SIZE were possible Stefan Weil
2013-12-07 9:04 ` Peter Maydell
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).