Hi,

On 11-10-18 13:23, Gert Doering wrote:
> On Thu, Oct 11, 2018 at 01:40:16PM +0300, Lev Stipakov wrote:
>>> Since crypto_overhead and crypto_max_overhead() are both size_t, and
>>> frame_add_to_extra_frame() is declared to take an "unsigned int" now,
>>> this cast should not be necessary.
>>
>>
>> Visual Studio disagrees. Without explicit cast I got
>>
>>> warning C4267: 'function': conversion from 'size_t' to 'const unsigned
>> int', possible loss of data
>>
>> https://docs.microsoft.com/fi-fi/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267?view=vs-2017
>>
>>
>> 'var' : conversion from 'size_t' to 'type', possible loss of data
>> The compiler detected a conversion from size_t to a smaller type.
> 
> So, maybe "crypto_overhead" and "crypto_max_overhead()" should be
> changed to be just "int" here...?
> 
> For something which has a numeric value between "10-ish" and "100" (maybe),
> using a 64bit integer initially and then adding casts because we want
> to work with 32bit integers later on and not be warned about it sounds
> like the wrong way to tackle this...
> 
> I know that Steffan likes using size_t for "things that have a size"
> but I find it a bit questionable here :-)

So the underlying problem is that "further down" used int to store
sizes, but since that just is the way it is and we shouldn't pull in
refactoring the code base for each small change, I would say either make
both 'int', or make both 'size_t', but without changing the types of
struct frame itself.  I of course prefer the latter ;-)

-Steffan

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to