Subject: Re: Windows Warnings

Re: Windows Warnings

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

Chris,

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

Regards,
Narayan

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

    Send libssh2-devel mailing list submissions to
            libssh2-devel_at_cool.haxx.se
    
    To subscribe or unsubscribe via the World Wide Web, visit
            https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
    or, via email, send a message with subject or body 'help' to
            libssh2-devel-request_at_cool.haxx.se
    
    You can reach the person managing the list at
            libssh2-devel-owner_at_cool.haxx.se
    
    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 <cmhanson_at_eschatologist.net>
    To: libssh2 development <libssh2-devel_at_cool.haxx.se>
    Subject: Re: Windows Warnings
    Message-ID: <94D15967-794D-4263-99A9-415182E788E3_at_eschatologist.net>
    Content-Type: text/plain; charset="utf-8"
    
    On Jun 26, 2019, at 3:45 AM, Narayan Subramanian <Narayan.Subramanian_at_veritas.com> 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: <http://cool.haxx.se/pipermail/libssh2-devel/attachments/20190626/37dde781/attachment-0001.html>
    
    ------------------------------
    
    Subject: Digest Footer
    
    _______________________________________________
    libssh2-devel mailing list
    libssh2-devel_at_cool.haxx.se
    https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
    
    
    ------------------------------
    
    End of libssh2-devel Digest, Vol 120, Issue 7
    *********************************************
    

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2019-07-01