qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] exec.c remove unnecessary operators on functions
@ 2009-02-20 18:11 Robert Reif
  2009-02-20 20:37 ` Robert Reif
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Reif @ 2009-02-20 18:11 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 232 bytes --]

This patch removes unnecessary *function and &function usage.

Also, why is it necessary to take the address of a variable holding a
function address rather than saving the function address directly
in exec.c lines 2766 and 2771?



[-- Attachment #2: exec.diff.txt --]
[-- Type: text/plain, Size: 1447 bytes --]

--- exec.c	(revision 6629)
+++ exec.c	(working copy)
@@ -2658,7 +2658,7 @@
     printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__,
            mmio, len, addr, idx);
 #endif
-    ret = (**mmio->mem_read[idx][len])(mmio->opaque[idx][0][len],
+    ret = (*mmio->mem_read[idx][len])(mmio->opaque[idx][0][len],
                                        addr + mmio->region_offset[idx][0][len]);
 
     return ret;
@@ -2674,7 +2674,7 @@
     printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d value %08x\n", __func__,
            mmio, len, addr, idx, value);
 #endif
-    (**mmio->mem_write[idx][len])(mmio->opaque[idx][1][len],
+    (*mmio->mem_write[idx][len])(mmio->opaque[idx][1][len],
                                   addr + mmio->region_offset[idx][1][len],
                                   value);
 }
@@ -2733,16 +2733,16 @@
     subpage_writelen(opaque, addr, value, 2);
 }
 
-static CPUReadMemoryFunc *subpage_read[] = {
-    &subpage_readb,
-    &subpage_readw,
-    &subpage_readl,
+static CPUReadMemoryFunc *subpage_read[3] = {
+    subpage_readb,
+    subpage_readw,
+    subpage_readl,
 };
 
-static CPUWriteMemoryFunc *subpage_write[] = {
-    &subpage_writeb,
-    &subpage_writew,
-    &subpage_writel,
+static CPUWriteMemoryFunc *subpage_write[3] = {
+    subpage_writeb,
+    subpage_writew,
+    subpage_writel,
 };
 
 static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] exec.c remove unnecessary operators on functions
  2009-02-20 18:11 [Qemu-devel] [PATCH] exec.c remove unnecessary operators on functions Robert Reif
@ 2009-02-20 20:37 ` Robert Reif
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Reif @ 2009-02-20 20:37 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

Robert Reif wrote:
>
> Also, why is it necessary to take the address of a variable holding a
> function address rather than saving the function address directly
> in exec.c lines 2766 and 2771?
>
>
This removes the extra level of indirection.  Comments?

[-- Attachment #2: subpage.diff.txt --]
[-- Type: text/plain, Size: 2655 bytes --]

--- exec.c	(revision 6629)
+++ exec.c	(working copy)
@@ -197,8 +197,8 @@
 #define SUBPAGE_IDX(addr) ((addr) & ~TARGET_PAGE_MASK)
 typedef struct subpage_t {
     target_phys_addr_t base;
-    CPUReadMemoryFunc **mem_read[TARGET_PAGE_SIZE][4];
-    CPUWriteMemoryFunc **mem_write[TARGET_PAGE_SIZE][4];
+    CPUReadMemoryFunc *mem_read[TARGET_PAGE_SIZE][4];
+    CPUWriteMemoryFunc *mem_write[TARGET_PAGE_SIZE][4];
     void *opaque[TARGET_PAGE_SIZE][2][4];
     ram_addr_t region_offset[TARGET_PAGE_SIZE][2][4];
 } subpage_t;
@@ -2658,7 +2658,7 @@
     printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d\n", __func__,
            mmio, len, addr, idx);
 #endif
-    ret = (**mmio->mem_read[idx][len])(mmio->opaque[idx][0][len],
+    ret = mmio->mem_read[idx][len](mmio->opaque[idx][0][len],
                                        addr + mmio->region_offset[idx][0][len]);
 
     return ret;
@@ -2674,7 +2674,7 @@
     printf("%s: subpage %p len %d addr " TARGET_FMT_plx " idx %d value %08x\n", __func__,
            mmio, len, addr, idx, value);
 #endif
-    (**mmio->mem_write[idx][len])(mmio->opaque[idx][1][len],
+    mmio->mem_write[idx][len](mmio->opaque[idx][1][len],
                                   addr + mmio->region_offset[idx][1][len],
                                   value);
 }
@@ -2733,16 +2733,16 @@
     subpage_writelen(opaque, addr, value, 2);
 }
 
-static CPUReadMemoryFunc *subpage_read[] = {
-    &subpage_readb,
-    &subpage_readw,
-    &subpage_readl,
+static CPUReadMemoryFunc *subpage_read[3] = {
+    subpage_readb,
+    subpage_readw,
+    subpage_readl,
 };
 
-static CPUWriteMemoryFunc *subpage_write[] = {
-    &subpage_writeb,
-    &subpage_writew,
-    &subpage_writel,
+static CPUWriteMemoryFunc *subpage_write[3] = {
+    subpage_writeb,
+    subpage_writew,
+    subpage_writel,
 };
 
 static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
@@ -2763,12 +2763,12 @@
     for (; idx <= eidx; idx++) {
         for (i = 0; i < 4; i++) {
             if (io_mem_read[memory][i]) {
-                mmio->mem_read[idx][i] = &io_mem_read[memory][i];
+                mmio->mem_read[idx][i] = io_mem_read[memory][i];
                 mmio->opaque[idx][0][i] = io_mem_opaque[memory];
                 mmio->region_offset[idx][0][i] = region_offset;
             }
             if (io_mem_write[memory][i]) {
-                mmio->mem_write[idx][i] = &io_mem_write[memory][i];
+                mmio->mem_write[idx][i] = io_mem_write[memory][i];
                 mmio->opaque[idx][1][i] = io_mem_opaque[memory];
                 mmio->region_offset[idx][1][i] = region_offset;
             }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-20 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-20 18:11 [Qemu-devel] [PATCH] exec.c remove unnecessary operators on functions Robert Reif
2009-02-20 20:37 ` Robert Reif

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).