void log_uptime(void)
{
- FILE *f;
+ FILE _cleanup_fclose_ *f = NULL;
char str[32];
double uptime;
if (!f)
return;
- if (!fscanf(f, "%s %*s", str)) {
- fclose(f);
+ if (!fscanf(f, "%s %*s", str))
return;
- }
- fclose(f);
+
uptime = strtod(str, NULL);
log_start = gettime_ns();
{
static int vmstat;
static int schedstat;
- FILE *st;
char buf[4095];
char key[256];
char val[256];
/* end of our LL? then append a new record */
if (ps->pid != pid) {
+ FILE _cleanup_fclose_ *st = NULL;
char t[32];
struct ps_struct *parent;
ps = ps->next_ps;
ps->pid = pid;
- ps->sample = calloc(len + 1, sizeof(struct ps_sched_struct));
+ ps->sample = calloc(samples_len + 1, sizeof(struct ps_sched_struct));
if (!ps->sample) {
perror("calloc(ps_struct)");
exit (EXIT_FAILURE);
if (!st)
continue;
if (!fscanf(st, "%*s %*s %*s %i", &p)) {
- fclose(st);
continue;
}
- fclose(st);
ps->ppid = p;
/*