From 00e74b693f28b3f543d8ec18ae631abab8023d5c Mon Sep 17 00:00:00 2001 From: compudj Date: Mon, 9 Aug 2004 01:31:58 +0000 Subject: [PATCH] uninitialized variables checked, plus O2 optimisations checked : strict aliasing corrected git-svn-id: http://ltt.polymtl.ca/svn@685 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/attribute.c | 16 ++++---- ltt/branches/poly/lttv/lttv/batchtest.c | 37 ++++++++++------- ltt/branches/poly/lttv/lttv/main.c | 7 ++-- ltt/branches/poly/lttv/lttv/module.c | 16 ++++---- ltt/branches/poly/lttv/lttv/option.c | 28 +++++-------- ltt/branches/poly/lttv/lttv/state.c | 34 ++++++++------- ltt/branches/poly/lttv/lttv/state.h | 3 +- ltt/branches/poly/lttv/lttv/stats.c | 47 ++++++++++++--------- ltt/branches/poly/lttv/lttv/stats.h | 8 ++-- ltt/branches/poly/lttv/lttv/tracecontext.c | 48 +++++++++------------- ltt/branches/poly/lttv/lttv/tracecontext.h | 3 ++ ltt/branches/poly/lttv/lttv/traceset.c | 2 +- 12 files changed, 132 insertions(+), 117 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/attribute.c b/ltt/branches/poly/lttv/lttv/attribute.c index 0eef75b8..a0d30704 100644 --- a/ltt/branches/poly/lttv/lttv/attribute.c +++ b/ltt/branches/poly/lttv/lttv/attribute.c @@ -16,6 +16,7 @@ * MA 02111-1307, USA. */ +#include #include #include @@ -55,6 +56,7 @@ LttvAttributeValue address_of_value(LttvAttributeType t, AttributeValue *v) case LTTV_POINTER: va.v_pointer = &v->dv_pointer; break; case LTTV_STRING: va.v_string = &v->dv_string; break; case LTTV_GOBJECT: va.v_gobject = &v->dv_gobject; break; + case LTTV_NONE: break; } return va; } @@ -75,6 +77,7 @@ AttributeValue init_value(LttvAttributeType t) case LTTV_POINTER: v.dv_pointer = NULL; break; case LTTV_STRING: v.dv_string = NULL; break; case LTTV_GOBJECT: v.dv_gobject = NULL; break; + case LTTV_NONE: break; } return v; } @@ -360,7 +363,7 @@ lttv_attribute_write_xml(LttvAttribute *self, FILE *fp, int pos, int indent) fprintf(fp, "TYPE=DOUBLE VALUE=%f/>\n", a->value.dv_double); break; case LTTV_TIME: - fprintf(fp, "TYPE=TIME SEC=%u NSEC=%u/>\n", a->value.dv_time.tv_sec, + fprintf(fp, "TYPE=TIME SEC=%lu NSEC=%lu/>\n", a->value.dv_time.tv_sec, a->value.dv_time.tv_nsec); break; case LTTV_POINTER: @@ -386,9 +389,7 @@ lttv_attribute_write_xml(LttvAttribute *self, FILE *fp, int pos, int indent) void lttv_attribute_read_xml(LttvAttribute *self, FILE *fp) { - int i, nb, res; - - Attribute *a; + int res; char buffer[256], type[10]; @@ -437,12 +438,12 @@ lttv_attribute_read_xml(LttvAttribute *self, FILE *fp) } else if(strcmp(type, "DOUBLE") == 0) { value = lttv_attribute_add(self, name, LTTV_DOUBLE); - res = fscanf(fp, " VALUE=%f/>", value.v_double); + res = fscanf(fp, " VALUE=%lf/>", value.v_double); g_assert(res == 1); } else if(strcmp(type, "TIME") == 0) { value = lttv_attribute_add(self, name, LTTV_TIME); - res = fscanf(fp, " SEC=%u NSEC=%u/>", &(value.v_time->tv_sec), + res = fscanf(fp, " SEC=%lu NSEC=%lu/>", &(value.v_time->tv_sec), &(value.v_time->tv_nsec)); g_assert(res == 2); } @@ -560,7 +561,8 @@ lttv_attribute_get_type (void) NULL, /* class_data */ sizeof (LttvAttribute), 0, /* n_preallocs */ - (GInstanceInitFunc) attribute_instance_init /* instance_init */ + (GInstanceInitFunc) attribute_instance_init, /* instance_init */ + NULL /* value handling */ }; static const GInterfaceInfo iattribute_info = { diff --git a/ltt/branches/poly/lttv/lttv/batchtest.c b/ltt/branches/poly/lttv/lttv/batchtest.c index 08922fd7..ab50262c 100644 --- a/ltt/branches/poly/lttv/lttv/batchtest.c +++ b/ltt/branches/poly/lttv/lttv/batchtest.c @@ -19,7 +19,7 @@ /* This module inserts a hook in the program main loop. This hook processes all the events in the main tracefile while testing the speed and functionality of the state and stats computations. */ - +#include #include #include @@ -32,6 +32,9 @@ #include #include #include +#include + +#define __UNUSED__ __attribute__((__unused__)) static LttvTraceset *traceset; @@ -84,7 +87,7 @@ typedef struct _save_state { } SaveState; -static void lttv_trace_option(void *hook_data) +static void lttv_trace_option(void __UNUSED__ *hook_data) { LttTrace *trace; @@ -105,7 +108,7 @@ static double run_one_test(LttvTracesetState *ts, LttTime start, LttTime end) { double t0, t1; - int i; + unsigned int i; //lttv_traceset_context_add_hooks(&ts->parent, //before_traceset, after_traceset, NULL, before_trace, after_trace, @@ -144,7 +147,7 @@ static double run_one_test(LttvTracesetState *ts, LttTime start, LttTime end) } -gboolean trace_event(void *hook_data, void *call_data) +gboolean trace_event(void __UNUSED__ *hook_data, void *call_data) { LttvTracefileState *tfs = (LttvTracefileState *)call_data; @@ -154,7 +157,7 @@ gboolean trace_event(void *hook_data, void *call_data) ltt_event_position(tfs->parent.e, a_event_position); ltt_event_position_get(a_event_position, &nb_block, &nb_event, &tf); - fprintf(stderr,"Event %s %lu.%09lu [%lu %lu]\n", + fprintf(stderr,"Event %s %lu.%09lu [%u %u]\n", ltt_eventtype_name(ltt_event_eventtype(tfs->parent.e)), tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec, nb_block, nb_event); @@ -162,7 +165,7 @@ gboolean trace_event(void *hook_data, void *call_data) } -gboolean count_event(void *hook_data, void *call_data) +gboolean count_event(void *hook_data, void __UNUSED__ *call_data) { guint *pcount = (guint *)hook_data; @@ -173,7 +176,7 @@ gboolean count_event(void *hook_data, void *call_data) gboolean save_state_copy_event(void *hook_data, void *call_data) { - SaveState *save_state = (SaveState *)hook_data; + SaveState __UNUSED__ *save_state = (SaveState *)hook_data; LttvTracefileState *tfs = (LttvTracefileState *)call_data; @@ -233,7 +236,8 @@ gboolean save_state_event(void *hook_data, void *call_data) } -static gboolean process_traceset(void *hook_data, void *call_data) +static gboolean process_traceset(void __UNUSED__ *hook_data, + void __UNUSED__ *call_data) { LttvTracesetStats *tscs; @@ -257,13 +261,14 @@ static gboolean process_traceset(void *hook_data, void *call_data) LttFacility *facility; - LttType *type; - LttEventType *event_type; LttTime time, previous_time; - long long unsigned cycle_count, start_count, delta_cycle; + /* start_count is always initialized in this function _if_ there is always + * a block_start before a block_end. + */ + long long unsigned cycle_count, start_count=0, delta_cycle; long long unsigned start_nsec, end_nsec, delta_nsec, added_nsec, added_nsec2; @@ -505,10 +510,11 @@ static gboolean process_traceset(void *hook_data, void *call_data) /* Seek a few times to each saved position */ if((a_test7 && a_test3) || a_test_all) { - int i, j; - - for(i = 0 ; i < a_seek_number ; i++) { - for(j = save_state.position - 1 ; j >= 0 ; j--) { + g_assert(a_seek_number >= 0); + for(i = 0 ; i < (guint)a_seek_number ; i++) { + gint reverse_j; /* just to make sure j is unsigned */ + for(reverse_j = save_state.position - 1 ; reverse_j >= 0 ; reverse_j--) { + j = (guint)reverse_j; lttv_state_add_event_hooks(ts); t = run_one_test(ts, save_state.write_time[j], save_state.write_time[j]); @@ -547,6 +553,7 @@ static gboolean process_traceset(void *hook_data, void *call_data) } g_info("BatchTest end process traceset"); + return 0; } diff --git a/ltt/branches/poly/lttv/lttv/main.c b/ltt/branches/poly/lttv/lttv/main.c index f984df14..16c0126f 100644 --- a/ltt/branches/poly/lttv/lttv/main.c +++ b/ltt/branches/poly/lttv/lttv/main.c @@ -26,6 +26,7 @@ #include #include #include +#include /* The main program maintains a few central data structures and relies @@ -147,9 +148,9 @@ int main(int argc, char **argv) { GError *error = NULL; LttvModule *module_module = lttv_module_require("module", &error); - if(error != NULL) g_error(error->message); + if(error != NULL) g_error("%s", error->message); LttvModule *module_option = lttv_module_require("option", &error); - if(error != NULL) g_error(error->message); + if(error != NULL) g_error("%s", error->message); /* Initialize the module loading */ @@ -237,7 +238,7 @@ void lttv_module_option(void *hook_data) GError *error = NULL; lttv_module_require(a_module, &error); - if(error != NULL) g_error(error->message); + if(error != NULL) g_error("%s", error->message); } diff --git a/ltt/branches/poly/lttv/lttv/module.c b/ltt/branches/poly/lttv/lttv/module.c index c2cc8fac..a1826b91 100644 --- a/ltt/branches/poly/lttv/lttv/module.c +++ b/ltt/branches/poly/lttv/lttv/module.c @@ -70,7 +70,7 @@ static GQuark lttv_module_error; static void init(); -static finish_destroy(); +static void finish_destroy(); static void module_release(LttvModule *m); @@ -129,16 +129,17 @@ static void library_remove(LttvLibrary *l) LttvModule *m; GPtrArray *modules; - + GPtrArray **modules_ptr = &modules; /* for strict aliasing */ guint i; char *key; + char **key_ptr = &key; /* for strict aliasing */ for(i = 0 ; i < l->modules->len ; i++) { m = (LttvModule *)(l->modules->pdata[i]); g_hash_table_lookup_extended(modules_by_name, m->info.name, - (gpointer *)&key, (gpointer *)&modules); + (gpointer *)key_ptr, (gpointer *)modules_ptr); g_assert(modules != NULL); g_ptr_array_remove(modules, m); if(modules->len == 0) { @@ -162,11 +163,12 @@ static void library_remove(LttvLibrary *l) static LttvLibrary *library_load(char *name, GError **error) { - GModule *gm; + GModule *gm = NULL; int i, nb; - char *path, *pathname; + /* path is always initialized, checked */ + char *path = NULL, *pathname; LttvLibrary *l; @@ -234,7 +236,7 @@ LttvLibrary *lttv_library_load(char *name, GError **error) static void library_unload(LttvLibrary *l) { - guint i, len; + guint i; GModule *gm; @@ -522,7 +524,7 @@ static void init() } -static finish_destroy() +static void finish_destroy() { guint i; diff --git a/ltt/branches/poly/lttv/lttv/option.c b/ltt/branches/poly/lttv/lttv/option.c index 54af7932..f4b34275 100644 --- a/ltt/branches/poly/lttv/lttv/option.c +++ b/ltt/branches/poly/lttv/lttv/option.c @@ -107,7 +107,7 @@ static int poptToLTT[] = { POPT_ARG_NONE, POPT_ARG_STRING, POPT_ARG_INT, POPT_ARG_LONG }; -static struct poptOption endOption = { NULL, '\0', 0, NULL, 0}; +static struct poptOption endOption = { NULL, '\0', 0, NULL, 0, NULL, NULL }; static void @@ -134,15 +134,15 @@ build_popts(GPtrArray **plist, struct poptOption **ppopts, poptContext *pc, /* add the options in the reverse order, so last additions are parsed first */ for(i = 0 ; i < list->len ; i++) { - guint index = list->len-1-i; + guint reverse_i = list->len-1-i; option = (LttvOption *)list->pdata[i]; - popts[index].longName = option->long_name; - popts[index].shortName = option->char_name; - popts[index].descrip = option->description; - popts[index].argDescrip = option->arg_description; - popts[index].argInfo = poptToLTT[option->t]; - popts[index].arg = option->p; - popts[index].val = option->val; + popts[reverse_i].longName = option->long_name; + popts[reverse_i].shortName = option->char_name; + popts[reverse_i].descrip = option->description; + popts[reverse_i].argDescrip = option->arg_description; + popts[reverse_i].argInfo = poptToLTT[option->t]; + popts[reverse_i].arg = option->p; + popts[reverse_i].val = option->val; } /* Terminate the array for popt and create the context */ @@ -271,11 +271,9 @@ static void show_help(LttvOption *option) void lttv_option_show_help(void) { - LttvOption option; - GPtrArray *list = g_ptr_array_new(); - int i; + guint i; g_hash_table_foreach(options, list_options, list); @@ -286,8 +284,6 @@ void lttv_option_show_help(void) show_help((LttvOption *)list->pdata[i]); } g_ptr_array_free(list, TRUE); - - } static void init() @@ -299,11 +295,9 @@ static void init() static void destroy() { - LttvOption option; - GPtrArray *list = g_ptr_array_new(); - int i; + guint i; g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Destroy option.c"); g_hash_table_foreach(options, list_options, list); diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index e7f23f9c..aa204e8a 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -96,16 +96,16 @@ void lttv_state_state_saved_free(LttvTraceState *self, guint process_hash(gconstpointer key) { - return ((LttvProcessState *)key)->pid; + return ((const LttvProcessState *)key)->pid; } gboolean process_equal(gconstpointer a, gconstpointer b) { - LttvProcessState *process_a, *process_b; + const LttvProcessState *process_a, *process_b; - process_a = (LttvProcessState *)a; - process_b = (LttvProcessState *)b; + process_a = (const LttvProcessState *)a; + process_b = (const LttvProcessState *)b; if(process_a->pid != process_b->pid) return FALSE; if(process_a->pid == 0 && @@ -188,7 +188,7 @@ init(LttvTracesetState *self, LttvTraceset *ts) static void fini(LttvTracesetState *self) { - guint i, j, nb_trace; + guint i, nb_trace; LttvTraceState *tcs; @@ -201,9 +201,10 @@ fini(LttvTracesetState *self) tcs = (LttvTraceState *)(LTTV_TRACESET_CONTEXT(self)->traces[i]); lttv_attribute_find(tcs->parent.t_a, LTTV_STATE_TRACE_STATE_USE_COUNT, LTTV_UINT, &v); + + g_assert(*(v.v_uint) != 0); (*v.v_uint)--; - g_assert(*(v.v_uint) >= 0); if(*(v.v_uint) == 0) { free_name_tables(tcs); free_max_time(tcs); @@ -729,7 +730,7 @@ static void pop_state(LttvTracefileState *tfs, LttvExecutionMode t) guint depth = process->execution_stack->len; if(process->state->t != t){ - g_info("Different execution mode type (%d.%09d): ignore it\n", + g_info("Different execution mode type (%lu.%09lu): ignore it\n", tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec); g_info("process state has %s when pop_int is %s\n", g_quark_to_string(process->state->t), @@ -743,7 +744,7 @@ static void pop_state(LttvTracefileState *tfs, LttvExecutionMode t) } if(depth == 1){ - g_info("Trying to pop last state on stack (%d.%09d): ignore it\n", + g_info("Trying to pop last state on stack (%lu.%09lu): ignore it\n", tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec); return; } @@ -1254,6 +1255,8 @@ static gboolean block_end(void *hook_data, void *call_data) self->saved_position = 0; *(tcs->max_time_state_recomputed_in_seek) = self->parent.timestamp; g_free(ep); + + return FALSE; } @@ -1261,7 +1264,7 @@ void lttv_state_save_add_event_hooks(LttvTracesetState *self) { LttvTraceset *traceset = self->parent.ts; - guint i, j, k, nb_trace, nb_tracefile; + guint i, j, nb_trace, nb_tracefile; LttvTraceState *ts; @@ -1304,7 +1307,7 @@ void lttv_state_save_remove_event_hooks(LttvTracesetState *self) { LttvTraceset *traceset = self->parent.ts; - guint i, j, k, nb_trace, nb_tracefile; + guint i, j, nb_trace, nb_tracefile; LttvTraceState *ts; @@ -1347,7 +1350,7 @@ void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t) { LttvTraceset *traceset = self->parent.ts; - guint i, j, nb_trace, nb_saved_state; + guint i, nb_trace; int min_pos, mid_pos, max_pos; @@ -1452,7 +1455,8 @@ lttv_traceset_state_get_type(void) NULL, /* class_data */ sizeof (LttvTracesetState), 0, /* n_preallocs */ - (GInstanceInitFunc) traceset_state_instance_init /* instance_init */ + (GInstanceInitFunc) traceset_state_instance_init, /* instance_init */ + NULL /* value handling */ }; type = g_type_register_static (LTTV_TRACESET_CONTEXT_TYPE, "LttvTracesetStateType", @@ -1502,7 +1506,8 @@ lttv_trace_state_get_type(void) NULL, /* class_data */ sizeof (LttvTraceState), 0, /* n_preallocs */ - (GInstanceInitFunc) trace_state_instance_init /* instance_init */ + (GInstanceInitFunc) trace_state_instance_init, /* instance_init */ + NULL /* value handling */ }; type = g_type_register_static (LTTV_TRACE_CONTEXT_TYPE, @@ -1549,7 +1554,8 @@ lttv_tracefile_state_get_type(void) NULL, /* class_data */ sizeof (LttvTracefileState), 0, /* n_preallocs */ - (GInstanceInitFunc) tracefile_state_instance_init /* instance_init */ + (GInstanceInitFunc) tracefile_state_instance_init, /* instance_init */ + NULL /* value handling */ }; type = g_type_register_static (LTTV_TRACEFILE_CONTEXT_TYPE, diff --git a/ltt/branches/poly/lttv/lttv/state.h b/ltt/branches/poly/lttv/lttv/state.h index c6b69b54..a88e2997 100644 --- a/ltt/branches/poly/lttv/lttv/state.h +++ b/ltt/branches/poly/lttv/lttv/state.h @@ -198,7 +198,8 @@ GType lttv_traceset_state_get_type (void); struct _LttvTraceState { LttvTraceContext parent; - GHashTable *processes; /* LttvProcessState objects indexed by pid */ + GHashTable *processes; /* LttvProcessState objects indexed by pid and + last_cpu */ guint nb_event, save_interval; /* Block/char devices, locks, memory pages... */ GQuark *eventtype_names; diff --git a/ltt/branches/poly/lttv/lttv/stats.c b/ltt/branches/poly/lttv/lttv/stats.c index b56eb36f..c2fca684 100644 --- a/ltt/branches/poly/lttv/lttv/stats.c +++ b/ltt/branches/poly/lttv/lttv/stats.c @@ -49,10 +49,8 @@ static GQuark LTTV_STATS_BEFORE_HOOKS, LTTV_STATS_AFTER_HOOKS; -static void remove_all_processes(GHashTable *processes); - static void -find_event_tree(LttvTracefileStats *tfcs, GQuark process, GQuark cpu, +find_event_tree(LttvTracefileStats *tfcs, GQuark pid_time, GQuark cpu, GQuark mode, GQuark sub_mode, LttvAttribute **events_tree, LttvAttribute **event_types_tree); @@ -252,11 +250,13 @@ lttv_traceset_stats_get_type(void) NULL, /* class_data */ sizeof (LttvTracesetStats), 0, /* n_preallocs */ - (GInstanceInitFunc) traceset_stats_instance_init /* instance_init */ + (GInstanceInitFunc) traceset_stats_instance_init, /* instance_init */ + NULL /* Value handling */ }; - type = g_type_register_static (LTTV_TRACESET_STATE_TYPE, "LttvTracesetStatsType", - &info, 0); + type = g_type_register_static (LTTV_TRACESET_STATE_TYPE, + "LttvTracesetStatsType", + &info, 0); } return type; } @@ -299,7 +299,8 @@ lttv_trace_stats_get_type(void) NULL, /* class_data */ sizeof (LttvTraceStats), 0, /* n_preallocs */ - (GInstanceInitFunc) trace_stats_instance_init /* instance_init */ + (GInstanceInitFunc) trace_stats_instance_init, /* instance_init */ + NULL /* Value handling */ }; type = g_type_register_static (LTTV_TRACE_STATE_TYPE, @@ -346,7 +347,8 @@ lttv_tracefile_stats_get_type(void) NULL, /* class_data */ sizeof (LttvTracefileStats), 0, /* n_preallocs */ - (GInstanceInitFunc) tracefile_stats_instance_init /* instance_init */ + (GInstanceInitFunc) tracefile_stats_instance_init, /* instance_init */ + NULL /* Value handling */ }; type = g_type_register_static (LTTV_TRACEFILE_STATE_TYPE, @@ -357,21 +359,25 @@ lttv_tracefile_stats_get_type(void) static void -find_event_tree(LttvTracefileStats *tfcs, GQuark process, GQuark cpu, - GQuark mode, GQuark sub_mode, LttvAttribute **events_tree, - LttvAttribute **event_types_tree) +find_event_tree(LttvTracefileStats *tfcs, + GQuark pid_time, + GQuark cpu, + GQuark mode, + GQuark sub_mode, + LttvAttribute **events_tree, + LttvAttribute **event_types_tree) { LttvAttribute *a; LttvTraceStats *tcs = LTTV_TRACE_STATS(tfcs->parent.parent.t_context); a = lttv_attribute_find_subdir(tcs->stats, LTTV_STATS_PROCESSES); - a = lttv_attribute_find_subdir(a, tfcs->parent.process->pid_time); + a = lttv_attribute_find_subdir(a, pid_time); a = lttv_attribute_find_subdir(a, LTTV_STATS_CPU); - a = lttv_attribute_find_subdir(a, tfcs->parent.cpu_name); + a = lttv_attribute_find_subdir(a, cpu); a = lttv_attribute_find_subdir(a, LTTV_STATS_MODE_TYPES); - a = lttv_attribute_find_subdir(a, tfcs->parent.process->state->t); + a = lttv_attribute_find_subdir(a, mode); a = lttv_attribute_find_subdir(a, LTTV_STATS_SUBMODES); - a = lttv_attribute_find_subdir(a, tfcs->parent.process->state->n); + a = lttv_attribute_find_subdir(a, sub_mode); *events_tree = a; a = lttv_attribute_find_subdir(a, LTTV_STATS_EVENT_TYPES); *event_types_tree = a; @@ -382,7 +388,8 @@ static void update_event_tree(LttvTracefileStats *tfcs) { LttvExecutionState *es = tfcs->parent.process->state; - find_event_tree(tfcs, tfcs->parent.process->pid_time, tfcs->parent.cpu_name, + find_event_tree(tfcs, tfcs->parent.process->pid_time, + tfcs->parent.cpu_name, es->t, es->n, &(tfcs->current_events_tree), &(tfcs->current_event_types_tree)); } @@ -709,7 +716,7 @@ lttv_stats_sum_traceset(LttvTracesetStats *self) // Hook wrapper. call_data is a traceset context. -gint lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data) +gboolean lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data) { LttvTracesetStats *tss = (LttvTracesetStats*)call_data; @@ -718,7 +725,7 @@ gint lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data) return 0; } -lttv_stats_add_event_hooks(LttvTracesetStats *self) +void lttv_stats_add_event_hooks(LttvTracesetStats *self) { LttvTraceset *traceset = self->parent.parent.ts; @@ -844,7 +851,7 @@ lttv_stats_add_event_hooks(LttvTracesetStats *self) } // Hook wrapper. call_data is a traceset context. -gint lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data) +gboolean lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data) { LttvTracesetStats *tss = (LttvTracesetStats*)call_data; @@ -853,7 +860,7 @@ gint lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data) return 0; } -lttv_stats_remove_event_hooks(LttvTracesetStats *self) +void lttv_stats_remove_event_hooks(LttvTracesetStats *self) { LttvTraceset *traceset = self->parent.parent.ts; diff --git a/ltt/branches/poly/lttv/lttv/stats.h b/ltt/branches/poly/lttv/lttv/stats.h index ef6f05cd..aba1a68b 100644 --- a/ltt/branches/poly/lttv/lttv/stats.h +++ b/ltt/branches/poly/lttv/lttv/stats.h @@ -153,12 +153,12 @@ typedef struct _LttvTracefileStatsClass LttvTracefileStatsClass; // Hook wrapper. call_data is a trace context. -gint lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data); -gboolean lttv_stats_add_event_hooks(LttvTracesetStats *self); +gboolean lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data); +void lttv_stats_add_event_hooks(LttvTracesetStats *self); // Hook wrapper. call_data is a trace context. -gint lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data); -gboolean lttv_stats_remove_event_hooks(LttvTracesetStats *self); +gboolean lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data); +void lttv_stats_remove_event_hooks(LttvTracesetStats *self); gboolean lttv_stats_sum_traceset_hook(void *hook_data, void *call_data); void lttv_stats_sum_traceset(LttvTracesetStats *self); diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index 89d792c5..e0ddd006 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -16,7 +16,7 @@ * MA 02111-1307, USA. */ - +#include #include #include #include @@ -30,9 +30,9 @@ gint compare_tracefile(gconstpointer a, gconstpointer b) { gint comparison; - LttvTracefileContext *trace_a = (LttvTracefileContext *)a; + const LttvTracefileContext *trace_a = (const LttvTracefileContext *)a; - LttvTracefileContext *trace_b = (LttvTracefileContext *)b; + const LttvTracefileContext *trace_b = (const LttvTracefileContext *)b; if(trace_a == trace_b) return 0; comparison = ltt_time_compare(trace_a->timestamp, trace_b->timestamp); @@ -41,7 +41,9 @@ gint compare_tracefile(gconstpointer a, gconstpointer b) else if(trace_a->index > trace_b->index) return 1; if(trace_a->t_context->index < trace_b->t_context->index) return -1; else if(trace_a->t_context->index > trace_b->t_context->index) return 1; + g_assert(FALSE); + return 0; /* This should never happen */ } struct _LttvTraceContextPosition { @@ -465,7 +467,8 @@ lttv_traceset_context_get_type(void) NULL, /* class_data */ sizeof (LttvTracesetContext), 0, /* n_preallocs */ - (GInstanceInitFunc) traceset_context_instance_init /* instance_init */ + (GInstanceInitFunc) traceset_context_instance_init, /* instance_init */ + NULL /* Value handling */ }; type = g_type_register_static (G_TYPE_OBJECT, "LttvTracesetContextType", @@ -513,7 +516,8 @@ lttv_trace_context_get_type(void) NULL, /* class_data */ sizeof (LttvTraceContext), 0, /* n_preallocs */ - (GInstanceInitFunc) trace_context_instance_init /* instance_init */ + (GInstanceInitFunc) trace_context_instance_init, /* instance_init */ + NULL /* Value handling */ }; type = g_type_register_static (G_TYPE_OBJECT, "LttvTraceContextType", @@ -561,7 +565,8 @@ lttv_tracefile_context_get_type(void) NULL, /* class_data */ sizeof (LttvTracefileContext), 0, /* n_preallocs */ - (GInstanceInitFunc) tracefile_context_instance_init /* instance_init */ + (GInstanceInitFunc) tracefile_context_instance_init, /* instance_init */ + NULL /* Value handling */ }; type = g_type_register_static (G_TYPE_OBJECT, "LttvTracefileContextType", @@ -748,8 +753,6 @@ void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start) LttvTraceContext *tc; - LttvTracefileContext *tfc; - nb_trace = lttv_traceset_number(self->ts); for(i = 0 ; i < nb_trace ; i++) { tc = self->traces[i]; @@ -763,8 +766,6 @@ gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self, { LttvTracefileContext *tfc = self; - LttEvent *event; - GTree *pqueue = self->t_context->ts_context->pqueue; ltt_tracefile_seek_position(tfc->tf, pos); @@ -774,7 +775,7 @@ gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self, g_tree_insert(pqueue, tfc, tfc); } - + return TRUE; } gboolean lttv_process_trace_seek_position(LttvTraceContext *self, @@ -784,8 +785,6 @@ gboolean lttv_process_trace_seek_position(LttvTraceContext *self, LttvTracefileContext *tfc; - LttEvent *event; - nb_tracefile = ltt_trace_control_tracefile_number(self->t) + ltt_trace_per_cpu_tracefile_number(self->t); @@ -810,8 +809,6 @@ gboolean lttv_process_traceset_seek_position(LttvTracesetContext *self, LttvTraceContext *tc; - LttvTracefileContext *tfc; - nb_trace = lttv_traceset_number(self->ts); if(nb_trace != pos->nb_trace) @@ -861,9 +858,7 @@ lttv_trace_find_hook(LttTrace *t, char *facility, char *event_type, LttEventType *et; - guint nb, pos, i; - - char *name; + guint nb, pos; nb = ltt_trace_facility_find(t, facility, &pos); if(nb < 1) g_error("No %s facility", facility); @@ -929,7 +924,7 @@ void lttv_traceset_context_position_save(const LttvTracesetContext *self, void lttv_traceset_context_position_destroy(LttvTracesetContextPosition *pos) { - guint nb_trace, nb_tracefile; + guint nb_trace; guint iter_trace, iter_tracefile; nb_trace = pos->nb_trace; @@ -1005,11 +1000,9 @@ gint lttv_traceset_context_ctx_pos_compare(const LttvTracesetContext *self, for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) { tfc = tc->tracefiles[iter_tracefile]; event = tfc->e; - if( - ret = - ltt_event_event_position_compare(event, - pos->t_pos[iter_trace].tf_pos[iter_tracefile]) - != 0) + ret = ltt_event_event_position_compare(event, + pos->t_pos[iter_trace].tf_pos[iter_tracefile]); + if(ret != 0) return ret; } } @@ -1037,11 +1030,10 @@ gint lttv_traceset_context_pos_pos_compare( g_error("lttv_traceset_context_ctx_pos_compare : nb_tracefile does not match."); for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) { - if(ret = - ltt_event_position_compare( + ret = ltt_event_position_compare( pos1->t_pos[iter_trace].tf_pos[iter_tracefile], - pos2->t_pos[iter_trace].tf_pos[iter_tracefile]) - != 0) + pos2->t_pos[iter_trace].tf_pos[iter_tracefile]); + if(ret != 0) return ret; } } diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.h b/ltt/branches/poly/lttv/lttv/tracecontext.h index 2c273902..dc652e25 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.h +++ b/ltt/branches/poly/lttv/lttv/tracecontext.h @@ -308,5 +308,8 @@ gint lttv_traceset_context_ctx_pos_compare(const LttvTracesetContext *self, LttTime lttv_traceset_context_position_get_time( const LttvTracesetContextPosition *pos); +gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self, + const LttEventPosition *pos); + #endif // PROCESSTRACE_H diff --git a/ltt/branches/poly/lttv/lttv/traceset.c b/ltt/branches/poly/lttv/lttv/traceset.c index fd67c688..a190486a 100644 --- a/ltt/branches/poly/lttv/lttv/traceset.c +++ b/ltt/branches/poly/lttv/lttv/traceset.c @@ -71,7 +71,7 @@ LttvTrace *lttv_trace_new(LttTrace *t) LttvTraceset *lttv_traceset_copy(LttvTraceset *s_orig) { - int i; + guint i; LttvTraceset *s; LttvTrace * trace; -- 2.34.1