json: Fix compile error on RHEL6
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 21 Apr 2020 19:17:12 +0000 (04:17 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 21 Apr 2020 19:50:18 +0000 (04:50 +0900)
eb2f29b7fd("Make the JSON code easier to analyze") doesn't compile
on RHEL6 using gcc4.x.

Using "{.object = val,}," for an union field seems to fix the issue,
but just use "arg.object = val;" instead as this is guaranteed to
compile on supported platforms.

--
    CC gettime.o
In file included from stat.h:7,
                 from thread_options.h:7,
                 from fio.h:18,
                 from gettime.c:7:
json.h: In function 'json_object_add_value_object':
json.h:95: error: unknown field 'object' specified in initializer
json.h:95: warning: missing braces around initializer
json.h:95: warning: (near initialization for 'arg.<anonymous>')
json.h:95: warning: initialization makes integer from pointer without a cast
make: *** [gettime.o] Error 1

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
json.h

diff --git a/json.h b/json.h
index b2bb457ea95c0b49f791a4bf6b220a0de7df85f7..1544ed765055f9c0e4aabb207b80dd0536bc43ec 100644 (file)
--- a/json.h
+++ b/json.h
@@ -92,9 +92,9 @@ static inline int json_object_add_value_object(struct json_object *obj,
 {
        struct json_value arg = {
                .type = JSON_TYPE_OBJECT,
-               .object = val,
        };
 
+       arg.object = val;
        return json_object_add_value_type(obj, name, &arg);
 }