Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] MSVC 2015 failures

From: Anders Broman <anders.broman@xxxxxxxxxxxx>
Date: Mon, 8 Jun 2015 14:08:30 +0000

-----Original Message-----
From: wireshark-dev-bounces@xxxxxxxxxxxxx [mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] On Behalf Of Guy Harris
Sent: den 5 juni 2015 21:22
To: Developer support list for Wireshark
Subject: Re: [Wireshark-dev] MSVC 2015 failures


On Jun 5, 2015, at 3:50 AM, Anders Broman <anders.broman@xxxxxxxxxxxx> wrote:
 
>> in_cksum.c(92): error C2220: warning treated as error - no 'object' file generated
>> in_cksum.c(92): warning C4311: 'type cast': pointer truncation from 'const guint16 *' to 'unsigned long'
>
>This is trying to do 2-byte operations with word loads/stores/arithmetic instructions, but to do it safely, so that we don't do those with unaligned pointers.  It's testing the low-order bit of the pointer.
>
>On ILP32 platforms, such as 32-bit UN*Xes and 32-bit Windows, an int, a long, and a pointer are all 32 bits, so you can just cast a pointer to an int or a long.
>
>On LP64 platforms, such as all the 64-bit UN*Xes we support, a long and a pointer are both 64 bits, so you can just cast a pointer to a long.
>
>On LLP64 platforms, such as 64-bit Windows, an int and a long are both 32 bits, and a long long and a pointer are both 64 bits, so you can't just cast a pointer to a long without throwing away bits.  Those bits don't >actually *matter* in this case, but the compiler still warns.
>
>C99 has an intptr_t type, but C90 doesn't.  MSVC has it at least as far back as Visual Studio .NET 2003:
>
>	https://msdn.microsoft.com/en-us/library/323b6b3k(v=vs.71).aspx
>
>I don't know whether any UN*X platforms we support don't have it; I suspect most if not all of them have adopted it.
>
>Alternatively, GLib 2.18 and later have gintptr, although configure.ac currently only requires 2.16 or later.
>
OK I checked in a "fix" for that and commented out

//#ifdef _WIN32
//#define inet_pton ws_inet_pton
//#define inet_ntop ws_inet_ntop
//#endif
//
//WS_DLL_PUBLIC int inet_pton(int af, const char *src, void *dst);

In inet_v6defs.h  to get further and got:


capture_sync.c(662): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'int'
capture_sync.c(667): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'long'
capture_sync.c(670): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'long'
capture_sync.c(878): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'int'
capture_sync.c(883): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'long'
capture_sync.c(884): warning C4311: 'type cast': pointer truncation from 'HANDLE' to 'long'
capture_sync.c(2121): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size
capture_sync.c(2170): warning C4312: 'type cast': conversion from 'int' to 'HANDLE' of greater size

use gintptr here too, or use intptr_t or?

Regards
Anders

___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe