Skip to content

Commit

Permalink
xattr: check for ENOATTR when available
Browse files Browse the repository at this point in the history
This suppresses this unhelpful warning on macOS:

WARNING: failed to getxattr for some_file: Attribute not found

Also, return the system call result (0 or -1) from rm_xattr_is_fail
instead of the errno value. Although not currently used, this return
value is more idiomatic.

Fixes #431
  • Loading branch information
cebtenzzre committed Jun 20, 2023
1 parent 90a88cf commit 00d2018
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,19 @@ static int rm_xattr_is_fail(const char *name, char *path, int rc) {
return 0;
}

if(errno != ENOTSUP && errno != ENODATA) {
rm_log_warning_line("failed to %s for %s: %s", name, path, g_strerror(errno));
return errno;
if(errno == ENOTSUP || errno == ENODATA) {
return 0;
}

return 0;
#ifdef ENOATTR
/* Mac OS X, *BSD, etc. */
if(errno == ENOATTR) {
return 0;
}
#endif

rm_log_warning_line("failed to %s for %s: %s", name, path, g_strerror(errno));
return rc;
}

static int rm_xattr_set(RmFile *file,
Expand Down

0 comments on commit 00d2018

Please sign in to comment.