#include <string.h>
#include <assert.h>
+#include <lttng/constant.h>
#include "../command.h"
static int opt_userspace;
int ret;
FILE *fp;
char *cmdline = NULL;
- char path[24]; /* Can't go bigger than /proc/65535/cmdline */
+ /* Can't go bigger than /proc/LTTNG_MAX_PID/cmdline */
+ char path[sizeof("/proc//cmdline") + sizeof(LTTNG_MAX_PID_STR) - 1];
snprintf(path, sizeof(path), "/proc/%d/cmdline", pid);
fp = fopen(path, "r");
}
/* Caller must free() *cmdline */
- cmdline = malloc(PATH_MAX);
+ cmdline = zmalloc(PATH_MAX);
+ if (!cmdline) {
+ perror("malloc cmdline");
+ goto end;
+ }
ret = fread(cmdline, 1, PATH_MAX, fp);
if (ret < 0) {
perror("fread proc list");
goto error_channels;
}
- if (channel_name == NULL) {
+ if (count) {
MSG("Channels:\n-------------");
}