On 24/08/17 09:57, Antonio Quartulli wrote:
> My effort in writing the commit message has been quite poor.
> 
> The assignment is useless because 'ret' is re-assigned a few lines later
> without ever being read.

Hmmm.  I'm not convinced of this change.  But I'm also weird in these
cases :)

I think it is good defensive programming to predefine the state of
variables.  When that is not done, it is up the the compiler to decide
what to do - which most of the times does a sane job these days.  But
you're at the mercy of the compiler.

In this case,  I would expect the compiler to optimize this out anyway,
regardless of the approaches used.  The compiler doesn't necessarily set
the value first to true and then to change it to the output of
multi_process_post().  It might just as well postpone the declaration.

So I think a better approach would be to completely move the "bool ret"
down.  So it will become:

   bool ret = multi_process_post(m, mi, mpp_flags);

Which I think is also closer to what the compiler would end up with anyway.


-- 
kind regards,

David Sommerseth
OpenVPN Technologies, Inc



> On 24/08/17 15:53, Antonio Quartulli wrote:
>> Signed-off-by: Antonio Quartulli <a...@unstable.cc>
>> ---
>>  src/openvpn/multi.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h
>> index 5892ac07..6cdb0110 100644
>> --- a/src/openvpn/multi.h
>> +++ b/src/openvpn/multi.h
>> @@ -633,7 +633,7 @@ multi_process_outgoing_tun(struct multi_context *m, 
>> const unsigned int mpp_flags
>>  static inline bool
>>  multi_process_outgoing_link_dowork(struct multi_context *m, struct 
>> multi_instance *mi, const unsigned int mpp_flags)
>>  {
>> -    bool ret = true;
>> +    bool ret;
>>      set_prefix(mi);
>>      process_outgoing_link(&mi->context);
>>      ret = multi_process_post(m, mi, mpp_flags);
>>

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to