qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [6120] Use the ARRAY_SIZE() macro where appropriate.


From: malc
Subject: [Qemu-devel] [6120] Use the ARRAY_SIZE() macro where appropriate.
Date: Mon, 22 Dec 2008 20:33:55 +0000

Revision: 6120
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6120
Author:   malc
Date:     2008-12-22 20:33:55 +0000 (Mon, 22 Dec 2008)

Log Message:
-----------
Use the ARRAY_SIZE() macro where appropriate.

Change from v1:
  Avoid changing the existing coding style in certain files.

Signed-off-by: Stuart Brady <address@hidden>

Modified Paths:
--------------
    trunk/audio/audio.c
    trunk/audio/fmodaudio.c
    trunk/darwin-user/commpage.c
    trunk/darwin-user/syscall.c
    trunk/hw/ac97.c
    trunk/hw/dma.c
    trunk/hw/e1000.c
    trunk/hw/fdc.c
    trunk/hw/max7310.c
    trunk/hw/nseries.c
    trunk/hw/rc4030.c
    trunk/hw/sb16.c
    trunk/hw/sh_intc.c
    trunk/hw/sh_intc.h
    trunk/hw/sm501.c
    trunk/hw/usb-net.c
    trunk/hw/vmware_vga.c
    trunk/linux-user/strace.c
    trunk/target-cris/translate.c
    trunk/target-i386/helper.c
    trunk/target-mips/translate_init.c
    trunk/target-ppc/translate_init.c
    trunk/target-sh4/translate.c
    trunk/target-sparc/helper.c
    trunk/tcg/ppc/tcg-target.c
    trunk/tcg/ppc64/tcg-target.c
    trunk/vl.c

Modified: trunk/audio/audio.c
===================================================================
--- trunk/audio/audio.c 2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/audio/audio.c 2008-12-22 20:33:55 UTC (rev 6120)
@@ -1556,7 +1556,7 @@
     size_t i;
 
     audio_process_options ("AUDIO", audio_options);
