chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemd-python: refuse path and flags together in __init__
[elogind.git]
/
src
/
bootchart
/
log.c
diff --git
a/src/bootchart/log.c
b/src/bootchart/log.c
index 1e3f4a9e8c9c1b359c212f6dda3a57e964bb6018..ccec03f12cb18c6b85c49dcdc888df50d5d5ba07 100644
(file)
--- a/
src/bootchart/log.c
+++ b/
src/bootchart/log.c
@@
-57,7
+57,7
@@
double gettime_ns(void)
void log_uptime(void)
{
void log_uptime(void)
{
- FILE
*f
;
+ FILE
_cleanup_fclose_ *f = NULL
;
char str[32];
double uptime;
char str[32];
double uptime;
@@
-65,11
+65,9
@@
void log_uptime(void)
if (!f)
return;
if (!f)
return;
- if (!fscanf(f, "%s %*s", str)) {
- fclose(f);
+ if (!fscanf(f, "%s %*s", str))
return;
return;
- }
- fclose(f);
+
uptime = strtod(str, NULL);
log_start = gettime_ns();
uptime = strtod(str, NULL);
log_start = gettime_ns();
@@
-120,7
+118,6
@@
void log_sample(int sample)
{
static int vmstat;
static int schedstat;
{
static int vmstat;
static int schedstat;
- FILE *st;
char buf[4095];
char key[256];
char val[256];
char buf[4095];
char key[256];
char val[256];
@@
-253,6
+250,7
@@
schedstat_next:
/* end of our LL? then append a new record */
if (ps->pid != pid) {
/* 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;
char t[32];
struct ps_struct *parent;
@@
-264,7
+262,7
@@
schedstat_next:
ps = ps->next_ps;
ps->pid = pid;
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 (!ps->sample) {
perror("calloc(ps_struct)");
exit (EXIT_FAILURE);
@@
-320,10
+318,8
@@
schedstat_next:
if (!st)
continue;
if (!fscanf(st, "%*s %*s %*s %i", &p)) {
if (!st)
continue;
if (!fscanf(st, "%*s %*s %*s %i", &p)) {
- fclose(st);
continue;
}
continue;
}
- fclose(st);
ps->ppid = p;
/*
ps->ppid = p;
/*