Use PATH_MAX instead of MAXPATHLEN
Subsystems (3)
PATCH 1/1 Use PATH_MAX instead of MAXPATHLEN
They are equivalent but the former is more common. PATH_MAX is specified by POSIX and needs <limits.h> while MAXPATHLEN has BSD origin and needs <sys/param.h>.
PATH_MAX has already been in use in misc/lnstat.h.
--- ip/ipnetns.c | 15 +++++++-------- lib/namespace.c | 11 ++++++----- 2 files changed, 13 insertions(+), 13 deletions(-)
ip/ipnetns.c +7 -8
@@ -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>
@@ -436,7 +435,7 @@ static int is_pid(const char *str)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;
@@ -471,7 +470,7 @@ static int netns_pids(int argc, char **argv)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 ;
@@ -492,7 +491,7 @@ static int netns_pids(int argc, char **argv)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;
@@ -536,7 +535,7 @@ static int netns_identify(int argc, char **argv) }while ((entry =readdir (dir))) { -char name_path[MAXPATHLEN ]; +char name_path[PATH_MAX ];struct stat st;if (strcmp (entry->d_name,"." ) ==0 )
@@ -562,7 +561,7 @@ static int netns_identify(int argc, char **argv)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 );
@@ -611,7 +610,7 @@ static int netns_add(int argc, char **argv)* 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 ;
@@ -706,7 +705,7 @@ static int set_netnsid_from_name(const char *name, int nsid)static int netns_set (int argc,char **argv) { -char netns_path[MAXPATHLEN ]; +char netns_path[PATH_MAX ];const char *name;int netns, nsid;
lib/namespace.c +6 -5
@@ -9,15 +9,16 @@#include <fcntl.h> #include <dirent.h> +#include <limits.h> #include "utils.h" #include "namespace.h" static void bind_etc (const char *name) { -char etc_netns_path[MAXPATHLEN ]; -char netns_name[MAXPATHLEN ]; -char etc_name[MAXPATHLEN ]; +char etc_netns_path[PATH_MAX ]; +char netns_name[PATH_MAX ]; +char etc_name[PATH_MAX ];struct dirent *entry;DIR *dir;
@@ -43,7 +44,7 @@ static void bind_etc(const char *name)int netns_switch (char *name) { -char net_path[MAXPATHLEN ]; +char net_path[PATH_MAX ];int netns;snprintf (net_path,sizeof (net_path),"%s/%s" ,NETNS_RUN_DIR , name);
@@ -87,7 +88,7 @@ int netns_switch(char *name)int netns_get_fd (const char *name) { -char pathbuf[MAXPATHLEN ]; +char pathbuf[PATH_MAX ];const char *path, *ptr; path = name;
Signature · 1 line
2.0.5
Quoted 7 lines · On Sat, 25 Apr 2015 22:33:28 +0200 Felix Janda <[email protected]> wrote:
They are equivalent but the former is more common.
PATH_MAXis specified by POSIX and needs <limits.h> while MAXPATHLEN has BSD origin and needs <sys/param.h>.
PATH_MAXhas already been in use inmisc/lnstat.h.Signed-off-by Felix Janda <[email protected]>
Iproute2 is intended for use on Linux.
It makes more sense to align with Posix than using leftover BSD stuff. Therefore I don't see any point in doing this.
Quoted 7 lines · Stephen Hemminger
Quoted 4 lines · On Sat, 25 Apr 2015 22:33:28 +0200 Felix Janda <[email protected]> wrote:
They are equivalent but the former is more common.
PATH_MAXis specified by POSIX and needs <limits.h> while MAXPATHLEN has BSD origin and needs <sys/param.h>.
Quoted 7 lines
Quoted 3 lines
PATH_MAXhas already been in use inmisc/lnstat.h.Signed-off-by Felix Janda <[email protected]>Iproute2 is intended for use on Linux.
It makes more sense to align with Posix than using leftover BSD stuff. Therefore I don't see any point in doing this.
My reading from Felix's commit message is that he is attempting to do exactly that: conform to POSIX rather than BSD, which seems to be the direction you are also suggesting here.
Signature · 1 line
Florian
Quoted 12 lines · Florian Fainelli
Quoted 11 lines · Stephen Hemminger
Quoted 7 lines · On Sat, 25 Apr 2015 22:33:28 +0200 Felix Janda <[email protected]> wrote:
They are equivalent but the former is more common.
PATH_MAXis specified by POSIX and needs <limits.h> while MAXPATHLEN has BSD origin and needs <sys/param.h>.
PATH_MAXhas already been in use inmisc/lnstat.h.Signed-off-by Felix Janda <[email protected]>
Quoted 9 lines
Quoted 3 lines
Iproute2 is intended for use on Linux.
It makes more sense to align with Posix than using leftover BSD stuff. Therefore I don't see any point in doing this.My reading from Felix's commit message is that he is attempting to do exactly that: conform to POSIX rather than BSD, which seems to be the direction you are also suggesting here.
Signature · 1 line
Florian
This is correct. (In fact I misread the end of Stephen's message, thought that the patch was merged and wanted to thank for that.)
Felix
Quoted 17 lines · Felix Janda
Quoted 16 lines · Florian Fainelli
Quoted 14 lines · Stephen Hemminger
Quoted 7 lines · On Sat, 25 Apr 2015 22:33:28 +0200 Felix Janda <[email protected]> wrote:
They are equivalent but the former is more common.
PATH_MAXis specified by POSIX and needs <limits.h> while MAXPATHLEN has BSD origin and needs <sys/param.h>.
PATH_MAXhas already been in use inmisc/lnstat.h.Signed-off-by Felix Janda <[email protected]>Iproute2 is intended for use on Linux.
It makes more sense to align with Posix than using leftover BSD stuff. Therefore I don't see any point in doing this.
Quoted 8 lines
Quoted 5 lines
My reading from Felix's commit message is that he is attempting to do exactly that: conform to POSIX rather than BSD, which seems to be the direction you are also suggesting here.
--
FlorianThis is correct. (In fact I misread the end of Stephen's message, thought that the patch was merged and wanted to thank for that.)
What's the status of this patch? This is one of the reasons iproute2 cannot be compiled against musl C library. After fixing this I get tons of redefine errors:
In file included from ../include/linux/xfrm.h:4:0,
from xfrm_state.c:31:
../include/linux/in6.h:32:8: error: redefinition of ‘struct in6_addr’
struct in6_addr {
^
In file included from
/home/user/Documents/versioned/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/include/netdb.h:9:0,
from xfrm_state.c:30:
/home/user/Documents/versioned/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/include/netinet/in.h:24:8:
note: originally defined here
struct in6_addr
^
In file included from ../include/linux/xfrm.h:4:0,
from xfrm_state.c:31:../include/linux/in6.h:40:0: warning: "s6_addr" redefined
#define s6_addr in6_u.u6_addr8
^
In file included from /home/user/Documents/versioned/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/include/netdb.h:9:0,
from xfrm_state.c:30:
/home/user/Documents/versioned/buildroot/output/host/usr/arm-buildroot-linux-musleabi/sysroot/usr/include/netinet/in.h:32:0:
note: this is the location of the previous definition
#define s6_addr __in6_union.__s6_addr
^
Yegor