cpu-op lib: Change code layout to remove gcc-4.8 warnings
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 23 Apr 2019 18:46:44 +0000 (14:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 23 Apr 2019 18:46:44 +0000 (14:46 -0400)
gcc-4.8 seems to mistakenly think there are missing field initializers
in the cpu-op.c code, e.g.:

cpu-op.c: In function ‘cpu_op_cmpxchg’:
cpu-op.c:94:4: warning: missing initializer for field ‘src’ of ‘struct <anonymous>’ [-Wmissing-field-initializers]
    .u.memcpy_op.src = (unsigned long)n,

Change the code layout so these warnings are not triggered.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/cpu-op.c

index 82e07b4f822a2e3b469f23b3730668968bdbb9f1..f85a3cb363654c90add096ff3fe340a0f79410e2 100644 (file)
@@ -70,26 +70,32 @@ int cpu_op_cmpxchg(void *v, void *expect, void *old, void *n, size_t len,
                [0] = {
                        .op = CPU_MEMCPY_OP,
                        .len = len,
-                       .u.memcpy_op.dst = (unsigned long)old,
-                       .u.memcpy_op.src = (unsigned long)v,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)old,
+                               .src = (unsigned long)v,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
                [1] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = len,
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [2] = {
                        .op = CPU_MEMCPY_OP,
                        .len = len,
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)n,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)n,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
        };
 
@@ -102,9 +108,11 @@ int cpu_op_add(void *v, int64_t count, size_t len, int cpu)
                [0] = {
                        .op = CPU_ADD_OP,
                        .len = len,
-                       .u.arithmetic_op.p = (unsigned long)v,
-                       .u.arithmetic_op.count = count,
-                       .u.arithmetic_op.expect_fault_p = 0,
+                       .u.arithmetic_op = {
+                               .p = (unsigned long)v,
+                               .count = count,
+                               .expect_fault_p = 0,
+                       },
                },
        };
 
@@ -118,18 +126,22 @@ int cpu_op_cmpeqv_storev(intptr_t *v, intptr_t expect, intptr_t newv,
                [0] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)&expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)&expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [1] = {
                        .op = CPU_MEMCPY_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)&newv,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)&newv,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
        };
 
@@ -143,19 +155,23 @@ static int cpu_op_cmpeqv_storep_expect_fault(intptr_t *v, intptr_t expect,
                [0] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)&expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)&expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [1] = {
                        .op = CPU_MEMCPY_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)newp,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       /* Return EAGAIN on src fault. */
-                       .u.memcpy_op.expect_fault_src = 1,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)newp,
+                               .expect_fault_dst = 0,
+                               /* Return EAGAIN on src fault. */
+                               .expect_fault_src = 1,
+                       },
                },
        };
 
@@ -191,26 +207,32 @@ int cpu_op_cmpeqv_storev_storev(intptr_t *v, intptr_t expect,
                [0] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)&expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)&expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [1] = {
                        .op = CPU_MEMCPY_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v2,
-                       .u.memcpy_op.src = (unsigned long)&newv2,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v2,
+                               .src = (unsigned long)&newv2,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
                [2] = {
                        .op = CPU_MEMCPY_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)&newv,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)&newv,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
        };
 
@@ -225,26 +247,32 @@ int cpu_op_cmpeqv_storev_mb_storev(intptr_t *v, intptr_t expect,
                [0] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)&expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)&expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+               },
                },
                [1] = {
                        .op = CPU_MEMCPY_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v2,
-                       .u.memcpy_op.src = (unsigned long)&newv2,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v2,
+                               .src = (unsigned long)&newv2,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
                [2] = {
                        .op = CPU_MEMCPY_RELEASE_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)&newv,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)&newv,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
        };
 
@@ -259,26 +287,32 @@ int cpu_op_cmpeqv_cmpeqv_storev(intptr_t *v, intptr_t expect,
                [0] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)&expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)&expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [1] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v2,
-                       .u.compare_op.b = (unsigned long)&expect2,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v2,
+                               .b = (unsigned long)&expect2,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [2] = {
                        .op = CPU_MEMCPY_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)&newv,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)&newv,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
        };
 
@@ -293,26 +327,32 @@ int cpu_op_cmpeqv_memcpy_storev(intptr_t *v, intptr_t expect,
                [0] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)&expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)&expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [1] = {
                        .op = CPU_MEMCPY_OP,
                        .len = len,
-                       .u.memcpy_op.dst = (unsigned long)dst,
-                       .u.memcpy_op.src = (unsigned long)src,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)dst,
+                               .src = (unsigned long)src,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
                [2] = {
                        .op = CPU_MEMCPY_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)&newv,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)&newv,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
        };
 
@@ -327,26 +367,32 @@ int cpu_op_cmpeqv_memcpy_mb_storev(intptr_t *v, intptr_t expect,
                [0] = {
                        .op = CPU_COMPARE_EQ_OP,
                        .len = sizeof(intptr_t),
-                       .u.compare_op.a = (unsigned long)v,
-                       .u.compare_op.b = (unsigned long)&expect,
-                       .u.compare_op.expect_fault_a = 0,
-                       .u.compare_op.expect_fault_b = 0,
+                       .u.compare_op = {
+                               .a = (unsigned long)v,
+                               .b = (unsigned long)&expect,
+                               .expect_fault_a = 0,
+                               .expect_fault_b = 0,
+                       },
                },
                [1] = {
                        .op = CPU_MEMCPY_OP,
                        .len = len,
-                       .u.memcpy_op.dst = (unsigned long)dst,
-                       .u.memcpy_op.src = (unsigned long)src,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)dst,
+                               .src = (unsigned long)src,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
                [2] = {
                        .op = CPU_MEMCPY_RELEASE_OP,
                        .len = sizeof(intptr_t),
-                       .u.memcpy_op.dst = (unsigned long)v,
-                       .u.memcpy_op.src = (unsigned long)&newv,
-                       .u.memcpy_op.expect_fault_dst = 0,
-                       .u.memcpy_op.expect_fault_src = 0,
+                       .u.memcpy_op = {
+                               .dst = (unsigned long)v,
+                               .src = (unsigned long)&newv,
+                               .expect_fault_dst = 0,
+                               .expect_fault_src = 0,
+                       },
                },
        };
 
This page took 0.034117 seconds and 4 git commands to generate.