diff mbox

[iproute,v2,1/7] devlink: No need for this self-assignment

Message ID 20170817170931.24089-2-phil@nwl.cc
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Phil Sutter Aug. 17, 2017, 5:09 p.m. UTC
dl_argv_handle_both() will either assign to handle_bit or error out in
which case the variable is not used by the caller.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 devlink/devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Pirko Aug. 17, 2017, 7:48 p.m. UTC | #1
Thu, Aug 17, 2017 at 07:09:25PM CEST, phil@nwl.cc wrote:
>dl_argv_handle_both() will either assign to handle_bit or error out in
>which case the variable is not used by the caller.

I'm pretty sure that I did this to silence the compiler. If the compiler
bug is fixed now, good.

Acked-by: Jiri Pirko <jiri@mellanox.com>
Phil Sutter Aug. 18, 2017, 10:20 a.m. UTC | #2
On Thu, Aug 17, 2017 at 09:48:50PM +0200, Jiri Pirko wrote:
> Thu, Aug 17, 2017 at 07:09:25PM CEST, phil@nwl.cc wrote:
> >dl_argv_handle_both() will either assign to handle_bit or error out in
> >which case the variable is not used by the caller.
> 
> I'm pretty sure that I did this to silence the compiler. If the compiler
> bug is fixed now, good.

That might depend on the compiler you used, so maybe you just want to
give it a try in your environment? If it still happens, we can keep this
self-assignment of course since it shouldn't harm.

Thanks, Phil
Jiri Pirko Aug. 21, 2017, 9:02 a.m. UTC | #3
Fri, Aug 18, 2017 at 12:20:24PM CEST, phil@nwl.cc wrote:
>On Thu, Aug 17, 2017 at 09:48:50PM +0200, Jiri Pirko wrote:
>> Thu, Aug 17, 2017 at 07:09:25PM CEST, phil@nwl.cc wrote:
>> >dl_argv_handle_both() will either assign to handle_bit or error out in
>> >which case the variable is not used by the caller.
>> 
>> I'm pretty sure that I did this to silence the compiler. If the compiler
>> bug is fixed now, good.
>
>That might depend on the compiler you used, so maybe you just want to
>give it a try in your environment? If it still happens, we can keep this
>self-assignment of course since it shouldn't harm.

No warning with gcc 6.3.1
diff mbox

Patch

diff --git a/devlink/devlink.c b/devlink/devlink.c
index f9bc16c350c40..bf43e2cd5e709 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -779,7 +779,7 @@  static int dl_argv_parse(struct dl *dl, uint32_t o_required,
 	int err;
 
 	if (o_required & DL_OPT_HANDLE && o_required & DL_OPT_HANDLEP) {
-		uint32_t handle_bit = handle_bit;
+		uint32_t handle_bit;
 
 		err = dl_argv_handle_both(dl, &opts->bus_name, &opts->dev_name,
 					  &opts->port_index, &handle_bit);