[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/5] libcacard: replace qemu thread primitives w
From: |
Michael Tokarev |
Subject: |
Re: [Qemu-devel] [PATCH 4/5] libcacard: replace qemu thread primitives with glib ones |
Date: |
Tue, 29 Apr 2014 13:14:14 +0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.4.0 |
29.04.2014 13:11, Paolo Bonzini пишет:
> Il 29/04/2014 10:42, Michael Tokarev ha scritto:
>>>>>> >>> > Also replace single instance pstrcpy() in vcard_emul_nss.c
>>>>>> >>> > to strncpy(). This reverts commit 2e679780ae86c6ca8.
>>>> >> An alternative would be to use g_strlcpy which guarantees
>>>> >> nul-termination.
>>> >
>>> > Yes, that is better.
>> Actually in this very place it isn't really important, given we
>> always know the exact length of the source and are able to adjust
>> it to fit into the buffer. With g_strlcat() code becomes a bit
>> more ugly... ;)
>
> Uh, now I looked at NEXT_TOKEN and g_strlcpy suddenly becomes less palatable.
Yess, that's exactly what I mean.
> mempcpy would be nice actually, like
>
> *mempcpy(dest, src, type_params_length) = 0;
>
> but it is not portable and not wrapped by glib.
>
> Another good alternative is
>
> char *type_str;
> ...
> type_str = g_strndup(type_params, type_params_length);
> type = vcard_emul_type_from_string(type_str);
> g_free(type_str);
Actually it is the best one, -- type_str is g_strndup'ed down the line.
I'll do that, in a separate patch before this series.
/mjt
[Qemu-devel] [PATCH 3/5] vscclient: use glib thread primitives not qemu, Michael Tokarev, 2014/04/29
[Qemu-devel] [PATCH 2/5] glib-compat.h: add new thread API emulation on top of pre-2.31 API, Michael Tokarev, 2014/04/29