The alfred version of debugfs.c and debugfs.h contains several cleanups
regarding error message output, removal of unused declarations and usage of
const buffers.

Signed-off-by: Sven Eckelmann <[email protected]>
---
 debugfs.c | 17 ++++++++++-------
 debugfs.h |  4 +---
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/debugfs.c b/debugfs.c
index 3c58195..fc39322 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -33,6 +33,9 @@
 static int debugfs_premounted;
 static char debugfs_mountpoint[MAX_PATH+1];
 
+static const char *debugfs_find_mountpoint(void);
+static int debugfs_valid_mountpoint(const char *debugfs);
+
 static const char *debugfs_known_mountpoints[] = {
        "/sys/kernel/debug/",
        "/debug/",
@@ -40,7 +43,8 @@ static const char *debugfs_known_mountpoints[] = {
 };
 
 /* construct a full path to a debugfs element */
-int debugfs_make_path(const char *fmt, char *mesh_iface, char *buffer, int 
size)
+int debugfs_make_path(const char *fmt, const char *mesh_iface, char *buffer,
+                     int size)
 {
        if (strlen(debugfs_mountpoint) == 0) {
                buffer[0] = '\0';
@@ -53,14 +57,14 @@ int debugfs_make_path(const char *fmt, char *mesh_iface, 
char *buffer, int size)
 static int debugfs_found;
 
 /* find the path to the mounted debugfs */
-const char *debugfs_find_mountpoint(void)
+static const char *debugfs_find_mountpoint(void)
 {
        const char **ptr;
        char type[100];
        FILE *fp;
 
        if (debugfs_found)
-               return (const char *) debugfs_mountpoint;
+               return (const char *)debugfs_mountpoint;
 
        ptr = debugfs_known_mountpoints;
        while (*ptr) {
@@ -68,7 +72,7 @@ const char *debugfs_find_mountpoint(void)
                        debugfs_found = 1;
                        strncpy(debugfs_mountpoint, *ptr,
                                sizeof(debugfs_mountpoint));
-                       debugfs_mountpoint[sizeof(debugfs_mountpoint) - 1] = 
'\0';
+                       debugfs_mountpoint[sizeof(debugfs_mountpoint) - 1] = 0;
                        return debugfs_mountpoint;
                }
                ptr++;
@@ -77,8 +81,7 @@ const char *debugfs_find_mountpoint(void)
        /* give up and parse /proc/mounts */
        fp = fopen("/proc/mounts", "r");
        if (fp == NULL) {
-               fprintf(stderr, "Error - can't open /proc/mounts for read: 
%s\n",
-                      strerror(errno));
+               perror("Error - can't open /proc/mounts for read");
                return NULL;
        }
 
@@ -101,7 +104,7 @@ const char *debugfs_find_mountpoint(void)
 
 /* verify that a mountpoint is actually a debugfs instance */
 
-int debugfs_valid_mountpoint(const char *debugfs)
+static int debugfs_valid_mountpoint(const char *debugfs)
 {
        struct statfs st_fs;
 
diff --git a/debugfs.h b/debugfs.h
index e608902..b4dc6bb 100644
--- a/debugfs.h
+++ b/debugfs.h
@@ -30,11 +30,9 @@
 # define STR(x) _STR(x)
 #endif
 
-extern const char *debugfs_find_mountpoint(void);
-extern int debugfs_valid_mountpoint(const char *debugfs);
 extern int debugfs_valid_entry(const char *path);
 extern char *debugfs_mount(const char *mountpoint);
-extern int debugfs_make_path(const char *fmt, char *mesh_iface,
+extern int debugfs_make_path(const char *fmt, const char *mesh_iface,
                             char *buffer, int size);
 
 #endif /* __DEBUGFS_H__ */
-- 
2.8.1

Reply via email to