Close the iterator when cgroup_get_all_controller_next fails. I've rewritten the loop to have one error check for both cgroup_get_all_controller_begin and cgroup_get_all_controller_end.
Signed-off-by: Jan Safranek <jsafr...@redhat.com> --- src/tools/lssubsys.c | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/tools/lssubsys.c b/src/tools/lssubsys.c index 28ef456..d64f6de 100644 --- a/src/tools/lssubsys.c +++ b/src/tools/lssubsys.c @@ -167,8 +167,7 @@ static int cgroup_list_all_controllers(const char *tname, int is_on_list = 0; ret = cgroup_get_all_controller_begin(&handle, &info); - - while (ret != ECGEOF) { + while (ret == 0) { if (info.hierarchy == 0) { /* the controller is not attached to any hierrachy */ if (flags & FL_ALL) @@ -207,15 +206,17 @@ static int cgroup_list_all_controllers(const char *tname, } ret = cgroup_get_all_controller_next(&handle, &info); - if (ret && ret != ECGEOF) { - fprintf(stderr, - "cgroup_get_controller_next failed (%s)\n", - cgroup_strerror(ret)); - return ret; - } + } + cgroup_get_all_controller_end(&handle); + if (ret == ECGEOF) + ret = 0; + if (ret) { + fprintf(stderr, + "cgroup_get_controller_begin/next failed (%s)\n", + cgroup_strerror(ret)); + return ret; } - ret = cgroup_get_all_controller_end(&handle); for (j = 0; j < counter; j++) ret = print_all_controllers_in_hierarchy(tname, ------------------------------------------------------------------------------ EMC VNX: the world's simplest storage, starting under $10K The only unified storage solution that offers unified management Up to 160% more powerful than alternatives and 25% more efficient. Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel