[Libwebsockets] warning C4244: 'return' : conversion from 'lws_filepos_t' to 'size_t', possible loss of data

jon at keyonsec.com jon at keyonsec.com
Thu Apr 26 04:24:17 CEST 2018

Thanks Andy.

-----Original Message-----
From: Andy Green [mailto:andy at warmcat.com] 
Sent: Wednesday, April 25, 2018 9:24 PM
To: jon at keyonsec.com; Libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] warning C4244: 'return' : conversion from
'lws_filepos_t' to 'size_t', possible loss of data

On 04/26/2018 06:20 AM, jon at keyonsec.com wrote:
> Hello all,
> I'm compiling websockets 2.4 in 32-bit Microsoft Visual C (v11) and 
> noticed this warning message. Can someone clarify if I should change 
> some code to alleviate the warning? Or should I typecast?
> Function below. Please advise.
> Thanks,
> Jon
> LWS_VISIBLE size_t

Well, this is master, but no worries.

This is only used on http/2 at the minute, which in the standard defines 
the tx credit to be a 32-bit signed int.


> lws_get_peer_write_allowance(structlws *wsi)
> {
> if(wsi->role_ops->tx_credit)
> return wsi->role_ops->tx_credit(wsi); // This line is giving me the

With the refactor to put all this stuff into role ops, inside it uses a 
larger type (now ultimately long long) since it may meet other role 
protocols than h2.  size_t matches the length of that on linux x86_64 
but not on windows.

I pushed a fix changing the return type on the public api from size_t to 
lws_fileofs_t, which is ultimately long long, matching the internal role 
ops type.


> return-1;
> }
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets

More information about the Libwebsockets mailing list