[libvirt] [libvirt-glib 2/2] RFC: Make use of GUINT_TO_POINTER/GPOINTER_TO_UINT

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Tue Jul 31 10:09:31 UTC 2012


On Mon, Jul 30, 2012 at 7:09 PM, Marc-André Lureau
<marcandre.lureau at gmail.com> wrote:
> On Mon, Jul 30, 2012 at 6:30 PM, Zeeshan Ali (Khattak)
> <zeeshanak at gnome.org> wrote:
>> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
>>
>> We create struct and a free function each time we need to pass a simple
>> unsigned integer to an async function. Code can be simplified if we
>> don't do that but rather use glib's API to convert to/from uint to
>> pointer.
>>
>> This patch only changes this for one of these functions. I'll change
>> other functions when/if there is a consensus on this..
>
> Personally, I prefer consistency with the rest of the async functions,

Me too and thats why I said I'll change it everywhere if we agree this
is better.

> and I often found myself replacing GUINT_TO_POINTER "trick" with a
> real pointer to a structure that can be extended.

Although its a trick, its pretty safe to keep 32-bit integers as
pointers (the other way around isn't true AFAIK). All this is internal
so we can always switch back to structs if/when needed and its
trivial. Keeping in mind that there isn't a very good chance of us
needing more fields of most async calls.

Another way to simply would to have just one struct/free function for
functions that take only flags argument but that won't be as simple.
I'd rather keep the code as simple as possible as long as its
guaranteed to work.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124




More information about the libvir-list mailing list