Skip to contentSkip to conversation

ip netns: 'ip netns id' cmd without argument should not give error

PATCH In review Mahesh Bandewar 2 participants 3 messages Dec 19, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip netns: 'ip netns id' cmd without argument should not give error

The command 'ip netns identify' without PID parameter is supposed to use the self PID to identify its ns but a trivial error prevented it from doing so. This patch fixes that error.

So before the patch -

	# ip netns id
	No pid specified
	# echo $?
	1
	#

After the patch -

	# ip netns id
	test-ns
	# echo $?
	0
	#
Cc Stephen Hemminger <[email protected]>
Cc Vadim Kochan <[email protected]>
Cc Saied Kazemi <[email protected]>
---
 ip/ipnetns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipnetns.c +1 -1
index 1c8aa029073e..ec9afa2177a5 100644
@@ -298,7 +298,7 @@ static int netns_identify(int argc, char **argv)
 	DIR *dir;
 	struct dirent *entry;
 
-	if (argc < 1) {
+	if (!argc) {
 		pidstr = "self";
 	} else if (argc > 1) {
 		fprintf(stderr, "extra arguments specified\n");
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw
Quoted 42 lines · Mahesh Bandewar

The command 'ip netns identify' without PID parameter is supposed to use the self PID to identify its ns but a trivial error prevented it from doing so. This patch fixes that error.

So before the patch -

	# ip netns id
	No pid specified
	# echo $?
	1
	#

After the patch -

	# ip netns id
	test-ns
	# echo $?
	0
	#
Cc Stephen Hemminger <[email protected]>
Cc Vadim Kochan <[email protected]>
Cc Saied Kazemi <[email protected]>
---
 ip/ipnetns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipnetns.c +1 -1
index 1c8aa029073e..ec9afa2177a5 100644
@@ -298,7 +298,7 @@ static int netns_identify(int argc, char **argv)
 	DIR *dir;
 	struct dirent *entry;
 
-	if (argc < 1) {
+	if (!argc) {
 		pidstr = "self";
 	} else if (argc > 1) {
 		fprintf(stderr, "extra arguments specified\n");
Signature · 1 line
2.2.0.rc0.207.ga3a616c

Hi Mahesh,

I did not get such error on the current master branch?

Did I miss something ?

Regards,
Vadim Kochan

#2 lore raw
Quoted 46 lines · Vadim Kochan
Quoted 40 lines · Mahesh Bandewar

The command 'ip netns identify' without PID parameter is supposed to use the self PID to identify its ns but a trivial error prevented it from doing so. This patch fixes that error.

So before the patch -

      # ip netns id
      No pid specified
      # echo $?
      1
      #

After the patch -

      # ip netns id
      test-ns
      # echo $?
      0
      #
Cc Stephen Hemminger <[email protected]>
Cc Vadim Kochan <[email protected]>
Cc Saied Kazemi <[email protected]>
---
 ip/ipnetns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipnetns.c +1 -2
index 1c8aa029073e..ec9afa2177a5 100644
@@ -298,7 +298,7 @@ static int netns_identify(int argc, char **argv)
      DIR *dir;
      struct dirent *entry;
 
-     if (argc < 1) {
+     if (!argc) {
              pidstr = "self";
      } else if (argc > 1) {
              fprintf(stderr, "extra arguments specified\n");
--
Quoted 2 lines

2.2.0.rc0.207.ga3a616c

Hi Mahesh,

Quoted 4 lines

I did not get such error on the current master branch?

Did I miss something ?

No you did not! Please ignore this patch. :)

Looks like the tree I was working / using wasn't next and did not have the patch that made it work (in next). I cherry-picked my fix onto the next and sent it. My bad!

Quoted 2 lines

Regards,
Vadim Kochan