gint hdr;
gchar buf[MAX_STRING_LEN];
guint len;
+ size_t res;
trace_path = g_quark_to_string(ltt_trace_name(tcs->parent.t));
strncpy(path, trace_path, PATH_MAX-1);
g_ptr_array_set_size(quarktable, q+1);
i=0;
while(1) {
- fread(&buf[i], sizeof(gchar), 1, fp);
+ res = fread(&buf[i], sizeof(gchar), 1, fp);
+ g_assert(res == 1);
if(buf[i] == '\0' || feof(fp)) break;
i++;
}
LttvProcessState *process, *parent_process;
LttvProcessState tmp;
GQuark tmpq;
+ size_t res;
guint64 *address;
- /* TODO : check return value */
- fread(&tmp.type, sizeof(tmp.type), 1, fp);
- fread(&tmp.name, sizeof(tmp.name), 1, fp);
- fread(&tmp.brand, sizeof(tmp.brand), 1, fp);
- fread(&tmp.pid, sizeof(tmp.pid), 1, fp);
- fread(&tmp.free_events, sizeof(tmp.free_events), 1, fp);
- fread(&tmp.tgid, sizeof(tmp.tgid), 1, fp);
- fread(&tmp.ppid, sizeof(tmp.ppid), 1, fp);
- fread(&tmp.cpu, sizeof(tmp.cpu), 1, fp);
- fread(&tmp.creation_time, sizeof(tmp.creation_time), 1, fp);
- fread(&tmp.insertion_time, sizeof(tmp.insertion_time), 1, fp);
+ res = fread(&tmp.type, sizeof(tmp.type), 1, fp);
+ res += fread(&tmp.name, sizeof(tmp.name), 1, fp);
+ res += fread(&tmp.brand, sizeof(tmp.brand), 1, fp);
+ res += fread(&tmp.pid, sizeof(tmp.pid), 1, fp);
+ res += fread(&tmp.free_events, sizeof(tmp.free_events), 1, fp);
+ res += fread(&tmp.tgid, sizeof(tmp.tgid), 1, fp);
+ res += fread(&tmp.ppid, sizeof(tmp.ppid), 1, fp);
+ res += fread(&tmp.cpu, sizeof(tmp.cpu), 1, fp);
+ res += fread(&tmp.creation_time, sizeof(tmp.creation_time), 1, fp);
+ res += fread(&tmp.insertion_time, sizeof(tmp.insertion_time), 1, fp);
+ g_assert(res == 10);
if(tmp.pid == 0) {
process = lttv_state_find_process(self, tmp.cpu, tmp.pid);
process->execution_stack->len-1);
process->state = es;
- fread(&es->t, sizeof(es->t), 1, fp);
+ res = fread(&es->t, sizeof(es->t), 1, fp);
+ g_assert(res == 1);
es->t = g_quark_from_string(
(gchar*)g_ptr_array_index(quarktable, es->t));
- fread(&es->n, sizeof(es->n), 1, fp);
+ res = fread(&es->n, sizeof(es->n), 1, fp);
+ g_assert(res == 1);
es->n = g_quark_from_string(
(gchar*)g_ptr_array_index(quarktable, es->n));
- fread(&es->s, sizeof(es->s), 1, fp);
+ res = fread(&es->s, sizeof(es->s), 1, fp);
+ g_assert(res == 1);
es->s = g_quark_from_string(
(gchar*)g_ptr_array_index(quarktable, es->s));
- fread(&es->entry, sizeof(es->entry), 1, fp);
- fread(&es->change, sizeof(es->change), 1, fp);
- fread(&es->cum_cpu_time, sizeof(es->cum_cpu_time), 1, fp);
+ res = fread(&es->entry, sizeof(es->entry), 1, fp);
+ res += fread(&es->change, sizeof(es->change), 1, fp);
+ res += fread(&es->cum_cpu_time, sizeof(es->cum_cpu_time), 1, fp);
+ g_assert(res == 3);
break;
case HDR_USER_STACK:
process->user_stack->len + 1);
address = &g_array_index(process->user_stack, guint64,
process->user_stack->len-1);
- fread(address, sizeof(address), 1, fp);
+ res = fread(address, sizeof(address), 1, fp);
+ g_assert(res == 1);
process->current_function = *address;
break;
case HDR_USERTRACE:
- fread(&tmpq, sizeof(tmpq), 1, fp);
- fread(&process->usertrace->cpu, sizeof(process->usertrace->cpu), 1, fp);
+ res = fread(&tmpq, sizeof(tmpq), 1, fp);
+ res += fread(&process->usertrace->cpu,
+ sizeof(process->usertrace->cpu), 1, fp);
+ g_assert(res == 2);
break;
default:
guint nb_cpus;
int hdr;
+ size_t res;
LttTime t;
restore_init_state(self);
- fread(&t, sizeof(t), 1, fp);
+ res = fread(&t, sizeof(t), 1, fp);
+ g_assert(res == 1);
do {
if(feof(fp) || ferror(fp)) goto end_loop;
int cpu_num;
hdr = fgetc(fp);
g_assert(hdr == HDR_CPU);
- fread(&cpu_num, sizeof(cpu_num), 1, fp); /* cpu number */
+ res = fread(&cpu_num, sizeof(cpu_num), 1, fp); /* cpu number */
+ g_assert(res == 1);
g_assert(i == cpu_num);
- fread(&self->running_process[i]->pid,
+ res = fread(&self->running_process[i]->pid,
sizeof(self->running_process[i]->pid), 1, fp);
+ g_assert(res == 1);
}
nb_tracefile = self->parent.tracefiles->len;
g_tree_remove(pqueue, &tfcs->parent);
hdr = fgetc(fp);
g_assert(hdr == HDR_TRACEFILE);
- fread(&tfcs->parent.timestamp, sizeof(tfcs->parent.timestamp), 1, fp);
+ res = fread(&tfcs->parent.timestamp, sizeof(tfcs->parent.timestamp), 1, fp);
+ g_assert(res == 1);
/* Note : if timestamp if LTT_TIME_INFINITE, there will be no
* position following : end of trace */
if(ltt_time_compare(tfcs->parent.timestamp, ltt_time_infinite) != 0) {
- fread(&nb_block, sizeof(nb_block), 1, fp);
- fread(&offset, sizeof(offset), 1, fp);
- fread(&tsc, sizeof(tsc), 1, fp);
+ res = fread(&nb_block, sizeof(nb_block), 1, fp);
+ res += fread(&offset, sizeof(offset), 1, fp);
+ res += fread(&tsc, sizeof(tsc), 1, fp);
+ g_assert(res == 3);
ltt_event_position_set(ep, tfcs->parent.tf, nb_block, offset, tsc);
gint ret = ltt_tracefile_seek_position(tfcs->parent.tf, ep);
g_assert(ret == 0);
static void modify_path_with_private(GArray *path, struct process_state *pstate)
{
char *tmps;
+ int res;
// FIXME: fix this leak
switch(pstate->bstate) {
case HLEV_INTERRUPTED_IRQ:
- asprintf(&tmps, "IRQ %d [%s]", ((struct hlev_state_info_interrupted_irq *)pstate->private)->irq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(irq_table, &((struct hlev_state_info_interrupted_irq *)pstate->private)->irq)));
+ res = asprintf(&tmps, "IRQ %d [%s]", ((struct hlev_state_info_interrupted_irq *)pstate->private)->irq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(irq_table, &((struct hlev_state_info_interrupted_irq *)pstate->private)->irq)));
+ g_assert(res > 0);
g_array_append_val(path, tmps);
break;
case HLEV_INTERRUPTED_SOFTIRQ:
- asprintf(&tmps, "SoftIRQ %d [%s]", ((struct hlev_state_info_interrupted_softirq *)pstate->private)->softirq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(softirq_table, &((struct hlev_state_info_interrupted_softirq *)pstate->private)->softirq)));
+ res = asprintf(&tmps, "SoftIRQ %d [%s]", ((struct hlev_state_info_interrupted_softirq *)pstate->private)->softirq, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(softirq_table, &((struct hlev_state_info_interrupted_softirq *)pstate->private)->softirq)));
+ g_assert(res > 0);
g_array_append_val(path, tmps);
break;
case HLEV_BLOCKED: {
g_array_append_val(path, ptr);
}
else {
- asprintf(&tmps, "Syscall %d [%s]", hlev_blocked_private->syscall_id, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(syscall_table, &hlev_blocked_private->syscall_id)));
+ res = asprintf(&tmps, "Syscall %d [%s]", hlev_blocked_private->syscall_id, g_quark_to_string((GQuark)(unsigned long)g_hash_table_lookup(syscall_table, &hlev_blocked_private->syscall_id)));
+ g_assert(res > 0);
g_array_append_val(path, tmps);
}
}
else if(((struct hlev_state_info_blocked *)pstate->private)->substate == HLEV_BLOCKED__READ) {
char *str;
- asprintf(&str, "%s", g_quark_to_string(((struct hlev_state_info_blocked__read *)((struct hlev_state_info_blocked *)pstate->private)->private)->filename));
+ res = asprintf(&str, "%s", g_quark_to_string(((struct hlev_state_info_blocked__read *)((struct hlev_state_info_blocked *)pstate->private)->private)->filename));
+ g_assert(res > 0);
g_array_append_val(path, str);
/* FIXME: this must be freed at some point */
//free(str);
}
else if(((struct hlev_state_info_blocked *)pstate->private)->substate == HLEV_BLOCKED__POLL) {
char *str;
- asprintf(&str, "%s", g_quark_to_string(((struct hlev_state_info_blocked__poll *)((struct hlev_state_info_blocked *)pstate->private)->private)->filename));
+ res = asprintf(&str, "%s", g_quark_to_string(((struct hlev_state_info_blocked__poll *)((struct hlev_state_info_blocked *)pstate->private)->private)->filename));
+ g_assert(res > 0);
g_array_append_val(path, str);
/* FIXME: this must be freed at some point */
//free(str);
LttvTracefileState *tfs = (LttvTracefileState *)call_data;
LttEvent *e;
struct marker_info *info;
+ int res;
/* Extract data from event structures and state */
guint cpu = tfs->cpu;
}
else {
char *tmp;
- asprintf(&tmp, "Unknown filename, fd %d", fd);
+ res = asprintf(&tmp, "Unknown filename, fd %d", fd);
+ g_assert(res > 0);
llev_syscall_read_private->filename = g_quark_from_string(tmp);
free(tmp);
}
}
else {
char *tmp;
- asprintf(&tmp, "Unknown filename, fd %d", fd);
+ res = asprintf(&tmp, "Unknown filename, fd %d", fd);
+ g_assert(res > 0);
llev_syscall_poll_private->filename = g_quark_from_string(tmp);
free(tmp);
}