Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 51419: /trunk/epan/dissectors/ /trun

From: Evan Huus <eapache@xxxxxxxxx>
Date: Sun, 18 Aug 2013 19:29:19 -0400
On Sun, Aug 18, 2013 at 6:56 PM, Guy Harris <guy@xxxxxxxxxxxx> wrote:

On Aug 18, 2013, at 1:04 PM, eapache@xxxxxxxxxxxxx wrote:

> http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=51419
>
> User: eapache
> Date: 2013/08/18 01:04 PM
>
> Log:
> Add a cast to try and fix
> packet-rtpproxy.c:226: warning: implicit conversion shortens 64-bit value into
> a 32-bit value
>
> I'm not quite sure what's going on here, all the values in use are either gint
> or guint so they should all be the same size?

In

        new_offset = tvb_skip_wsp(tvb, offset + (strlen("VF") + 1), -1);

one of the values - the return value of strlen() - is size_t, which isn't necessarily gint or guint (or, as Mountain Lion's autocorrect would have it, "hint or guilt" :-)), as it's 64-bit in most if not all 64-bit C implementations (including MSVC when compiling 64-bit).
 
Right. I had it in my head for some reason that Mac was ILP64 (in which case size_t and *int would all be 64-bit) but that's clearly not the case. I'm not sure where I got that idea from.

I'd make it "(gint)strlen("VF")" (and then I might make it "(sizeof "VF" - 1)", for the benefit of compilers that don't do that for you at compile time).

Premature optimization is the root of all evil, though I'm not sure I can say that with a straight face given how much time I've spent recently on wmem's block allocator :)