Fix lint warnings
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 15 Nov 2013 00:40:57 +0000 (19:40 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 15 Nov 2013 02:02:11 +0000 (21:02 -0500)
** CID 1125105: Unchecked close() return value
formats/ctf/writer/stream.c: 521

** CID 1124085: Use after free
formats/ctf/writer/event-fields.c: 1128

** CID 1124088: Dereference before null check
formats/ctf/writer/stream.c: 371

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/writer/event-fields.c
formats/ctf/writer/stream.c

index 30fe5783db6e86a696b9ef96321ef9f233a7767b..ff970c0a86959fee1ce87ddcd2138dcb2b1b4c92 100644 (file)
@@ -1125,7 +1125,10 @@ int bt_ctf_field_structure_serialize(struct bt_ctf_field *field,
        while (!ctf_pos_access_ok(pos,
                offset_align(pos->offset,
                        field->type->declaration->alignment))) {
-               increase_packet_size(pos);
+               ret = increase_packet_size(pos);
+               if (ret) {
+                       goto end;
+               }
        }
 
        ctf_align_pos(pos, field->type->declaration->alignment);
@@ -1139,7 +1142,7 @@ int bt_ctf_field_structure_serialize(struct bt_ctf_field *field,
                        break;
                }
        }
-
+end:
        return ret;
 }
 
index f03f170d6a5ff7c09744149b4f4f2f9181eaa1f6..ac8942972ef71e71678b85f41e953f117eb1b9be 100644 (file)
@@ -368,7 +368,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
        int ret = 0;
        size_t i;
        uint64_t timestamp_begin, timestamp_end;
-       struct bt_ctf_stream_class *stream_class = stream->stream_class;
+       struct bt_ctf_stream_class *stream_class;
        struct bt_ctf_field *integer = NULL;
        struct ctf_stream_pos packet_context_pos;
 
@@ -385,6 +385,7 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
                stream->flush.func(stream, stream->flush.data);
        }
 
+       stream_class = stream->stream_class;
        timestamp_begin = ((struct bt_ctf_event *) g_ptr_array_index(
                stream->events, 0))->timestamp;
        timestamp_end = ((struct bt_ctf_event *) g_ptr_array_index(
@@ -518,7 +519,9 @@ void bt_ctf_stream_destroy(struct bt_ctf_ref *ref)
 
        stream = container_of(ref, struct bt_ctf_stream, ref_count);
        ctf_fini_pos(&stream->pos);
-       close(stream->pos.fd);
+       if (close(stream->pos.fd)) {
+               perror("close");
+       }
        bt_ctf_stream_class_put(stream->stream_class);
        g_ptr_array_free(stream->events, TRUE);
        g_free(stream);
This page took 0.030551 seconds and 4 git commands to generate.