]> Git Repo - qemu.git/commitdiff
misc: Use macro ARRAY_SIZE where possible
authorStefan Weil <[email protected]>
Sat, 7 Dec 2013 13:48:04 +0000 (14:48 +0100)
committerMichael Tokarev <[email protected]>
Mon, 23 Dec 2013 12:02:19 +0000 (16:02 +0400)
This improves readability and simplifies the code.

Cc: Anthony Liguori <[email protected]>
Cc: Gerd Hoffmann <[email protected]>
Cc: Stefan Hajnoczi <[email protected]>
Signed-off-by: Stefan Weil <[email protected]>
Reviewed-by: Peter Maydell <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
hw/audio/intel-hda.c
net/net.c
qemu-char.c

index 6ab8c245d3ecaf7044c95f47e47489d0c0ba6d6f..d41f82cec4db2dbad97ba8422b99362497487d93 100644 (file)
@@ -900,7 +900,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;
@@ -1025,7 +1025,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;
         }
index 9db88cc0ee19ad9628ff89aed097c23ae5e84a24..f8db85f30b41973b1973ff5d21020994a7292105 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -856,7 +856,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;
index 418dc69d398db5d9dd8b6c9f9b543e7dcf710c9f..30c5a6afd06c94442bef8bbb18e01391424f2e3d 100644 (file)
@@ -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 */
This page took 0.044884 seconds and 4 git commands to generate.