lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CB79494@AcuExch.aculab.com>
Date:	Wed, 12 Aug 2015 09:58:00 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Zhang Shengju' <zhangshengju@...s.chinamobile.com>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH iproute2] ip: replace exit with return

From: netdev-owner@...r.kernel.org
> Sent: 11 August 2015 10:40
> In our manual, we have this description of 'EXIT STATUS':
> Exit status is 0 if command was successful, and 1 if there is a syntax
> error.
> 
> But we exit in command functions with code -1 when there is a syntax error.
> It's better to use return.

Eh?
Using exit() makes it much more obvious that the program is going to exit.

I've not looked at the call site (I'm not entirely sure where this code is
in the source tree), but main() shouldn't return -1 any more than exit(-1)
is invalid.
The domain for both is 0..127.
So the code should be using a valid value.

...
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index b7b4e3e..6d29a69 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -1879,5 +1879,5 @@ int do_ipaddr(int argc, char **argv)
>  	if (matches(*argv, "help") == 0)
>  		usage();
>  	fprintf(stderr, "Command \"%s\" is unknown, try \"ip addr help\".\n", *argv);
> -	exit(-1);
> +	return -1;
>  }
...

	David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