Cleanup: fix cppcheck warnings
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Oct 2012 22:31:11 +0000 (18:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Oct 2012 22:31:11 +0000 (18:31 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace-log.c
converter/babeltrace.c
formats/ctf-text/types/enum.c
formats/ctf/ctf.c
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
formats/ctf/types/float.c
types/float.c
types/types.c

index 9d87776a8f361ade58a7557215d99fe8a56916fd..8d425be65f9615882ae3ee6d240d1609eca751f2 100644 (file)
@@ -164,13 +164,14 @@ void write_event_header(struct ctf_stream_pos *pos, char *line,
                        uint64_t *ts)
 {
        unsigned long sec, usec;
-       int ret;
 
        if (!s_timestamp)
                return;
 
        /* Only need to be executed on first pass (dummy) */
        if (pos->dummy) {
+               int ret;
+
                /* Extract time from input line */
                ret = sscanf(line, "[%lu.%lu] ", &sec, &usec);
                if (ret == 2) {
@@ -201,21 +202,25 @@ void trace_string(char *line, struct ctf_stream_pos *pos, size_t len)
        uint64_t ts = 0;
 
        printf_debug("read: %s\n", line);
-retry:
-       ctf_dummy_pos(pos, &dummy);
-       write_event_header(&dummy, line, &tline, len, &tlen, &ts);
-       ctf_align_pos(&dummy, sizeof(uint8_t) * CHAR_BIT);
-       ctf_move_pos(&dummy, tlen * CHAR_BIT);
-       if (ctf_pos_packet(&dummy)) {
-               ctf_pos_pad_packet(pos);
-               write_packet_header(pos, s_uuid);
-               write_packet_context(pos);
-               if (attempt++ == 1) {
-                       fprintf(stderr, "[Error] Line too large for packet size (%" PRIu64 "kB) (discarded)\n",
-                               pos->packet_size / CHAR_BIT / 1024);
-                       return;
+
+       for (;;) {
+               ctf_dummy_pos(pos, &dummy);
+               write_event_header(&dummy, line, &tline, len, &tlen, &ts);
+               ctf_align_pos(&dummy, sizeof(uint8_t) * CHAR_BIT);
+               ctf_move_pos(&dummy, tlen * CHAR_BIT);
+               if (ctf_pos_packet(&dummy)) {
+                       ctf_pos_pad_packet(pos);
+                       write_packet_header(pos, s_uuid);
+                       write_packet_context(pos);
+                       if (attempt++ == 1) {
+                               fprintf(stderr, "[Error] Line too large for packet size (%" PRIu64 "kB) (discarded)\n",
+                                       pos->packet_size / CHAR_BIT / 1024);
+                               return;
+                       }
+                       continue;
+               } else {
+                       break;
                }
-               goto retry;
        }
 
        write_event_header(pos, line, &tline, len, &tlen, &ts);
index b24d0102fba72a7428be2f642ab22082ec687caf..d3fa02acf26cc7148e0e671d031aa927ea34dc8f 100644 (file)
@@ -459,7 +459,6 @@ int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
 
        GArray *trace_ids;
        int ret = 0;
-       int i;
 
        /* Should lock traversed_paths mutex here if used in multithread */
 
@@ -470,6 +469,8 @@ int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path,
 
        /* Process the array if ntfw did not return a fatal error */
        if (ret >= 0) {
+               int i;
+
                for (i = 0; i < traversed_paths->len; i++) {
                        GString *trace_path = g_ptr_array_index(traversed_paths,
                                                                i);
index b973d494b195dcd67d65931979b3d28dc06996a7..11529dd9bb9cf001dc87ecb460199f044bcc0bd8 100644 (file)
@@ -30,7 +30,7 @@ int ctf_text_enum_write(struct stream_pos *ppos, struct definition *definition)
                enum_definition->integer;
        struct ctf_text_stream_pos *pos = ctf_text_pos(ppos);
        GArray *qs;
-       int i, ret;
+       int ret;
        int field_nr_saved;
 
        if (!print_field(definition))
@@ -53,6 +53,8 @@ int ctf_text_enum_write(struct stream_pos *ppos, struct definition *definition)
        qs = enum_definition->value;
 
        if (qs) {
+               int i;
+
                for (i = 0; i < qs->len; i++) {
                        GQuark q = g_array_index(qs, GQuark, i);
                        const char *str = g_quark_to_string(q);
index 37e314849c611844065e0605ef7fa3dbfafabce9..8029512a2745876f9ce19e9ce1fab725fb64ddf7 100644 (file)
@@ -583,11 +583,11 @@ int ctf_init_pos(struct ctf_stream_pos *pos, int fd, int open_flags)
 
 int ctf_fini_pos(struct ctf_stream_pos *pos)
 {
-       int ret;
-
        if (pos->prot == PROT_WRITE && pos->content_size_loc)
                *pos->content_size_loc = pos->offset;
        if (pos->base_mma) {
+               int ret;
+
                /* unmap old base */
                ret = munmap_align(pos->base_mma);
                if (ret) {
@@ -1940,9 +1940,11 @@ static
 int ctf_close_trace(struct trace_descriptor *tdp)
 {
        struct ctf_trace *td = container_of(tdp, struct ctf_trace, parent);
-       int i, ret;
+       int ret;
 
        if (td->streams) {
+               int i;
+
                for (i = 0; i < td->streams->len; i++) {
                        struct ctf_stream_declaration *stream;
                        int j;
index 64c19677d346d0f34646ee9d00a1998b1bcc8833..7cc84953c1533f2ecab6604d953ebf9ab830a6a5 100644 (file)
@@ -890,7 +890,6 @@ struct declaration *ctf_declaration_variant_visit(FILE *fd,
        struct declaration_untagged_variant *untagged_variant_declaration;
        struct declaration_variant *variant_declaration;
        struct ctf_node *iter;
-       int ret;
 
        /*
         * For named variant (without body), lookup in
@@ -916,12 +915,16 @@ struct declaration *ctf_declaration_variant_visit(FILE *fd,
                }
                untagged_variant_declaration = untagged_variant_declaration_new(declaration_scope);
                bt_list_for_each_entry(iter, declaration_list, siblings) {
+                       int ret;
+
                        ret = ctf_variant_declaration_list_visit(fd, depth + 1, iter,
                                untagged_variant_declaration, trace);
                        if (ret)
                                goto error;
                }
                if (name) {
+                       int ret;
+
                        ret = register_variant_declaration(g_quark_from_string(name),
                                        untagged_variant_declaration,
                                        declaration_scope);
@@ -1051,7 +1054,6 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth,
        struct last_enum_value last_value;
        struct ctf_node *iter;
        GQuark dummy_id;
-       int ret;
 
        /*
         * For named enum (without body), lookup in
@@ -1107,12 +1109,16 @@ struct declaration *ctf_declaration_enum_visit(FILE *fd, int depth,
                        last_value.u.u = 0;
                }
                bt_list_for_each_entry(iter, enumerator_list, siblings) {
+                       int ret;
+
                        ret = ctf_enumerator_list_visit(fd, depth + 1, iter, enum_declaration,
                                        &last_value);
                        if (ret)
                                goto error;
                }
                if (name) {
+                       int ret;
+
                        ret = register_enum_declaration(g_quark_from_string(name),
                                        enum_declaration,
                                        declaration_scope);
@@ -2960,18 +2966,20 @@ error:
 
 int ctf_destroy_metadata(struct ctf_trace *trace)
 {
-       int i, j, k;
+       int i;
        struct ctf_file_stream *metadata_stream;
 
        if (trace->streams) {
                for (i = 0; i < trace->streams->len; i++) {
                        struct ctf_stream_declaration *stream;
+                       int j;
 
                        stream = g_ptr_array_index(trace->streams, i);
                        if (!stream)
                                continue;
                        for (j = 0; j < stream->streams->len; j++) {
                                struct ctf_stream_definition *stream_def;
+                               int k;
 
                                stream_def = g_ptr_array_index(stream->streams, j);
                                if (!stream_def)
index 0e4b9485607bfc83e16e347a70f01739c2aa92c5..782f72bfef514433303a9c232188e86bee4f4e80 100644 (file)
@@ -69,7 +69,7 @@ static struct declaration_float *static_float_declaration,
                *static_double_declaration;
 
 struct pos_len {
-       size_t sign_start, exp_start, mantissa_start, len;
+       size_t len;
 };
 
 static void float_lock(void)
index 3e49a4b1fbc7c2c995cb7adc490de0fe49d61d6b..b2ef65bc3ee21510deafcb3d63516ab0b2780e91 100644 (file)
@@ -83,7 +83,6 @@ struct definition *
                container_of(declaration, struct declaration_float, p);
        struct definition_float *_float;
        struct definition *tmp;
-       int ret;
 
        _float = g_new(struct definition_float, 1);
        declaration_ref(&float_declaration->p);
@@ -121,6 +120,8 @@ struct definition *
        _float->p.name = field_name;
        _float->value = 0.0;
        if (parent_scope) {
+               int ret;
+
                ret = register_field_definition(field_name, &_float->p,
                                                parent_scope);
                assert(!ret);
index f74e730f3df71e2531b27b54bff4dc1e45a2db7a..3ffe7e2f1b83d0e92efb5d2796f15406ccaf9b98 100644 (file)
@@ -117,10 +117,10 @@ static int compare_paths(GArray *a, GArray *b, int len)
 
 static int is_path_child_of(GArray *path, GArray *maybe_parent)
 {
-       int i, ret;
+       int ret;
 
        if (babeltrace_debug) {
-               int need_dot = 0;
+               int i, need_dot = 0;
 
                printf_debug("Is path \"");
                for (i = 0; i < path->len; need_dot = 1, i++)
@@ -497,7 +497,6 @@ GQuark new_definition_path(struct definition_scope *parent_scope,
        GQuark path;
        GString *str;
        gchar *c_str;
-       int i;
        int need_dot = 0;
 
        str = g_string_new("");
@@ -505,6 +504,8 @@ GQuark new_definition_path(struct definition_scope *parent_scope,
                g_string_append(str, root_name);
                need_dot = 1;
        } else if (parent_scope) {
+               int i;
+
                for (i = 0; i < parent_scope->scope_path->len; i++) {
                        GQuark q = g_array_index(parent_scope->scope_path,
                                                 GQuark, i);
This page took 0.029659 seconds and 5 git commands to generate.