mirror of
https://github.com/ericonr/util-linux.git
synced 2024-04-21 09:12:35 -05:00
libsmartcols: make child-parent reference more robust [clang analyze]
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
a172badb03
commit
fdd68e25b5
@ -214,20 +214,19 @@ int scols_line_add_child(struct libscols_line *ln, struct libscols_line *child)
|
|||||||
if (!ln || !child)
|
if (!ln || !child)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
DBG(LINE, ul_debugobj(ln, "add child %p", child));
|
||||||
|
scols_ref_line(child);
|
||||||
|
scols_ref_line(ln);
|
||||||
|
|
||||||
/* unref old<->parent */
|
/* unref old<->parent */
|
||||||
if (child->parent)
|
if (child->parent)
|
||||||
scols_line_remove_child(child->parent, child);
|
scols_line_remove_child(child->parent, child);
|
||||||
|
|
||||||
DBG(LINE, ul_debugobj(ln, "add child %p", child));
|
|
||||||
|
|
||||||
/* new reference from parent to child */
|
/* new reference from parent to child */
|
||||||
list_add_tail(&child->ln_children, &ln->ln_branch);
|
list_add_tail(&child->ln_children, &ln->ln_branch);
|
||||||
scols_ref_line(child);
|
|
||||||
|
|
||||||
/* new reference from child to parent */
|
/* new reference from child to parent */
|
||||||
child->parent = ln;
|
child->parent = ln;
|
||||||
scols_ref_line(ln);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user