From patchwork Thu Jun 9 14:58:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 16353 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id D66A881D44; Thu, 9 Jun 2016 16:59:32 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=simonwunderlich.de Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2001:4d88:2000:24::c0de; helo=mail.mail.packetmixer.de; envelope-from=sw@simonwunderlich.de; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=none header.from=simonwunderlich.de Received: from mail.mail.packetmixer.de (packetmixer.de [IPv6:2001:4d88:2000:24::c0de]) by open-mesh.org (Postfix) with ESMTPS id AA39B81CF5 for ; Thu, 9 Jun 2016 16:58:58 +0200 (CEST) Received: from kero.packetmixer.de (p2003007C6F7E2400527B9DFFFECE2EDC.dip0.t-ipconnect.de [IPv6:2003:7c:6f7e:2400:527b:9dff:fece:2edc]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mail.packetmixer.de (Postfix) with ESMTPSA id C10CF174001; Thu, 9 Jun 2016 16:58:58 +0200 (CEST) From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 9 Jun 2016 16:58:51 +0200 Message-Id: <1465484333-8187-4-git-send-email-sw@simonwunderlich.de> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465484333-8187-1-git-send-email-sw@simonwunderlich.de> References: <1465484333-8187-1-git-send-email-sw@simonwunderlich.de> Subject: [B.A.T.M.A.N.] [PATCH v9 3/5] batctl: Import alfred version of debugfs.* X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Sven Eckelmann 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 --- 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__ */