#include <time.h>
#include "util.h"
+#include "strxcpyx.h"
#include "store.h"
#include "bootchart.h"
}
void log_uptime(void) {
- FILE _cleanup_fclose_ *f = NULL;
+ _cleanup_fclose_ FILE *f = NULL;
char str[32];
double uptime;
return c;
}
-static int pid_cmdline_strncpy(char *buffer, int pid, size_t buf_len) {
+static int pid_cmdline_strscpy(char *buffer, size_t buf_len, int pid) {
char filename[PATH_MAX];
- int _cleanup_close_ fd=-1;
+ _cleanup_close_ int fd=-1;
ssize_t n;
sprintf(filename, "%d/cmdline", pid);
void log_sample(int sample) {
static int vmstat;
static int schedstat;
- char buf[4095];
+ char buf[4096];
char key[256];
char val[256];
char rt[256];
/* end of our LL? then append a new record */
if (ps->pid != pid) {
- FILE _cleanup_fclose_ *st = NULL;
+ _cleanup_fclose_ FILE *st = NULL;
char t[32];
struct ps_struct *parent;
if (!sscanf(buf, "%s %*s %*s", key))
continue;
- strncpy(ps->name, key, 256);
+ strscpy(ps->name, sizeof(ps->name), key);
/* cmdline */
if (arg_show_cmdline)
- pid_cmdline_strncpy(ps->name, pid, 256);
+ pid_cmdline_strscpy(ps->name, sizeof(ps->name), pid);
/* discard line 2 */
m = bufgetline(buf);
if (!sscanf(buf, "%s %*s %*s", key))
continue;
- strncpy(ps->name, key, 256);
+ strscpy(ps->name, sizeof(ps->name), key);
/* cmdline */
if (arg_show_cmdline)
- pid_cmdline_strncpy(ps->name, pid, 256);
+ pid_cmdline_strscpy(ps->name, sizeof(ps->name), pid);
}
}
}