Replace BSD MAXPATHLEN by POSIX PATH_MAX
Prefer using the POSIX constant PATH_MAX instead of the legacy BSD
derived MAXPATHLEN. The necessary includes for MAXPATHLEN and PATH_MAX
are <sys/param.h> and <limits.h>, respectively.
Signed-off-by: Felix Janda <felix.janda@posteo.de>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 0c28f8a..3b704a4 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -4,7 +4,6 @@
#include <sys/wait.h>
#include <sys/inotify.h>
#include <sys/mount.h>
-#include <sys/param.h>
#include <sys/syscall.h>
#include <stdio.h>
#include <string.h>
@@ -437,7 +436,7 @@
static int netns_pids(int argc, char **argv)
{
const char *name;
- char net_path[MAXPATHLEN];
+ char net_path[PATH_MAX];
int netns;
struct stat netst;
DIR *dir;
@@ -472,7 +471,7 @@
return -1;
}
while((entry = readdir(dir))) {
- char pid_net_path[MAXPATHLEN];
+ char pid_net_path[PATH_MAX];
struct stat st;
if (!is_pid(entry->d_name))
continue;
@@ -493,7 +492,7 @@
static int netns_identify(int argc, char **argv)
{
const char *pidstr;
- char net_path[MAXPATHLEN];
+ char net_path[PATH_MAX];
int netns;
struct stat netst;
DIR *dir;
@@ -537,7 +536,7 @@
}
while((entry = readdir(dir))) {
- char name_path[MAXPATHLEN];
+ char name_path[PATH_MAX];
struct stat st;
if (strcmp(entry->d_name, ".") == 0)
@@ -563,7 +562,7 @@
static int on_netns_del(char *nsname, void *arg)
{
- char netns_path[MAXPATHLEN];
+ char netns_path[PATH_MAX];
snprintf(netns_path, sizeof(netns_path), "%s/%s", NETNS_RUN_DIR, nsname);
umount2(netns_path, MNT_DETACH);
@@ -612,7 +611,7 @@
* userspace tweaks like remounting /sys, or bind mounting
* a new /etc/resolv.conf can be shared between uers.
*/
- char netns_path[MAXPATHLEN];
+ char netns_path[PATH_MAX];
const char *name;
int fd;
int made_netns_run_dir_mount = 0;
@@ -707,7 +706,7 @@
static int netns_set(int argc, char **argv)
{
- char netns_path[MAXPATHLEN];
+ char netns_path[PATH_MAX];
const char *name;
int netns, nsid;