Unix FD Passing

Havoc Pennington hp at pobox.com
Tue May 12 21:42:47 PDT 2009


Hi,

On Tue, May 12, 2009 at 9:13 PM, Lennart Poettering <mzqohf at 0pointer.de> wrote:
> Fixed. I don't really understand the logic when you put braces and
> when not, though.

My usual rule is that only 1-line bodies can omit, and the if and else
blocks have to match in whether they have braces, so you can't omit on
the else but have braces on the if.

dbus has had various contributors though, it probably is not
completely consistent.

> That is not true. Lot's of "++" everywhere. On iterators,
> on other counters.

I generally use it only for "iterators" (++i, ++p) and never use it
when the prefix vs. postfix matters.
By my grepping that is mostly the rule in the current code, with a
couple exceptions that are basically mistakes.

>> If updating the header field fails, you have to roll back the earlier
>> stuff (close fd and re-decrement n_unix_fds).
>
> Why?
>
> The message is hosed anyway on OOM and the fd is not lost. It has been
> added to the array and will be freed properly when the message itself
> is freed.

I don't remember the full context here. If it does work out then OK,
but do ensure it's clear that it works out on purpose and not by
accident (perhaps a one-line comment, "we rely on xyz" or "this is OK
because we don't handle OOM anyway" or whatever it is)

Havoc


More information about the dbus mailing list