From: Stephen Hemminger <stephen@networkplumber•org>
To: Serhey Popovych <serhe.popovych@gmail•com>
Cc: netdev@vger•kernel.org, dsahern@gmail•com
Subject: Re: [PATCH iproute2-next 1/8] iplink: Return from function instead of calling exit()
Date: Tue, 20 Feb 2018 12:08:21 -0800 [thread overview]
Message-ID: <20180220120821.61fe7d74@xeon-e3> (raw)
In-Reply-To: <1519155598-22137-2-git-send-email-serhe.popovych@gmail.com>
On Tue, 20 Feb 2018 21:39:51 +0200
Serhey Popovych <serhe.popovych@gmail•com> wrote:
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail•com>
> ---
> ip/iplink.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/ip/iplink.c b/ip/iplink.c
> index 74c377c..a2c8108 100644
> --- a/ip/iplink.c
> +++ b/ip/iplink.c
> @@ -653,7 +653,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
> NEXT_ARG();
> if (xdp_parse(&argc, &argv, req, dev_index,
> generic, drv, offload))
> - exit(-1);
> + return -1;
> } else if (strcmp(*argv, "netns") == 0) {
> NEXT_ARG();
> if (netns != -1)
> @@ -972,12 +972,12 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
> if (!dev) {
> fprintf(stderr,
> "Not enough information: \"dev\" argument is required.\n");
> - exit(-1);
> + return -1;
> }
> if (cmd == RTM_NEWLINK && index) {
> fprintf(stderr,
> "index can be used only when creating devices.\n");
> - exit(-1);
> + return -1;
> }
>
> req.i.ifi_index = ll_name_to_index(dev);
> @@ -1392,7 +1392,7 @@ static int do_set(int argc, char **argv)
> if (!dev) {
> fprintf(stderr,
> "Not enough of information: \"dev\" argument is required.\n");
> - exit(-1);
> + return -1;
> }
>
> if (newaddr || newbrd) {
> @@ -1553,7 +1553,7 @@ static int iplink_afstats(int argc, char **argv)
> fprintf(stderr,
> "Command \"%s\" is unknown, try \"ip link help\".\n",
> *argv);
> - exit(-1);
> + return -1;
> }
>
> argv++; argc--;
> @@ -1648,5 +1648,5 @@ int do_iplink(int argc, char **argv)
>
> fprintf(stderr, "Command \"%s\" is unknown, try \"ip link help\".\n",
> *argv);
> - exit(-1);
> + return -1;
> }
Not sure I like this. If given bad input in batch it is better to stop and exit
rather than continuing with more bad data.
next prev parent reply other threads:[~2018-02-20 20:08 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-20 19:39 [PATCH iproute2-next 0/8] iplink: Improve iplink_parse() Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 1/8] iplink: Return from function instead of calling exit() Serhey Popovych
2018-02-20 20:08 ` Stephen Hemminger [this message]
2018-02-20 20:17 ` Serhey Popovych
2018-02-20 20:27 ` David Ahern
2018-02-20 20:33 ` Stephen Hemminger
2018-02-20 20:44 ` Roopa Prabhu
2018-02-20 20:49 ` David Ahern
2018-02-20 22:36 ` Roopa Prabhu
2018-02-20 20:44 ` Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 2/8] utils: Introduce and use nodev() helper routine Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 3/8] iplink: Correctly report error when network device isn't found Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 4/8] iplink: Use "dev" and "name" parameters interchangeable when possible Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 5/8] iplink: Follow documented behaviour when "index" is given Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 6/8] iplink: Perform most of request buffer setups and checks in iplink_parse() Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 7/8] iplink: Move data structures to block of their users Serhey Popovych
2018-02-20 19:39 ` [PATCH iproute2-next 8/8] iplink: Reduce number of arguments to iplink_parse() Serhey Popovych
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180220120821.61fe7d74@xeon-e3 \
--to=stephen@networkplumber$(echo .)org \
--cc=dsahern@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=serhe.popovych@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox