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:
Arnaldo Carvalho de Melo
2011-11-16 12:55:59 -02:00
parent c23205c848
commit c168fbfb93
6 changed files with 24 additions and 62 deletions

View File

@@ -2,8 +2,10 @@
#include "debugfs.h"
#include "cache.h"
#include <sys/mount.h>
static int debugfs_premounted;
static char debugfs_mountpoint[MAX_PATH+1];
static char debugfs_mountpoint[PATH_MAX + 1];
static const char *debugfs_known_mountpoints[] = {
"/sys/kernel/debug/",
@@ -64,9 +66,7 @@ const char *debugfs_find_mountpoint(void)
if (fp == NULL)
die("Can't open /proc/mounts for read");
while (fscanf(fp, "%*s %"
STR(MAX_PATH)
"s %99s %*s %*d %*d\n",
while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
debugfs_mountpoint, type) == 2) {
if (strcmp(type, "debugfs") == 0)
break;
@@ -158,7 +158,7 @@ int debugfs_umount(void)
int debugfs_write(const char *entry, const char *value)
{
char path[MAX_PATH+1];
char path[PATH_MAX + 1];
int ret, count;
int fd;
@@ -203,7 +203,7 @@ int debugfs_write(const char *entry, const char *value)
*/
int debugfs_read(const char *entry, char *buffer, size_t size)
{
char path[MAX_PATH+1];
char path[PATH_MAX + 1];
int ret;
int fd;