]> xenbits.xensource.com Git - libvirt.git/commitdiff
virFileRemoveXAttr: Report error on failure
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Mar 2019 14:41:06 +0000 (15:41 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Jul 2019 06:36:03 +0000 (08:36 +0200)
It's better to have the function report errors, because none of
the callers does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virfile.c

index 75ec9e0bd8056f8985b346279717fde191f94d8c..b351f72bef8cd7187758d567eaf132c80d51eebe 100644 (file)
@@ -4446,13 +4446,20 @@ virFileSetXAttr(const char *path,
  * Remove xattr of @name on @path.
  *
  * Returns: 0 on success,
- *         -1 otherwise (with errno set).
+ *         -1 otherwise (with errno set AND error reported).
  */
 int
 virFileRemoveXAttr(const char *path,
                    const char *name)
 {
-    return removexattr(path, name);
+    if (removexattr(path, name) < 0) {
+        virReportSystemError(errno,
+                             _("Unable to remove XATTR %s on %s"),
+                             name, path);
+        return -1;
+    }
+
+    return 0;
 }
 
 #else /* !HAVE_LIBATTR */
@@ -4479,10 +4486,13 @@ virFileSetXAttr(const char *path,
 }
 
 int
-virFileRemoveXAttr(const char *path ATTRIBUTE_UNUSED,
-                   const char *name ATTRIBUTE_UNUSED)
+virFileRemoveXAttr(const char *path,
+                   const char *name)
 {
     errno = ENOSYS;
+    virReportSystemError(errno,
+                         _("Unable to remove XATTR %s on %s"),
+                         name, path);
     return -1;
 }