]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup: Use double pointers everywhere in the get_task APIs
authorDhaval Giani <dhaval@linux.vnet.ibm.com>
Thu, 18 Jun 2009 14:12:47 +0000 (19:42 +0530)
committerDhaval Giani <dhaval@linux.vnet.ibm.com>
Thu, 18 Jun 2009 14:19:39 +0000 (19:49 +0530)
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 <dhaval@linux.vnet.ibm.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
include/libcgroup.h
src/api.c
tests/walk_task.c

index 149a56012330e811ef6b2de5bb1681677d050eaf..dd87c63808624263525e56e77bc60c93e99fdd70 100644 (file)
@@ -301,7 +301,7 @@ int cgroup_get_task_begin(char *cgroup, char *controller, void **handle,
  *
  * 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 */
 
index 2facfc833d77b01135aaa3dfcc689cba48179902..ab35ed7c598b61f9ab5714dc4f9890a80f0e7154 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -2487,7 +2487,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;
 
@@ -2497,7 +2497,7 @@ int cgroup_get_task_next(void *handle, pid_t *pid)
        if (!handle)
                return ECGINVAL;
 
-       ret = fscanf((FILE *) handle, "%u", pid);
+       ret = fscanf((FILE *) *handle, "%u", pid);
 
        if (ret != 1) {
                if (ret == EOF)
@@ -2536,7 +2536,7 @@ int cgroup_get_task_begin(char *cgroup, char *controller, void **handle,
                last_errno = errno;
                return ECGOTHER;
        }
-       ret = cgroup_get_task_next(*handle, pid);
+       ret = cgroup_get_task_next(handle, pid);
 
        return ret;
 }
index fb89963bb9340f88e0d079a4d6b5d46322a70637..42ef32db21f01cd84d1f91bade4bb1404777b031 100644 (file)
@@ -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;