[Spice-devel] [vdagent-win PATCH V3 11/11] g_key_get_string: use size_t for pointer difference
Uri Lublin
uril at redhat.com
Tue Jan 20 05:04:02 PST 2015
On 01/19/2015 07:00 PM, Christophe Fergeau wrote:
> I don't know if VS has ptrdiff_t readily available which would
> probably be the best type to use here.
>
> Christophe
Although VS has ptrdiff_t available, it complains:
file_xfer.cpp
e:\vdagent\vdagent\file_xfer.cpp(224) : warning C4018: '>=' :
signed/unsigned mismatch
That's the line where len (which is now ptrdiff_t -- a signed type) is
compared against
vsize (which is unsigned).
If we want to be pedantic, vsize should really be of a size_t too since
it holds a sizeof() value.
Also I build with VS the following program for both 32 and 64 machines,
with output follows:
int _tmain(int argc, _TCHAR* argv[])
{
printf("sizeof(ptrdiff_t)=%d\n", sizeof(ptrdiff_t));
printf("sizeof(size_t)=%d\n", sizeof(size_t));
return 0;
}
x86 (WinXP):
sizeof(ptrdiff_t)=4
sizeof(size_t)=4
x64 (Win7):
sizeof(ptrdiff_t)=8
sizeof(size_t)=8
Thanks,
Uri.
>
>
> On Tue, Dec 30, 2014 at 06:20:57PM +0200, Uri Lublin wrote:
>> The 64 bit Visual Studio build complains that:
>> .\file_xfer.cpp(223) : warning C4244:
>> '=' : conversion from '__int64' to 'unsigned int', possible loss of data
>> ---
>> vdagent/file_xfer.cpp | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/vdagent/file_xfer.cpp b/vdagent/file_xfer.cpp
>> index 3aad4ac..8d7c86c 100644
>> --- a/vdagent/file_xfer.cpp
>> +++ b/vdagent/file_xfer.cpp
>> @@ -205,7 +205,7 @@ bool FileXfer::g_key_get_string(char* data, const char* group, const char* key,
>> {
>> char group_pfx[G_KEY_MAX_LEN], key_pfx[G_KEY_MAX_LEN];
>> char *group_pos, *key_pos, *next_group_pos, *start, *end;
>> - unsigned len;
>> + size_t len;
>>
>> snprintf(group_pfx, sizeof(group_pfx), "[%s]", group);
>> if (!(group_pos = strstr((char*)data, group_pfx))) return false;
>> --
>> 1.7.1
>>
>> _______________________________________________
>> Spice-devel mailing list
>> Spice-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list