netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] Use PATH_MAX instead of MAXPATHLEN
@ 2015-04-25 20:33 Felix Janda
  2015-04-27 16:13 ` Stephen Hemminger
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Janda @ 2015-04-25 20:33 UTC (permalink / raw)
  To: netdev

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.

Signed-off-by: Felix Janda <felix.janda@posteo.de>
---
 ip/ipnetns.c    | 15 +++++++--------
 lib/namespace.c | 11 ++++++-----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 438d59b..c7b45a3 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>
@@ -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;
 
diff --git a/lib/namespace.c b/lib/namespace.c
index c03a103..a61feb6 100644
--- a/lib/namespace.c
+++ b/lib/namespace.c
@@ -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;
-- 
2.0.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2] Use PATH_MAX instead of MAXPATHLEN
  2015-04-25 20:33 [PATCH iproute2] Use PATH_MAX instead of MAXPATHLEN Felix Janda
@ 2015-04-27 16:13 ` Stephen Hemminger
  2015-04-28 22:47   ` Florian Fainelli
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2015-04-27 16:13 UTC (permalink / raw)
  To: Felix Janda; +Cc: netdev

On Sat, 25 Apr 2015 22:33:28 +0200
Felix Janda <felix.janda@posteo.de> wrote:

> 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.
> 
> Signed-off-by: Felix Janda <felix.janda@posteo.de>

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2] Use PATH_MAX instead of MAXPATHLEN
  2015-04-27 16:13 ` Stephen Hemminger
@ 2015-04-28 22:47   ` Florian Fainelli
  2015-04-29 16:52     ` Felix Janda
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2015-04-28 22:47 UTC (permalink / raw)
  To: Stephen Hemminger, Felix Janda; +Cc: netdev

On 27/04/15 09:13, Stephen Hemminger wrote:
> On Sat, 25 Apr 2015 22:33:28 +0200
> Felix Janda <felix.janda@posteo.de> wrote:
> 
>> 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.
>>
>> Signed-off-by: Felix Janda <felix.janda@posteo.de>
> 
> 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.
-- 
Florian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2] Use PATH_MAX instead of MAXPATHLEN
  2015-04-28 22:47   ` Florian Fainelli
@ 2015-04-29 16:52     ` Felix Janda
  2015-07-21 20:40       ` Yegor Yefremov
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Janda @ 2015-04-29 16:52 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: Stephen Hemminger, netdev

Florian Fainelli wrote:
> On 27/04/15 09:13, Stephen Hemminger wrote:
> > On Sat, 25 Apr 2015 22:33:28 +0200
> > Felix Janda <felix.janda@posteo.de> wrote:
> > 
> >> 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.
> >>
> >> Signed-off-by: Felix Janda <felix.janda@posteo.de>
> > 
> > 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.
> -- 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2] Use PATH_MAX instead of MAXPATHLEN
  2015-04-29 16:52     ` Felix Janda
@ 2015-07-21 20:40       ` Yegor Yefremov
  0 siblings, 0 replies; 5+ messages in thread
From: Yegor Yefremov @ 2015-07-21 20:40 UTC (permalink / raw)
  To: Felix Janda; +Cc: Florian Fainelli, Stephen Hemminger, netdev

On Wed, Apr 29, 2015 at 6:52 PM, Felix Janda <felix.janda@posteo.de> wrote:
> Florian Fainelli wrote:
>> On 27/04/15 09:13, Stephen Hemminger wrote:
>> > On Sat, 25 Apr 2015 22:33:28 +0200
>> > Felix Janda <felix.janda@posteo.de> wrote:
>> >
>> >> 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.
>> >>
>> >> Signed-off-by: Felix Janda <felix.janda@posteo.de>
>> >
>> > 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.
>> --
>> 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.)

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-07-21 20:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-25 20:33 [PATCH iproute2] Use PATH_MAX instead of MAXPATHLEN Felix Janda
2015-04-27 16:13 ` Stephen Hemminger
2015-04-28 22:47   ` Florian Fainelli
2015-04-29 16:52     ` Felix Janda
2015-07-21 20:40       ` Yegor Yefremov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).