From: Ivan Boule <ivan.bo...@6wind.com>

When a memory address must be read, for instance a [mapped] PCI register,
the read value is assigned to a local variable that is not used after,
as for instance:
    x = *((uint8_t *) mem_addr);

Such instructions do not compile with gcc 4.6.
The fix consists in adding the "volatile" attribute to the accessed data type
and to not assign the read value:
    *((volatile uint8_t *) mem_addr);

Acked-by: Olivier Matz <olivier.matz at 6wind.com>
Signed-off-by: Ivan Boule <ivan.boule at 6wind.com>
---
 app/test/test_memory.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/app/test/test_memory.c b/app/test/test_memory.c
index 8a25eca..96d35d9 100644
--- a/app/test/test_memory.c
+++ b/app/test/test_memory.c
@@ -61,7 +61,6 @@ test_memory(void)
        uint64_t s;
        unsigned i, j;
        const struct rte_memseg *mem;
-       volatile uint8_t x;

        /*
         * dump the mapped memory: the python-expect script checks
@@ -83,8 +82,7 @@ test_memory(void)

                /* check memory */
                for (j = 0; j<mem[i].len; j++) {
-                       x = *((uint8_t *) mem[i].addr + j);
-                       RTE_SET_USED(x);
+                       *((volatile uint8_t *) mem[i].addr + j);
                }
        }

-- 
1.7.2.5


Reply via email to