On Sun, 17.08.14 09:45, Michael Olbrich (m.olbr...@pengutronix.de) wrote:

> This avoids errors like this, when the paths are already there with the
> correct permissions and owner:
> 
> chmod(/var/spool) failed: Read-only file system

Applied! Thanks!

> The original code checked for 'stat() >= 0'. Any reason for that? My
> man-page says 'On success, zero is returned'.

Well, I usually check for "< 0" on failure and ">= 0" on success. It's
usually how things are done, on libc, and on our own code (our code just
gets one step further and returns -errno on error...

But yeah, it's not much of a difference, both works, but I think it's
slightly clearer to just check for negativity/non-negativity, since
usually positive values indicate non-errors, and negative ones errors,
even if in this case one can check for less.

Or to turn this around: if stat() would someday return 1 instead of 0,
for some reason, then I'd assume that this wouldn#t indicate an error,
but just some other form of success...

Lennart

-- 
Lennart Poettering, Red Hat
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to