[systemd-devel] [PATCH 4/7] bus: rename sd_bus_get_property_{trivial, basic}

Lennart Poettering lennart at poettering.net
Thu Nov 7 10:32:15 PST 2013


On Thu, 07.11.13 19:15, Lennart Poettering (lennart at poettering.net) wrote:

> On Thu, 07.11.13 13:49, Marc-Antoine Perennou (Marc-Antoine at Perennou.com) wrote:
> 
> This one is unfortunately not that easy. The reason this checks for
> trivial and not basic types is that strings (which are basic, but not
> trivial) are pointers in C. Usually we just return pointers into the
> actual message. However, in this case the message is freed before
> returning from sd_bus_get_property_trivial(), hence we cannot do
> this. The alternative would be to allocate the thing from the heap and
> return that, but that means the caller must know that and free it
> afterwards. But those would be quite surprising semantics, especially
> given that sd_bus_read_basic() does not require this, and the non-string
> basic types require neither.
> 
> I can see though that it would be a good thing to read strings with an
> easy call. I am hence going to add a separate call for this now, which
> hopefully makes this a bit more understandable.

I now added sd_bus_get_property_string() and sd_bus_get_property_strv()
to make it easy to read strings and strv properties. For both of them
the result must be freed.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list