summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-18 19:42:47 +0530
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-06-18 19:49:39 +0530
commit80e9084d3e7be7fbec1ed72f90b88c7626fb93d1 (patch)
treea961561e45079a196bcef67988cdebe98a229218
parent7c8df4bd70091301e8473ef144153d1b2946edd3 (diff)
downloadlibcg-80e9084d3e7be7fbec1ed72f90b88c7626fb93d1.tar.gz
libcg-80e9084d3e7be7fbec1ed72f90b88c7626fb93d1.tar.xz
libcg-80e9084d3e7be7fbec1ed72f90b88c7626fb93d1.zip
libcgroup: Use double pointers everywhere in the get_task APIs
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>
-rw-r--r--include/libcgroup.h2
-rw-r--r--src/api.c6
-rw-r--r--tests/walk_task.c9
3 files changed, 8 insertions, 9 deletions
diff --git a/include/libcgroup.h b/include/libcgroup.h
index 149a560..dd87c63 100644
--- a/include/libcgroup.h
+++ b/include/libcgroup.h
@@ -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 */
diff --git a/src/api.c b/src/api.c
index 2facfc8..ab35ed7 100644
--- 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;
}
diff --git a/tests/walk_task.c b/tests/walk_task.c
index fb89963..42ef32d 100644
--- a/tests/walk_task.c
+++ b/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;