[Libwebsockets] Typo in _LWS_PAD

Stepan Vondrak stepanvondrak at slightlymadstudios.com
Thu Oct 15 12:41:10 CEST 2015


Hi all,

After updating to latest sources Visual Studio 2015 started complaining 
about LWS_SEND_BUFFER_PRE_PADDING. Looking at the sources, I noticed a 
probable typo in _LWS_PAD definition:
     #define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? (n + (_LWS_PAD_SIZE - 
(n % _LWS_PAD_SIZE))) : (n))
To be specific, this
     (n % _LWS_PAD_SIZE)
expands to
     (4 + 10 + (2 * MAX_MUX_RECURSION) % _LWS_PAD_SIZE)
which is probably not intended.

Fixing the define to
     #define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? ((n) + (_LWS_PAD_SIZE 
- ((n) % _LWS_PAD_SIZE))) : (n))
makes the warnings go away and the value evaluates correctly to 20 again 
in 32-builds.

Cheers,
Stepan




More information about the Libwebsockets mailing list