[v11,07/11] batctl: Import alfred version of debugfs.*
Commit Message
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 <sven@narfation.org>
---
debugfs.c | 17 ++++++++++-------
debugfs.h | 4 +---
2 files changed, 11 insertions(+), 10 deletions(-)
Comments
On Monday, July 18, 2016 12:12:04 Sven Eckelmann wrote:
> 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 <sven@narfation.org>
> ---
> debugfs.c | 17 ++++++++++-------
> debugfs.h | 4 +---
> 2 files changed, 11 insertions(+), 10 deletions(-)
Applied in revision 23c3c6d.
Thanks,
Marek
@@ -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;
@@ -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__ */