ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails
Subsystems (2)
PATCH 1/1 ethtool: return non-zero from do_sset() when any of ETHTOOL_{G,S}* fails
Function do_sset returns unconditionally zero error code without regard to return value of ETHTOOL_{G,S}* ioctls.
--- ethtool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
ethtool.c +5 -2
@@ -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)
Signature · 1 line
2.0.5
Quoted 41 lines · Ivan Vecera
Function
do_ssetreturns unconditionally zero error code without regard to return value of ETHTOOL_{G,S}* ioctls.Cc Ben Hutchings <[email protected]>Signed-off-by Ivan Vecera <[email protected]>--- ethtool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)ethtool.c +3
-1@@ -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 )
ethtool.c static int do_sset(struct cmd_context *ctx) · line 2679
Quoted 10 lines
ethtool.c +2
-1perror ("Cannot set new msglvl" ); } + result = err; } -return 0 ; +return result; }static int do_gregs (struct cmd_context *ctx)
Ben, any comment on this?
Ivan
Quoted 2 lines · Ivan Vecera
Function
do_ssetreturns 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.
Signature · 2 lines
Ben Hutchings Quantity is no substitute for quality, but it's the only one we've got.