Re: [Openvpn-devel] [PATCH] options.c: fix broken unary minus usage

2018-10-10 Thread Lev Stipakov
Hi, This was catched by Visual Studio. Moreover, with SDL enabled ( https://docs.microsoft.com/fi-fi/cpp/build/reference/sdl-enable-additional-security-checks?view=vs-2017 ) this warning is treated as an error. It is probably a good idea to trigger Visual Studio build on every commit to master (a

Re: [Openvpn-devel] [PATCH] options.c: fix broken unary minus usage

2018-10-09 Thread Selva Nair
Hi On Tue, Oct 9, 2018 at 5:14 PM Selva Nair wrote: > > > In fact the issue here is not the unary minus, but the unsigned to signed > conversion. So when there is no scope for overflow all is good. If there is > overflow, unsigned->signed conversion is ill-defined -- cast doesn't fix > it. In fa

Re: [Openvpn-devel] [PATCH] options.c: fix broken unary minus usage

2018-10-09 Thread Selva Nair
Hi, More noise: a typo alert below: On Tue, Oct 9, 2018 at 5:14 PM Selva Nair wrote: > Hi > > On Tue, Oct 9, 2018 at 4:39 PM Steffan Karger wrote: > >> Hi, >> >> On 08-10-18 18:09, Lev Stipakov wrote: >> > From: Lev Stipakov >> > >> > In Visual Studio when unary minus is applied to unsigned,

Re: [Openvpn-devel] [PATCH] options.c: fix broken unary minus usage

2018-10-09 Thread Selva Nair
Hi On Tue, Oct 9, 2018 at 4:39 PM Steffan Karger wrote: > Hi, > > On 08-10-18 18:09, Lev Stipakov wrote: > > From: Lev Stipakov > > > > In Visual Studio when unary minus is applied to unsigned, > > result is still unsigned. This means that when we use result > > as function formal parameter, we

Re: [Openvpn-devel] [PATCH] options.c: fix broken unary minus usage

2018-10-09 Thread Steffan Karger
Hi, On 08-10-18 18:09, Lev Stipakov wrote: > From: Lev Stipakov > > In Visual Studio when unary minus is applied to unsigned, > result is still unsigned. This means that when we use result > as function formal parameter, we pass incorrect value. > > Fix by adding explicit cast to signed type. >