* [PATCH] ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails
@ 2015-02-06 15:24 Ivan Vecera
2015-03-25 16:58 ` Ivan Vecera
2015-04-05 1:55 ` Ben Hutchings
0 siblings, 2 replies; 3+ messages in thread
From: Ivan Vecera @ 2015-02-06 15:24 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings
Function do_sset returns unconditionally zero error code without regard
to return value of ETHTOOL_{G,S}* ioctls.
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
ethtool.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index bf583f3..c004d41 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2357,7 +2357,7 @@ static int do_sset(struct cmd_context *ctx)
int argc = ctx->argc;
char **argp = ctx->argp;
int i;
- int err;
+ int err, result = 0;
for (i = 0; i < ARRAY_SIZE(flags_msglvl); i++)
flag_to_cmdline_info(flags_msglvl[i].name,
@@ -2617,6 +2617,7 @@ static int do_sset(struct cmd_context *ctx)
fprintf(stderr, " not setting transceiver\n");
if (mdix_wanted != -1)
fprintf(stderr, " not setting mdix\n");
+ result = err;
}
}
@@ -2650,6 +2651,7 @@ static int do_sset(struct cmd_context *ctx)
fprintf(stderr, " not setting wol\n");
if (sopass_change)
fprintf(stderr, " not setting sopass\n");
+ result = err;
}
}
@@ -2668,9 +2670,10 @@ static int do_sset(struct cmd_context *ctx)
if (err < 0)
perror("Cannot set new msglvl");
}
+ result = err;
}
- return 0;
+ return result;
}
static int do_gregs(struct cmd_context *ctx)
--
2.0.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails
2015-02-06 15:24 [PATCH] ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails Ivan Vecera
@ 2015-03-25 16:58 ` Ivan Vecera
2015-04-05 1:55 ` Ben Hutchings
1 sibling, 0 replies; 3+ messages in thread
From: Ivan Vecera @ 2015-03-25 16:58 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, bhutchings
On 02/06/2015 04:24 PM, Ivan Vecera wrote:
> Function do_sset returns unconditionally zero error code without regard
> to return value of ETHTOOL_{G,S}* ioctls.
>
> Cc: Ben Hutchings <ben@decadent.org.uk>
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> ---
> ethtool.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/ethtool.c b/ethtool.c
> index bf583f3..c004d41 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -2357,7 +2357,7 @@ static int do_sset(struct cmd_context *ctx)
> int argc = ctx->argc;
> char **argp = ctx->argp;
> int i;
> - int err;
> + int err, result = 0;
>
> for (i = 0; i < ARRAY_SIZE(flags_msglvl); i++)
> flag_to_cmdline_info(flags_msglvl[i].name,
> @@ -2617,6 +2617,7 @@ static int do_sset(struct cmd_context *ctx)
> fprintf(stderr, " not setting transceiver\n");
> if (mdix_wanted != -1)
> fprintf(stderr, " not setting mdix\n");
> + result = err;
> }
> }
>
> @@ -2650,6 +2651,7 @@ static int do_sset(struct cmd_context *ctx)
> fprintf(stderr, " not setting wol\n");
> if (sopass_change)
> fprintf(stderr, " not setting sopass\n");
> + result = err;
> }
> }
>
> @@ -2668,9 +2670,10 @@ static int do_sset(struct cmd_context *ctx)
> if (err < 0)
> perror("Cannot set new msglvl");
> }
> + result = err;
> }
>
> - return 0;
> + return result;
> }
>
> static int do_gregs(struct cmd_context *ctx)
>
Ben, any comment on this?
Ivan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails
2015-02-06 15:24 [PATCH] ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails Ivan Vecera
2015-03-25 16:58 ` Ivan Vecera
@ 2015-04-05 1:55 ` Ben Hutchings
1 sibling, 0 replies; 3+ messages in thread
From: Ben Hutchings @ 2015-04-05 1:55 UTC (permalink / raw)
To: Ivan Vecera; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 567 bytes --]
On Fri, 2015-02-06 at 16:24 +0100, Ivan Vecera wrote:
> Function do_sset returns unconditionally zero error code without regard
> to return value of ETHTOOL_{G,S}* ioctls.
[...]
This behaviour is stupid, but it's what ethtool has always done and what
some scripts will depend on now. If you can think of a simple way for
scripts to opt-in to sensible exit codes, please submit that.
Also, negative exit codes aren't sensible; please just use 0 and 1.
Ben.
--
Ben Hutchings
Quantity is no substitute for quality, but it's the only one we've got.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-05 1:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 15:24 [PATCH] ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails Ivan Vecera
2015-03-25 16:58 ` Ivan Vecera
2015-04-05 1:55 ` Ben Hutchings
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).