[systemd-devel] [RFC 5/6] proxy-discoveryd: Add the basic parts for handling DBus methods

Lennart Poettering lennart at poettering.net
Fri Apr 10 09:02:33 PDT 2015


On Fri, 10.04.15 15:17, Tomasz Bursztyka (tomasz.bursztyka at linux.intel.com) wrote:

> +
> +static int method_find_proxy(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
> +        _cleanup_free_ char *p = strdup("DIRECT");

Please don't mix variable declarations and function invocations in one
line (also see CODING_STYLE). Also, missing OOM check...

> +        Manager *m = userdata;
> +        int r;
> +
> +        assert(bus);
> +        assert(message);
> +        assert(m);
> +
> +        r = proxy_execute(m->default_proxies, message);
> +        if (r < 0)
> +                sd_bus_reply_method_return(message, "s", p);

Hmm, is this right? Shouldn't we return the error code to the client
instead of eating up and returning "DIRECT"?

Also, why allocate "DIRECT" with strdup() at all?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list