]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api.c: fix a comparison error in cgroup_delete_cgroup_ext()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 14 Feb 2022 15:11:39 +0000 (08:11 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 14 Feb 2022 15:11:44 +0000 (08:11 -0700)
Fix a comparison logic in the first_errno assignment, that would
never get executed in the case of first_errno == ECGNONEMPTY in
cgroup_delete_cgroup_ext().

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c

index 4e3fe470d3e09745bf8f82017b88121b19646840..ab24fdb3919d84a282eced3b67881eac1501cb97 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -3072,13 +3072,14 @@ int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags)
                 * error code, but continue with next controller and try remove
                 * the group from all of them.
                 */
-               if (ret != 0 && first_error == 0) {
+               if (ret) {
                        /*
                         * ECGNONEMPTY is more or less not an error, but an
                         * indication that something was not removed.
                         * Therefore it should be replaced by any other error.
                         */
-                       if (ret != ECGNONEMPTY || first_error == ECGNONEMPTY) {
+                       if (ret != ECGNONEMPTY &&
+                           (first_error == 0 || first_errno == ECGNONEMPTY)) {
                                first_errno = last_errno;
                                first_error = ret;
                        }