perf tools: Eliminate duplicate code and use PATH_MAX consistently
No need for multiple definitions for STR() and die(), also use SuSv2's PATH_MAX instead of adding MAX_PATH. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-qpujjkw7u0bf0tr4wt55cr9y@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include "parse-options.h"
|
||||
#include "evsel.h"
|
||||
#include "cgroup.h"
|
||||
#include "debugfs.h" /* MAX_PATH, STR() */
|
||||
#include "evlist.h"
|
||||
|
||||
int nr_cgroups;
|
||||
@@ -12,7 +11,7 @@ static int
|
||||
cgroupfs_find_mountpoint(char *buf, size_t maxlen)
|
||||
{
|
||||
FILE *fp;
|
||||
char mountpoint[MAX_PATH+1], tokens[MAX_PATH+1], type[MAX_PATH+1];
|
||||
char mountpoint[PATH_MAX + 1], tokens[PATH_MAX + 1], type[PATH_MAX + 1];
|
||||
char *token, *saved_ptr = NULL;
|
||||
int found = 0;
|
||||
|
||||
@@ -25,8 +24,8 @@ cgroupfs_find_mountpoint(char *buf, size_t maxlen)
|
||||
* and inspect every cgroupfs mount point to find one that has
|
||||
* perf_event subsystem
|
||||
*/
|
||||
while (fscanf(fp, "%*s %"STR(MAX_PATH)"s %"STR(MAX_PATH)"s %"
|
||||
STR(MAX_PATH)"s %*d %*d\n",
|
||||
while (fscanf(fp, "%*s %"STR(PATH_MAX)"s %"STR(PATH_MAX)"s %"
|
||||
STR(PATH_MAX)"s %*d %*d\n",
|
||||
mountpoint, type, tokens) == 3) {
|
||||
|
||||
if (!strcmp(type, "cgroup")) {
|
||||
@@ -57,15 +56,15 @@ cgroupfs_find_mountpoint(char *buf, size_t maxlen)
|
||||
|
||||
static int open_cgroup(char *name)
|
||||
{
|
||||
char path[MAX_PATH+1];
|
||||
char mnt[MAX_PATH+1];
|
||||
char path[PATH_MAX + 1];
|
||||
char mnt[PATH_MAX + 1];
|
||||
int fd;
|
||||
|
||||
|
||||
if (cgroupfs_find_mountpoint(mnt, MAX_PATH+1))
|
||||
if (cgroupfs_find_mountpoint(mnt, PATH_MAX + 1))
|
||||
return -1;
|
||||
|
||||
snprintf(path, MAX_PATH, "%s/%s", mnt, name);
|
||||
snprintf(path, PATH_MAX, "%s/%s", mnt, name);
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd == -1)
|
||||
|
Reference in New Issue
Block a user