basic/fs-util: change CHASE_OPEN flag into a separate output parameter
chase_symlinks() would return negative on error, and either a non-negative status or a non-negative fd when CHASE_OPEN was given. This made the interface quite complicated, because dependning on the flags used, we would get two different "types" of return object. Coverity was always confused by this, and flagged every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it would this that an fd is returned). This patch uses a saparate output parameter, so there is no confusion. (I think it is OK to have functions which return either an error or an fd. It's only returning *either* an fd or a non-fd that is confusing.)
This commit is contained in:
committed by
Yu Watanabe
parent
58ce85f6a1
commit
a5648b8094
@@ -273,7 +273,7 @@ char **path_strv_resolve(char **l, const char *root) {
|
||||
} else
|
||||
t = *s;
|
||||
|
||||
r = chase_symlinks(t, root, 0, &u);
|
||||
r = chase_symlinks(t, root, 0, &u, NULL);
|
||||
if (r == -ENOENT) {
|
||||
if (root) {
|
||||
u = TAKE_PTR(orig);
|
||||
|
||||
Reference in New Issue
Block a user