Hi,
On 26/09/2022 08:39, Gert Doering wrote:
Hi,
On Mon, Sep 26, 2022 at 12:13:57AM +0200, Antonio Quartulli wrote:
For now I will just remove the brackets from case 2, where they are not
needed.
TBH, I think we should just not use switch/case here.
It might seem elegant, to do this with a fall-through switch/case, but
it turns out to be not very elegant due to the restrictions on local
variables. Also, if someone ends up setting push-peer-info to 4,
they will get "nothing at all" now, instead of "everything".
This is set programmatically, not by the user. So right now you can't
set a value higher than 3.
Actually it may make sense to switch to an enum instead of a plain int,
so that the compiler will warn us if the switch/case is not handling all
the values (an 'if' won't do that).
To keep to your idea of doing this in blocks "3", "2+3", "1+2+3" one
could do
int detail = session->opt->push_peer_info_detail;
if (detail >= 3)
{
...
}
if (detail > 2)
{
...
}
if (detail > 1)
{
...
}
so it has less twisted conditions.
Since >3 is not possible, this is exactly the same as a switch/case,
(just reimplemented with ifs).
I am not sure why this switch/case is different from the others?
We also have {} in other case blocks for the very same reason.
If we feel having the {} is ugly, we should agree on what to do
globally, no? Not just change this hunk.
Cheers,
--
Antonio Quartulli
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel