Silence bogus Coverity warning of uninitialized value
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 6 May 2017 18:54:33 +0000 (14:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 6 May 2017 19:55:05 +0000 (15:55 -0400)
Coverity complains that struct lttng_condition_comm's payload
field is not initialized. "payload" is a flexible array
member which should be ignored. Normally, a such a member
_could_ result in additional padding added at the end of the
structure. In this case, the structure is declared as packed.

Nonetheless, using a designated initializer gets rid of the
ambiguity and silences Coverity.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/condition.c

index 0b184422a69bf0b3f3b36f877d0522b1ce8d8ee7..ceab81eabbd81a6928a9b6122a6fdb117940a4b8 100644 (file)
@@ -66,14 +66,15 @@ ssize_t lttng_condition_serialize(const struct lttng_condition *condition,
                char *buf)
 {
        ssize_t ret, condition_size;
-       struct lttng_condition_comm condition_comm;
+       struct lttng_condition_comm condition_comm = {
+               .condition_type = (int8_t) condition->type
+       };
 
        if (!condition) {
                ret = -1;
                goto end;
        }
 
-       condition_comm.condition_type = (int8_t) condition->type;
        ret = sizeof(struct lttng_condition_comm);
        if (buf) {
                memcpy(buf, &condition_comm, ret);
This page took 0.025836 seconds and 4 git commands to generate.