Subject: Re: Windows Warnings

Re: Windows Warnings

From: Narayan Subramanian <>
Date: Mon, 1 Jul 2019 05:43:40 +0000


Definitely library ABI must not be broken by a fix. Most of these can be fixed using length trimming bitmasks and other such simple transformations.

As an example, for the line in question (E:\libssh2\src\knownhost.c(174)) that yields the warning "warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data)"

could be fixed as:

#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 ...


On 27/06/19, 3:36 PM, "libssh2-devel on behalf of" < on behalf of> wrote:

    Send libssh2-devel mailing list submissions to
    To subscribe or unsubscribe via the World Wide Web, visit
    or, via email, send a message with subject or body 'help' to
    You can reach the person managing the list at
    When replying, please edit your Subject line so it is more specific
    than "Re: Contents of libssh2-devel digest..."
    Today's Topics:
       1. Re: Windows Warnings (Chris Hanson)
    Message: 1
    Date: Wed, 26 Jun 2019 12:12:08 -0700
    From: Chris Hanson <>
    To: libssh2 development <>
    Subject: Re: Windows Warnings
    Message-ID: <>
    Content-Type: text/plain; charset="utf-8"
    On Jun 26, 2019, at 3:45 AM, Narayan Subramanian <> wrote:
> Though Windows builds fine, there are SEVERAL build warnings. Is this normal?
> FYI, I am using Visual Studio 2017 and libssh2 1.9.
> I have attached the log file.
> Most of the warnings are data conversion / truncation warnings. E.g:
> E:\libssh2\src\knownhost.c(174): warning C4267: 'function': conversion from 'size_t' to 'unsigned int', possible loss of data
> These shouldn’t be difficult to fix. Should we work towards fixing these? I don’t mind contributing towards this. These may be reviewed and tested.
    Before assuming all such warnings should be fixed by changing types, take a look at the effect that changing these types would have.
    For example, if an exported function returns unsigned int and you get a warning like that, you can’t just change its return type without also changing the ABI of the library. Since that would mean a new version of the library isn’t a binary-compatible drop-in replacement for the old version, that means you would need to find some other way to address the warning.
      -- Chris
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <>
    Subject: Digest Footer
    libssh2-devel mailing list
    End of libssh2-devel Digest, Vol 120, Issue 7

Received on 2019-07-01