From patchwork Sun Jul 3 11:35:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16461 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 B4B7382490; Sun, 3 Jul 2016 13:35:57 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=c+IeGpcz; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id A950582464 for ; Sun, 3 Jul 2016 13:35:19 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C964F90000000000002E16.dip0.t-ipconnect.de [IPv6:2003:c5:93c9:64f9::2e16]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 2FB3D11010B for ; Sun, 3 Jul 2016 13:35:19 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1467545719; bh=d2aIBQUZTwXewpi5LIOCpkYBUMMMj5Owu9etszjkQOQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=c+IeGpczsyMuqxbt+OdTOj4ClA8yieCrX1Y1jNt5u57zQdSq22t941ynGSSZqyMjE 8X0py1AvIfTvK+Xby2rXQHcra2Ha2xmZPXRjsuBCyRLRBkE46kYUkT0WdyKJdOrHzg sk4WAG0jlvm+fP/Fftr31DuZGZBQsLvi8F/E+UBE= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 3 Jul 2016 13:35:10 +0200 Message-Id: <1467545714-20722-5-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1467545714-20722-1-git-send-email-sven@narfation.org> References: <1467545714-20722-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH v10 4/8] 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" 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__ */