trace: Simplify find_debugfs()

The return vale of find_debugfs() is 1 if it could find a mount point of
debugfs.  It can be saved in the while loop instead of checking it again.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Namhyung Kim 2017-11-08 00:31:34 +09:00 committed by Stefan Hajnoczi
parent 411ad78115
commit 5070570c90

View File

@ -19,6 +19,7 @@ static int find_debugfs(char *debugfs)
{ {
char type[100]; char type[100];
FILE *fp; FILE *fp;
int ret = 0;
fp = fopen("/proc/mounts", "r"); fp = fopen("/proc/mounts", "r");
if (fp == NULL) { if (fp == NULL) {
@ -28,15 +29,13 @@ static int find_debugfs(char *debugfs)
while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n", while (fscanf(fp, "%*s %" STR(PATH_MAX) "s %99s %*s %*d %*d\n",
debugfs, type) == 2) { debugfs, type) == 2) {
if (strcmp(type, "debugfs") == 0) { if (strcmp(type, "debugfs") == 0) {
ret = 1;
break; break;
} }
} }
fclose(fp); fclose(fp);
if (strcmp(type, "debugfs") != 0) { return ret;
return 0;
}
return 1;
} }
bool ftrace_init(void) bool ftrace_init(void)