As Jan Safranek pointed out, it is better to have double pointers
everywhere in the get_task API to keep consistency. Do the same.

Signed-off-by: Dhaval Giani <[email protected]>

---
 include/libcgroup.h |    2 +-
 src/api.c           |    6 +++---
 tests/walk_task.c   |    9 ++++-----
 3 files changed, 8 insertions(+), 9 deletions(-)

Index: libcg/src/api.c
===================================================================
--- libcg.orig/src/api.c
+++ libcg/src/api.c
@@ -2472,7 +2472,7 @@ int cgroup_get_task_end(void **handle)
        return 0;
 }
 
-int cgroup_get_task_next(void *handle, pid_t *pid)
+int cgroup_get_task_next(void **handle, pid_t *pid)
 {
        int ret;
 
@@ -2482,7 +2482,7 @@ int cgroup_get_task_next(void *handle, p
        if (!handle)
                return ECGINVAL;
 
-       ret = fscanf((FILE *) handle, "%u", pid);
+       ret = fscanf((FILE *) *handle, "%u", pid);
 
        if (ret != 1) {
                if (ret == EOF)
@@ -2521,7 +2521,7 @@ int cgroup_get_task_begin(char *cgroup, 
                last_errno = errno;
                return ECGOTHER;
        }
-       ret = cgroup_get_task_next(*handle, pid);
+       ret = cgroup_get_task_next(handle, pid);
 
        return ret;
 }
Index: libcg/tests/walk_task.c
===================================================================
--- libcg.orig/tests/walk_task.c
+++ libcg/tests/walk_task.c
@@ -8,7 +8,7 @@ int main(int argc, char *argv[])
 {
        int ret, i;
        char *group = NULL;
-       FILE *tasks = NULL;
+       void *handle;
 
        if (argc < 2) {
                printf("No list of groups provided\n");
@@ -26,11 +26,10 @@ int main(int argc, char *argv[])
                pid_t pid;
                group = strdup(argv[i]);
                printf("Printing the details of groups %s\n", group);
-               ret = cgroup_get_task_begin(group, "cpu", (void *) &tasks,
-                                                                       &pid);
+               ret = cgroup_get_task_begin(group, "cpu", &handle, &pid);
                while (!ret) {
                        printf("Pid is %u\n", pid);
-                       ret = cgroup_get_task_next((void *) tasks, &pid);
+                       ret = cgroup_get_task_next(&handle, &pid);
                        if (ret && ret != ECGEOF) {
                                printf("cgroup_get_task_next failed with %s\n",
                                                        cgroup_strerror(ret));
@@ -42,7 +41,7 @@ int main(int argc, char *argv[])
                }
                free(group);
                group = NULL;
-               ret = cgroup_get_task_end((void **) &tasks);
+               ret = cgroup_get_task_end(&handle);
        }
 
        return 0;
Index: libcg/include/libcgroup.h
===================================================================
--- libcg.orig/include/libcgroup.h
+++ libcg/include/libcgroup.h
@@ -301,7 +301,7 @@ int cgroup_get_task_begin(char *cgroup, 
  *
  * return ECGEOF when the iterator finishes getting the list of tasks.
  */
-int cgroup_get_task_next(void *handle, pid_t *pid);
+int cgroup_get_task_next(void **handle, pid_t *pid);
 int cgroup_get_task_end(void **handle);
 /* The wrappers for filling libcg structures */
 



------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to