xattr-util: add missing assertions

Follow-up for ed024abac6
and 9fbe26cfa8

Also, let's not get too tangled up in the style of defining variables
in between. The functions are short enough, and vars involved are still
effectively at the beginning... Put differently, the separation from
'int r' is too deliberate and brings no actual value in my eyes.
This commit is contained in:
Mike Yuan
2025-03-31 19:23:49 +02:00
parent ebc0514a65
commit 05587cece5
2 changed files with 9 additions and 6 deletions
+8 -5
View File
@@ -192,10 +192,11 @@ int getxattr_at_bool(int fd, const char *path, const char *name, int at_flags) {
}
int getxattr_at_strv(int fd, const char *path, const char *name, int at_flags, char ***ret_strv) {
_cleanup_free_ char *nulstr = NULL;
size_t nulstr_size;
int r;
_cleanup_free_ char *nulstr = NULL;
size_t nulstr_size = 0;
assert(ret_strv);
r = getxattr_at_malloc(fd, path, name, at_flags, &nulstr, &nulstr_size);
if (r < 0)
@@ -343,11 +344,13 @@ int xsetxattr_full(
return 0;
}
int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char * const* l) {
int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char * const *l) {
_cleanup_free_ char *nulstr = NULL;
size_t size;
int r;
_cleanup_free_ char *nulstr = NULL;
size_t size = 0;
assert(name);
r = strv_make_nulstr(l, &nulstr, &size);
if (r < 0)
return r;
+1 -1
View File
@@ -50,7 +50,7 @@ static inline int xsetxattr(
return xsetxattr_full(fd, path, at_flags, name, value, SIZE_MAX, 0);
}
int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char *const*l);
int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char * const *l);
int xremovexattr(int fd, const char *path, int at_flags, const char *name);