[systemd-devel] [PATCH 1/2] util: add files_same() helper function
Lennart Poettering
lennart at poettering.net
Wed Mar 5 10:18:53 PST 2014
On Wed, 05.03.14 14:37, harald at redhat.com (harald at redhat.com) wrote:
> - return
> - a.st_dev != b.st_dev ||
> - a.st_ino != b.st_ino;
> + return (a.st_dev == b.st_dev && a.st_ino == b.st_ino);
No need for the extra "()"...
> +}
> +
> +int running_in_chroot(void) {
> + int ret = files_same("/proc/1/root", "/");
Please avoid calling functions in variable declarations. We try to avoid
that in our code, to keep variable declarations and code seperate
(initialization with a constant value is fine).
> +
> + if (ret < 0)
> + return ret;
> +
> + return (ret == 0);
No need for the extra "()"....
Otherwise looks good.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list