Since the functions only return 0 or 1, they should return bool (missed the change in the first commit). That way it's clearer that the check for non-existing group should be either "== 0" instead. Fix this by using proper negation instead. Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/qemu/qemu_conf.c | 4 ++-- src/util/virutil.c | 8 ++++---- src/util/virutil.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 32da9a735184..a946b05d5d47 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -193,10 +193,10 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) if (virAsprintf(&cfg->swtpmStorageDir, "%s/lib/libvirt/swtpm", LOCALSTATEDIR) < 0) goto error; - if (virDoesUserExist("tss") != 0 || + if (!virDoesUserExist("tss") || virGetUserID("tss", &cfg->swtpm_user) < 0) cfg->swtpm_user = 0; /* fall back to root */ - if (virDoesGroupExist("tss") != 0 || + if (!virDoesGroupExist("tss") || virGetGroupID("tss", &cfg->swtpm_group) < 0) cfg->swtpm_group = 0; /* fall back to root */ } else { diff --git a/src/util/virutil.c b/src/util/virutil.c index c0783ecb285b..1407c026e298 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1133,7 +1133,7 @@ virGetGroupID(const char *group, gid_t *gid) /* Silently checks if User @name exists. * Returns if the user exists and fallbacks to false on error. */ -int +bool virDoesUserExist(const char *name) { return virGetUserIDByName(name, NULL, true) == 0; @@ -1142,7 +1142,7 @@ virDoesUserExist(const char *name) /* Silently checks if Group @name exists. * Returns if the group exists and fallbacks to false on error. */ -int +bool virDoesGroupExist(const char *name) { return virGetGroupIDByName(name, NULL, true) == 0; @@ -1243,13 +1243,13 @@ virGetGroupList(uid_t uid ATTRIBUTE_UNUSED, gid_t gid ATTRIBUTE_UNUSED, return 0; } -int +bool virDoesUserExist(const char *name ATTRIBUTE_UNUSED) { return 0; } -int +bool virDoesGroupExist(const char *name ATTRIBUTE_UNUSED) { return 0; diff --git a/src/util/virutil.h b/src/util/virutil.h index 2407f54efd47..e0ab0da0f2fc 100644 --- a/src/util/virutil.h +++ b/src/util/virutil.h @@ -152,8 +152,8 @@ int virGetUserID(const char *name, int virGetGroupID(const char *name, gid_t *gid) ATTRIBUTE_RETURN_CHECK; -int virDoesUserExist(const char *name); -int virDoesGroupExist(const char *name); +bool virDoesUserExist(const char *name); +bool virDoesGroupExist(const char *name); bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); -- 2.19.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list