[systemd-devel] [PATCH] timedatectl: work with old timedated

Lennart Poettering lennart at poettering.net
Thu Dec 12 06:36:47 PST 2013


On Wed, 11.12.13 14:04, Shawn Landden (shawn at churchofgit.com) wrote:

> Which does have TimeUSec. Should we specifically check for this method
> instead of assuming time=0 means it doesn't exist?

Sounds OK to just check against time == 0.

>  
> +        if (i->time)

For numeric values please always check with explicit numerical
comparison. Something like this:

if (i->time > 0) 

or so..

> +                sec = (time_t) (i->time / USEC_PER_SEC);
> +        else if (arg_transport == BUS_TRANSPORT_LOCAL)
> +                sec = time(NULL);
> +        else
> +                return (void)fprintf(stderr, "Could not get time from
> timedated and not operating locally.\n\n");

I am pretty sure we shouldn't exit here. We should instead show a line
of "n/a" or so for this value. 

Also please do not do stuff like "return (void) printf()"... We are not
in a contest to write non-obvious C code....

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list