]> git.proxmox.com Git - mirror_qemu.git/commitdiff
Use ARRAY_SIZE macro
authorBlue Swirl <blauwirbel@gmail.com>
Fri, 20 Aug 2010 21:03:24 +0000 (21:03 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Fri, 20 Aug 2010 21:03:24 +0000 (21:03 +0000)
Replace array size calculations with ARRAY_SIZE macro.

Implemented with this Coccinelle semantic patch, adapted from
Linux kernel:
@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(*E))
+ ARRAY_SIZE(E)

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(E[...]))
+ ARRAY_SIZE(E)

@@
type T;
T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)

Some files (*-dis.c, tests/*) had to be filtered out.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
os-posix.c
target-i386/cpuid.c

index 00133a0c7658dd0efcbf9ee9561884662b2edb4b..6321e990c5fcce0a7b6c9b67def844ec21b6c60d 100644 (file)
@@ -110,7 +110,7 @@ char *os_find_datadir(const char *argv0)
         size_t len = sizeof(buf) - 1;
 
         *buf = '\0';
-        if (!sysctl(mib, sizeof(mib)/sizeof(*mib), buf, &len, NULL, 0) &&
+        if (!sysctl(mib, ARRAY_SIZE(mib), buf, &len, NULL, 0) &&
             *buf) {
             buf[sizeof(buf) - 1] = '\0';
             p = buf;
index dcfd81b7ac3c991d5c5c00e2afe778c9f22f807e..dade145807b2036647963e1f87114beb5e45705b 100644 (file)
@@ -543,7 +543,7 @@ static int check_features_against_host(x86_def_t *guest_def)
             ~CPUID_EXT3_SVM, ext3_feature_name, 0x80000001}};
 
     cpu_x86_fill_host(&host_def);
-    for (rv = 0, i = 0; i < sizeof (ft) / sizeof (ft[0]); ++i)
+    for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i)
         for (mask = 1; mask; mask <<= 1)
             if (ft[i].check_feat & mask && *ft[i].guest_feat & mask &&
                 !(*ft[i].host_feat & mask)) {