On Wed, Sep 12, 2018 at 05:09:12PM +0200, Martin Kletzander wrote:
Instead of duplicating the code from virGet{User,Group}IDByName(), which are
static anyway, extend those functions to accept NULL pointers for the result and
a boolean for controlling the error reporting.

Signed-off-by: Martin Kletzander <[email protected]>
---
Feel free to suggest any other way of doing this, I just felt like this is the
most readable way of doing things

src/libvirt_private.syms |  2 ++
src/util/virutil.c       | 40 ++++++++++++++++++++++++++++++++--------
src/util/virutil.h       |  4 ++++
3 files changed, 38 insertions(+), 8 deletions(-)


+/* Silently checks if Group @name exists.
+ * Returns if the group exists and fallbacks to false on error.
+ */
+int
+virDoesGroupExist(const char *name)

util/virutil.c:1142:42: error: unused parameter 'exists' 
[-Werror,-Wunused-parameter]
virDoesUserExist(const char *name, bool *exists)
                                        ^
util/virutil.c:1151:1: error: conflicting types for 'virDoesGroupExist'
virDoesGroupExist(const char *name)


+{
+    return virGetGroupIDByName(name, NULL, true) == 0;
+}
+

/* Compute the list of primary and supplementary groups associated
 * with @uid, and including @gid in the list (unless it is -1),

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to