On 08/11/2011 08:44 PM, Dhaval Giani wrote: > On Thu, Aug 11, 2011 at 9:03 AM, Jan Safranek <jsafr...@redhat.com> wrote: >> 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. >> > > So we fail on the first failure, and not print the others we can still query?
If an iterator returns error, then I suppose it won't return any useful data anymore and it's worthless trying. > >> 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, >> >> >> ------------------------------------------------------------------------------ >> Get a FREE DOWNLOAD! and learn more about uberSVN rich system, >> user administration capabilities and model configuration. Take >> the hassle out of deploying and managing Subversion and the >> tools developers use with it. >> http://p.sf.net/sfu/wandisco-dev2dev >> _______________________________________________ >> Libcg-devel mailing list >> Libcg-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/libcg-devel >> ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel