]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api: make cgroup_get_subsys_mount_point_end() more useful
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Mon, 14 Feb 2022 15:11:25 +0000 (08:11 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 14 Feb 2022 15:11:29 +0000 (08:11 -0700)
Currently cgroup_get_subsys_mount_point_end(), does nothing more than
returning zero, it was caught by LGTM altering:
"This expression has no effect (because
cgroup_get_subsys_mount_point_end has no external side effects)."

make the function more useful like other *_end() functions by including
the check for cgroup_initialized and assigning NULL to the handle used
for iterating over controller mount points.

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 8f3a404218332ea8e95119a4c8b11d24370f1fa5..4e3fe470d3e09745bf8f82017b88121b19646840 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -5789,6 +5789,12 @@ int cgroup_get_subsys_mount_point_next(void **handle,
 
 int cgroup_get_subsys_mount_point_end(void **handle)
 {
+       if (!cgroup_initialized)
+               return ECGROUPNOTINITIALIZED;
+       if (!handle)
+               return ECGINVAL;
+
+       *handle = NULL;
        return 0;
 }