[systemd-devel] [PATCH] Log failing start conditions

Lennart Poettering lennart at poettering.net
Thu Jul 18 10:09:50 PDT 2013


On Thu, 18.07.13 15:47, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> > Now, in both cases the externally visible type is actually a bool, even
> > if we internally distuingish three different states. For the condition
> > stuff it is necessary to *actually* distuingish three states on the wire
> > too. D-Bus doesn't know this natively however.
> > 
> > Maybe use a string and map > 0 to "t", 0 to "f" and < 0 to ""?
> > 
> > static inline const char* tristate_to_string(int v) {
> >        return v > 0 ? "t" : 
> >              v == 0 ? "f" : "";
> > }
> > 
> > Or something like that?
> > 
> > Sounds a bit more future proof that way I think. 
> > 
> > What I am afraid of here is that if we expose tristate-as-int on the bus
> > that people will actually assume -1 and 1 are the values to check for,
> > even though we actually mean < 0 and > 0...
> I don't see why anybody would assume that, if is is explicitly documented
> (something like "The value is < 0, currently -1 is always used, but we
> reserve the possibility of extending the range of values used to carry
> additional information. So you should use 'state < 0' as the condition
> for a failed condition.")
> 
> I'm worried that numbers are easier to carry additional data
> (e.g. errno), and if strings are used, the interface will be hard to
> extend without breaking users who expect "f" for failure.

Well, regarding "f" and "t", of course "yes" and "no" would work too,
the same way as yesno() already handles that...

But hmm, maybe the tristate-as-int thing is actually not that bad, so
let's leave this in.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list