Narayan Subramanian wrote:
> Most of these can be fixed using length trimming bitmasks and other such
> simple transformations.
..
> #define TO32BIT(X) ( (X) & UINT_MAX ) //UINT_MAX is 0xFFFFFFFF
>
> rc = libssh2_base64_decode(hosts->session, &ptr, &ptrlen,
> host, TO32BIT(hostlen) );
>
> I'm sure all warnings can be fixed by simple in - place transformations
> without changing external ABI. Let me know what you think ...
Please don't send patches to fix the warnings, please send patches to fix
the code. There is a significant difference between the two.
If you merely silence the warning by (now explicitly) truncating the
value then the value continues to be truncated. Whenever that
truncating is actually incorrect you have literally swept the warning
under the rug and have made the real problem much harder to find.
//Peter
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2019-07-01