-    for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
         struct audio_driver *d = drvtab[i];
         if (d->options) {
             audio_process_options (d->name, d->options);
@@ -1569,7 +1569,7 @@
 
     printf ("Available drivers:\n");
 
-    for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
         struct audio_driver *d = drvtab[i];
 
         printf ("Name: %s\n", d->name);
@@ -1746,7 +1746,7 @@
     if (drvname) {
         int found = 0;
 
-        for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+        for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
             if (!strcmp (drvname, drvtab[i]->name)) {
                 done = !audio_driver_init (s, drvtab[i]);
                 found = 1;
@@ -1761,7 +1761,7 @@
     }
 
     if (!done) {
-        for (i = 0; !done && i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+        for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) {
             if (drvtab[i]->can_be_default) {
                 done = !audio_driver_init (s, drvtab[i]);
             }

Modified: trunk/audio/fmodaudio.c
===================================================================
--- trunk/audio/fmodaudio.c     2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/audio/fmodaudio.c     2008-12-22 20:33:55 UTC (rev 6120)
@@ -564,7 +564,7 @@
 
     if (drv) {
         int found = 0;
-        for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+        for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
             if (!strcmp (drv, drvtab[i].name)) {
                 output_type = drvtab[i].type;
                 found = 1;
@@ -574,7 +574,7 @@
         if (!found) {
             dolog ("Unknown FMOD driver `%s'\n", drv);
             dolog ("Valid drivers:\n");
-            for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+            for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
                 dolog ("  %s\n", drvtab[i].name);
             }
         }

Modified: trunk/darwin-user/commpage.c
===================================================================
--- trunk/darwin-user/commpage.c        2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/darwin-user/commpage.c        2008-12-22 20:33:55 UTC (rev 6120)
@@ -191,7 +191,7 @@
 
     /* XXX: commpage data not handled */
 
-    for(i = 0; i < sizeof(commpage_entries)/sizeof(commpage_entries[0]); i++)
+    for(i = 0; i < ARRAY_SIZE(commpage_entries); i++)
         install_commpage_backdoor_for_entry(commpage_entries[i]);
 #else
     /* simply map our pages so they can be executed
@@ -329,7 +329,7 @@
 
     num = num-COMMPAGE_START-2;
 
-    for(i = 0; i < sizeof(commpage_entries)/sizeof(commpage_entries[0]); i++) {
+    for(i = 0; i < ARRAY_SIZE(commpage_entries); i++) {
         if( num == commpage_code_num(&commpage_entries[i]) )
         {
             DPRINTF("commpage: %s %s\n", commpage_entries[i].name, 
commpage_is_indirect(&commpage_entries[i]) ? "[indirect]" : "[direct]");

Modified: trunk/darwin-user/syscall.c
===================================================================
--- trunk/darwin-user/syscall.c 2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/darwin-user/syscall.c 2008-12-22 20:33:55 UTC (rev 6120)
@@ -135,7 +135,7 @@
         { 4241876,  "lu_message_reply_id" }, /* lookupd */
     };
 
-    for(i = 0; i < sizeof(msg_name)/sizeof(msg_name[0]); i++) {
+    for(i = 0; i < ARRAY_SIZE(msg_name); i++) {
         if(msg_name[i].number == hdr->msgh_id)
         {
             name = msg_name[i].name;
@@ -210,7 +210,7 @@
         DPRINTF("MACH_MSG_SUCCESS\n");
     else
     {
-        for( i = 0; i < sizeof(msg_name)/sizeof(msg_name[0]); i++) {
+        for( i = 0; i < ARRAY_SIZE(msg_name); i++) {
             if(msg_name[i].code == ret) {
                 DPRINTF("%s\n", msg_name[i].name);
                 found = 1;

Modified: trunk/hw/ac97.c
===================================================================
--- trunk/hw/ac97.c     2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/ac97.c     2008-12-22 20:33:55 UTC (rev 6120)
@@ -1196,7 +1196,7 @@
     qemu_put_be32s (f, &s->glob_sta);
     qemu_put_be32s (f, &s->cas);
 
-    for (i = 0; i < sizeof (s->bm_regs) / sizeof (s->bm_regs[0]); ++i) {
+    for (i = 0; i < ARRAY_SIZE (s->bm_regs); ++i) {
         AC97BusMasterRegs *r = &s->bm_regs[i];
         qemu_put_be32s (f, &r->bdbar);
         qemu_put_8s (f, &r->civ);
@@ -1235,7 +1235,7 @@
     qemu_get_be32s (f, &s->glob_sta);
     qemu_get_be32s (f, &s->cas);
 
-    for (i = 0; i < sizeof (s->bm_regs) / sizeof (s->bm_regs[0]); ++i) {
+    for (i = 0; i < ARRAY_SIZE (s->bm_regs); ++i) {
         AC97BusMasterRegs *r = &s->bm_regs[i];
         qemu_get_be32s (f, &r->bdbar);
         qemu_get_8s (f, &r->civ);

Modified: trunk/hw/dma.c
===================================================================
--- trunk/hw/dma.c      2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/dma.c      2008-12-22 20:33:55 UTC (rev 6120)
@@ -37,8 +37,6 @@
 #define ldebug(...)
 #endif
 
-#define LENOFA(a) ((int) (sizeof(a)/sizeof(a[0])))
-
 struct dma_regs {
     int now[2];
     uint16_t base[2];
@@ -479,7 +477,7 @@
         register_ioport_write (base + (i << dshift), 1, 1, write_chan, d);
         register_ioport_read (base + (i << dshift), 1, 1, read_chan, d);
     }
-    for (i = 0; i < LENOFA (page_port_list); i++) {
+    for (i = 0; i < ARRAY_SIZE (page_port_list); i++) {
         register_ioport_write (page_base + page_port_list[i], 1, 1,
                                write_page, d);
         register_ioport_read (page_base + page_port_list[i], 1, 1,
@@ -499,7 +497,7 @@
     }
     qemu_register_reset(dma_reset, d);
     dma_reset(d);
-    for (i = 0; i < LENOFA (d->regs); ++i) {
+    for (i = 0; i < ARRAY_SIZE (d->regs); ++i) {
         d->regs[i].transfer_handler = dma_phony_handler;
     }
 }

Modified: trunk/hw/e1000.c
===================================================================
--- trunk/hw/e1000.c    2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/e1000.c    2008-12-22 20:33:55 UTC (rev 6120)
@@ -763,7 +763,7 @@
     [MTA ... MTA+127] = &mac_readreg,
     [VFTA ... VFTA+127] = &mac_readreg,
 };
-enum { NREADOPS = sizeof(macreg_readops) / sizeof(*macreg_readops) };
+enum { NREADOPS = ARRAY_SIZE(macreg_readops) };
 
 #define putreg(x)      [x] = mac_writereg
 static void (*macreg_writeops[])(E1000State *, int, uint32_t) = {
@@ -779,7 +779,7 @@
     [MTA ... MTA+127] = &mac_writereg,
     [VFTA ... VFTA+127] = &mac_writereg,
 };
-enum { NWRITEOPS = sizeof(macreg_writeops) / sizeof(*macreg_writeops) };
+enum { NWRITEOPS = ARRAY_SIZE(macreg_writeops) };
 
 static void
 e1000_mmio_writel(void *opaque, target_phys_addr_t addr, uint32_t val)
@@ -854,13 +854,13 @@
     TDT,       TORH,   TORL,   TOTH,   TOTL,   TPR,    TPT,    TXDCTL, WUFC,
     VET,
 };
-enum { MAC_NSAVE = sizeof mac_regtosave/sizeof *mac_regtosave };
+enum { MAC_NSAVE = ARRAY_SIZE(mac_regtosave) };
 
 static const struct {
     int size;
     int array0;
 } mac_regarraystosave[] = { {32, RA}, {128, MTA}, {128, VFTA} };
-enum { MAC_NARRAYS = sizeof mac_regarraystosave/sizeof *mac_regarraystosave };
+enum { MAC_NARRAYS = ARRAY_SIZE(mac_regarraystosave) };
 
 static void
 nic_save(QEMUFile *f, void *opaque)

Modified: trunk/hw/fdc.c
===================================================================
--- trunk/hw/fdc.c      2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/fdc.c      2008-12-22 20:33:55 UTC (rev 6120)
@@ -1851,7 +1851,7 @@
     int i, j;
 
     /* Fill 'command_to_handler' lookup table */
-    for (i = sizeof(handlers)/sizeof(handlers[0]) - 1; i >= 0; i--) {
+    for (i = ARRAY_SIZE(handlers) - 1; i >= 0; i--) {
         for (j = 0; j < sizeof(command_to_handler); j++) {
             if ((j & handlers[i].mask) == handlers[i].value)
                 command_to_handler[j] = i;

Modified: trunk/hw/max7310.c
===================================================================
--- trunk/hw/max7310.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/max7310.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -180,7 +180,7 @@
 static void max7310_gpio_set(void *opaque, int line, int level)
 {
     struct max7310_s *s = (struct max7310_s *) opaque;
-    if (line >= sizeof(s->handler) / sizeof(*s->handler) || line  < 0)
+    if (line >= ARRAY_SIZE(s->handler) || line  < 0)
         hw_error("bad GPIO line");
 
     if (level)
@@ -199,7 +199,7 @@
     s->i2c.recv = max7310_rx;
     s->i2c.send = max7310_tx;
     s->gpio_in = qemu_allocate_irqs(max7310_gpio_set, s,
-                    sizeof(s->handler) / sizeof(*s->handler));
+                    ARRAY_SIZE(s->handler));
 
     max7310_reset(&s->i2c);
 
@@ -217,7 +217,7 @@
 void max7310_gpio_out_set(i2c_slave *i2c, int line, qemu_irq handler)
 {
     struct max7310_s *s = (struct max7310_s *) i2c;
-    if (line >= sizeof(s->handler) / sizeof(*s->handler) || line  < 0)
+    if (line >= ARRAY_SIZE(s->handler) || line  < 0)
         hw_error("bad GPIO line");
 
     s->handler[line] = handler;

Modified: trunk/hw/nseries.c
===================================================================
--- trunk/hw/nseries.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/nseries.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -432,7 +432,7 @@
         cpu_abort(cpu_single_env, "%s: FIXME: bad SPI word width %i\n",
                         __FUNCTION__, len);
 
-    if (s->p >= sizeof(s->resp) / sizeof(*s->resp))
+    if (s->p >= ARRAY_SIZE(s->resp))
         ret = 0;
     else
         ret = s->resp[s->p ++];
@@ -840,7 +840,7 @@
 
     /* OMAP STI console? Pin out settings? */
     ADD_TAG(0x6e01, 414);
-    for (i = 0; i < sizeof(n800_pinout) / 4; i ++)
+    for (i = 0; i < ARRAY_SIZE(n800_pinout); i ++)
         stl_raw(v ++, n800_pinout[i]);
 
     /* Kernel memsize? */

Modified: trunk/hw/rc4030.c
===================================================================
--- trunk/hw/rc4030.c   2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/rc4030.c   2008-12-22 20:33:55 UTC (rev 6120)
@@ -269,7 +269,7 @@
             static int current = 0;
             target_phys_addr_t dest = 0 + dests[current];
             uint8_t buf;
-            current = (current + 1) % (sizeof(dests)/sizeof(dests[0]));
+            current = (current + 1) % (ARRAY_SIZE(dests));
             buf = s->cache_bwin - 1;
             cpu_physical_memory_rw(dest, &buf, 1, 1);
         }
@@ -403,7 +403,7 @@
     if (s->isr_jazz != 0) {
         uint32_t irq = 0;
         printf("jazz pending:");
-        for (irq = 0; irq < sizeof(irq_names)/sizeof(irq_names[0]); irq++) {
+        for (irq = 0; irq < ARRAY_SIZE(irq_names); irq++) {
             if (s->isr_jazz & (1 << irq)) {
                 printf(" %s", irq_names[irq]);
                 if (!(s->imr_jazz & (1 << irq))) {

Modified: trunk/hw/sb16.c
===================================================================
--- trunk/hw/sb16.c     2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/sb16.c     2008-12-22 20:33:55 UTC (rev 6120)
@@ -27,8 +27,6 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
-#define LENOFA(a) ((int) (sizeof(a)/sizeof(a[0])))
-
 #define dolog(...) AUD_log ("sb16", __VA_ARGS__)
 
 /* #define DEBUG */
@@ -1440,11 +1438,11 @@
         dolog ("warning: Could not create auxiliary timer\n");
     }
 
-    for (i = 0; i < LENOFA (dsp_write_ports); i++) {
+    for (i = 0; i < ARRAY_SIZE (dsp_write_ports); i++) {
         register_ioport_write (s->port + dsp_write_ports[i], 1, 1, dsp_write, 
s);
     }
 
-    for (i = 0; i < LENOFA (dsp_read_ports); i++) {
+    for (i = 0; i < ARRAY_SIZE (dsp_read_ports); i++) {
         register_ioport_read (s->port + dsp_read_ports[i], 1, 1, dsp_read, s);
     }
 

Modified: trunk/hw/sh_intc.c
===================================================================
--- trunk/hw/sh_intc.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/sh_intc.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -17,7 +17,6 @@
 //#define DEBUG_INTC_SOURCES
 
 #define INTC_A7(x) ((x) & 0x1fffffff)
-#define INTC_ARRAY(x) (sizeof(x) / sizeof(x[0]))
 
 void sh_intc_toggle_source(struct intc_source *source,
                           int enable_adj, int assert_adj)
@@ -327,7 +326,7 @@
         for (i = 0; i < desc->nr_mask_regs; i++) {
            struct intc_mask_reg *mr = desc->mask_regs + i;
 
-           for (k = 0; k < INTC_ARRAY(mr->enum_ids); k++) {
+           for (k = 0; k < ARRAY_SIZE(mr->enum_ids); k++) {
                 if (mr->enum_ids[k] != source)
                     continue;
 
@@ -342,7 +341,7 @@
         for (i = 0; i < desc->nr_prio_regs; i++) {
            struct intc_prio_reg *pr = desc->prio_regs + i;
 
-           for (k = 0; k < INTC_ARRAY(pr->enum_ids); k++) {
+           for (k = 0; k < ARRAY_SIZE(pr->enum_ids); k++) {
                 if (pr->enum_ids[k] != source)
                     continue;
 
@@ -357,7 +356,7 @@
         for (i = 0; i < nr_groups; i++) {
            struct intc_group *gr = groups + i;
 
-           for (k = 0; k < INTC_ARRAY(gr->enum_ids); k++) {
+           for (k = 0; k < ARRAY_SIZE(gr->enum_ids); k++) {
                 if (gr->enum_ids[k] != source)
                     continue;
 
@@ -400,7 +399,7 @@
            s = sh_intc_source(desc, gr->enum_id);
            s->next_enum_id = gr->enum_ids[0];
 
-           for (k = 1; k < INTC_ARRAY(gr->enum_ids); k++) {
+           for (k = 1; k < ARRAY_SIZE(gr->enum_ids); k++) {
                 if (!gr->enum_ids[k])
                     continue;
 

Modified: trunk/hw/sh_intc.h
===================================================================
--- trunk/hw/sh_intc.h  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/sh_intc.h  2008-12-22 20:33:55 UTC (rev 6120)
@@ -32,7 +32,7 @@
     unsigned long value;
 };
 
-#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
+#define _INTC_ARRAY(a) a, ARRAY_SIZE(a)
 
 struct intc_source {
     unsigned short vect;

Modified: trunk/hw/sm501.c
===================================================================
--- trunk/hw/sm501.c    2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/sm501.c    2008-12-22 20:33:55 UTC (rev 6120)
@@ -514,7 +514,7 @@
     uint32_t norm_size = 0;
     int i, index = 0;
 
-    for (i = 0; i < sizeof(sm501_mem_local_size)/sizeof(uint32_t); i++) {
+    for (i = 0; i < ARRAY_SIZE(sm501_mem_local_size); i++) {
        uint32_t new_size = sm501_mem_local_size[i];
        if (new_size >= size) {
            if (norm_size == 0 || norm_size > new_size) {

Modified: trunk/hw/usb-net.c
===================================================================
--- trunk/hw/usb-net.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/usb-net.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -628,14 +628,13 @@
                       uint8_t *inbuf, unsigned int inlen, uint8_t *outbuf,
                       size_t outlen)
 {
-    unsigned int i, count;
+    unsigned int i;
 
     switch (oid) {
     /* general oids (table 4-1) */
     /* mandatory */
     case OID_GEN_SUPPORTED_LIST:
-        count = sizeof(oid_supported_list) / sizeof(uint32_t);
-        for (i = 0; i < count; i++)
+        for (i = 0; i < ARRAY_SIZE(oid_supported_list); i++)
             ((le32 *) outbuf)[i] = cpu_to_le32(oid_supported_list[i]);
         return sizeof(oid_supported_list);
 

Modified: trunk/hw/vmware_vga.c
===================================================================
--- trunk/hw/vmware_vga.c       2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/hw/vmware_vga.c       2008-12-22 20:33:55 UTC (rev 6120)
@@ -817,7 +817,7 @@
         s->guest = value;
 #ifdef VERBOSE
         if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE +
-                sizeof(vmsvga_guest_id) / sizeof(*vmsvga_guest_id))
+                ARRAY_SIZE(vmsvga_guest_id))
             printf("%s: guest runs %s.\n", __FUNCTION__,
                             vmsvga_guest_id[value - GUEST_OS_BASE]);
 #endif

Modified: trunk/linux-user/strace.c
===================================================================
--- trunk/linux-user/strace.c   2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/linux-user/strace.c   2008-12-22 20:33:55 UTC (rev 6120)
@@ -263,7 +263,7 @@
 #include "strace.list"
 };
 
-static int nsyscalls = sizeof(scnames)/sizeof(struct syscallname);
+static int nsyscalls = ARRAY_SIZE(scnames);
 
 /*
  * The public interface to this module.

Modified: trunk/target-cris/translate.c
===================================================================
--- trunk/target-cris/translate.c       2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/target-cris/translate.c       2008-12-22 20:33:55 UTC (rev 6120)
@@ -612,7 +612,7 @@
 
        tcg_gen_shli_tl(t, org_s,  bitrev[0].shift);
        tcg_gen_andi_tl(d, t,  bitrev[0].mask);
-       for (i = 1; i < sizeof bitrev / sizeof bitrev[0]; i++) {
+       for (i = 1; i < ARRAY_SIZE(bitrev); i++) {
                if (bitrev[i].shift >= 0) {
                        tcg_gen_shli_tl(t, org_s,  bitrev[i].shift);
                } else {
@@ -3158,7 +3158,7 @@
        dc->postinc  = EXTRACT_FIELD(dc->ir, 10, 10);
 
        /* Large switch for all insns.  */
-       for (i = 0; i < sizeof decinfo / sizeof decinfo[0]; i++) {
+       for (i = 0; i < ARRAY_SIZE(decinfo); i++) {
                if ((dc->opcode & decinfo[i].mask) == decinfo[i].bits)
                {
                        insn_len = decinfo[i].dec(dc);

Modified: trunk/target-i386/helper.c
===================================================================
--- trunk/target-i386/helper.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/target-i386/helper.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -274,7 +274,7 @@
     int family = -1, model = -1, stepping = -1;
 
     def = NULL;
-    for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++) {
+    for (i = 0; i < ARRAY_SIZE(x86_defs); i++) {
         if (strcmp(name, x86_defs[i].name) == 0) {
             def = &x86_defs[i];
             break;
@@ -364,7 +364,7 @@
 {
     unsigned int i;
 
-    for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++)
+    for (i = 0; i < ARRAY_SIZE(x86_defs); i++)
         (*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name);
 }
 

Modified: trunk/target-mips/translate_init.c
===================================================================
--- trunk/target-mips/translate_init.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/target-mips/translate_init.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -421,7 +421,7 @@
 {
     int i;
 
-    for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
         if (strcasecmp(name, mips_defs[i].name) == 0) {
             return &mips_defs[i];
         }
@@ -433,7 +433,7 @@
 {
     int i;
 
-    for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) {
+    for (i = 0; i < ARRAY_SIZE(mips_defs); i++) {
         (*cpu_fprintf)(f, "MIPS '%s'\n",
                        mips_defs[i].name);
     }

Modified: trunk/target-ppc/translate_init.c
===================================================================
--- trunk/target-ppc/translate_init.c   2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/target-ppc/translate_init.c   2008-12-22 20:33:55 UTC (rev 6120)
@@ -9455,7 +9455,7 @@
     int i, best, match, best_match, max;
 
     ret = NULL;
-    max = sizeof(ppc_defs) / sizeof(ppc_def_t);
+    max = ARRAY_SIZE(ppc_defs);
     best = -1;
     pvr_rev = pvr & 0xFFFF;
     /* We want all specified bits to match */
@@ -9510,7 +9510,7 @@
             return ppc_find_by_pvr(strtoul(name, NULL, 16));
     }
     ret = NULL;
-    max = sizeof(ppc_defs) / sizeof(ppc_def_t);
+    max = ARRAY_SIZE(ppc_defs);
     for (i = 0; i < max; i++) {
         if (strcasecmp(name, ppc_defs[i].name) == 0) {
             ret = &ppc_defs[i];
@@ -9525,7 +9525,7 @@
 {
     int i, max;
 
-    max = sizeof(ppc_defs) / sizeof(ppc_def_t);
+    max = ARRAY_SIZE(ppc_defs);
     for (i = 0; i < max; i++) {
         (*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n",
                        ppc_defs[i].name, ppc_defs[i].pvr);

Modified: trunk/target-sh4/translate.c
===================================================================
--- trunk/target-sh4/translate.c        2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/target-sh4/translate.c        2008-12-22 20:33:55 UTC (rev 6120)
@@ -240,7 +240,7 @@
     if (strcasecmp(name, "any") == 0)
        return &sh4_defs[0];
 
-    for (i = 0; i < sizeof(sh4_defs) / sizeof(*sh4_defs); i++)
+    for (i = 0; i < ARRAY_SIZE(sh4_defs); i++)
        if (strcasecmp(name, sh4_defs[i].name) == 0)
            return &sh4_defs[i];
 
@@ -251,7 +251,7 @@
 {
     int i;
 
-    for (i = 0; i < sizeof(sh4_defs) / sizeof(*sh4_defs); i++)
+    for (i = 0; i < ARRAY_SIZE(sh4_defs); i++)
        (*cpu_fprintf)(f, "%s\n", sh4_defs[i].name);
 }
 

Modified: trunk/target-sparc/helper.c
===================================================================
--- trunk/target-sparc/helper.c 2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/target-sparc/helper.c 2008-12-22 20:33:55 UTC (rev 6120)
@@ -1240,7 +1240,7 @@
     long long iu_version;
     uint32_t fpu_version, mmu_version, nwindows;
 
-    for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) {
+    for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {
         if (strcasecmp(name, sparc_defs[i].name) == 0) {
             def = &sparc_defs[i];
         }
@@ -1336,7 +1336,7 @@
 {
     unsigned int i;
 
-    for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) {
+    for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {
         (*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx " FPU %08x MMU %08x 
NWINS %d ",
                        sparc_defs[i].name,
                        sparc_defs[i].iu_version,

Modified: trunk/tcg/ppc/tcg-target.c
===================================================================
--- trunk/tcg/ppc/tcg-target.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/tcg/ppc/tcg-target.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -212,7 +212,7 @@
 /* maximum number of register used for input function arguments */
 static int tcg_target_get_call_iarg_regs_count(int flags)
 {
-    return sizeof (tcg_target_call_iarg_regs) / sizeof 
(tcg_target_call_iarg_regs[0]);
+    return ARRAY_SIZE (tcg_target_call_iarg_regs);
 }
 
 /* parse target specific constraints */

Modified: trunk/tcg/ppc64/tcg-target.c
===================================================================
--- trunk/tcg/ppc64/tcg-target.c        2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/tcg/ppc64/tcg-target.c        2008-12-22 20:33:55 UTC (rev 6120)
@@ -199,7 +199,7 @@
 /* maximum number of register used for input function arguments */
 static int tcg_target_get_call_iarg_regs_count (int flags)
 {
-    return sizeof (tcg_target_call_iarg_regs) / sizeof 
(tcg_target_call_iarg_regs[0]);
+    return ARRAY_SIZE (tcg_target_call_iarg_regs);
 }
 
 /* parse target specific constraints */

Modified: trunk/vl.c
===================================================================
--- trunk/vl.c  2008-12-21 16:00:20 UTC (rev 6119)
+++ trunk/vl.c  2008-12-22 20:33:55 UTC (rev 6120)
@@ -1048,7 +1048,7 @@
 {
     int i;
     int cur = 0;
-    int count = (sizeof(alarm_timers) / sizeof(*alarm_timers)) - 1;
+    int count = ARRAY_SIZE(alarm_timers) - 1;
     char *arg;
     char *name;
     struct qemu_alarm_timer tmp;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]