It's better to have the function report errors, because none of
the callers does.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virfile.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 7ce4b1dbc2..fbcab404e7 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -4395,14 +4395,21 @@ virFileGetXAttrQuiet(const char *path,
* Sets xattr of @name and @value on @path.
*
* Returns: 0 on success,
- * -1 otherwise (with errno set).
+ * -1 otherwise (with errno set AND error reported).
*/
int
virFileSetXAttr(const char *path,
const char *name,
const char *value)
{
- return setxattr(path, name, value, strlen(value), 0);
+ if (setxattr(path, name, value, strlen(value), 0) < 0) {
+ virReportSystemError(errno,
+ _("Unable to set XATTR %s on %s"),
+ name, path);
+ return -1;
+ }
+
+ return 0;
}
/**
@@ -4434,11 +4441,14 @@ virFileGetXAttrQuiet(const char *path ATTRIBUTE_UNUSED,
}
int
-virFileSetXAttr(const char *path ATTRIBUTE_UNUSED,
- const char *name ATTRIBUTE_UNUSED,
+virFileSetXAttr(const char *path,
+ const char *name,
const char *value ATTRIBUTE_UNUSED)
{
errno = ENOSYS;
+ virReportSystemError(errno,
+ _("Unable to set XATTR %s on %s"),
+ name, path);
return -1;
}
--
2.19.2