From d335dc3def8568d7b2518d4c037cdce89da4ee29 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Wed, 17 Dec 2008 15:22:26 +0000 Subject: libcgroup Test: suppress-string-constant-warnings-in-compilation The following patch removes the string to char * conversion warnings. Signed-off-by: Sudhir Kumar git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@276 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcgrouptest.h | 10 ++++++---- tests/libcgrouptest01.c | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/libcgrouptest.h b/tests/libcgrouptest.h index 983d9be..1e5295d 100644 --- a/tests/libcgrouptest.h +++ b/tests/libcgrouptest.h @@ -79,10 +79,11 @@ char extra[SIZE] = "\n"; /* Functions to test each API */ void test_cgroup_init(int retcode, int i); void test_cgroup_attach_task(int retcode, struct cgroup *cgroup1, - char *group1, char *group2, int fs_info, int k, int i); + const char *group1, const char *group2, + int fs_info, int k, int i); /* API test functions end here */ -void get_controllers(char *name, int *exist); +void get_controllers(const char *name, int *exist); static int group_exist(char *path_group); static int set_controller(int controller, char *controller_name, char *control_file); @@ -94,9 +95,10 @@ struct cgroup *new_cgroup(char *group, char *controller_name, int check_fsmounted(int multimnt); static int check_task(char *tasksfile); /* function to print messages in better format */ -static inline void message(int num, int pass, char *api, int ret, char *extra); +static inline void message(int num, int pass, const char *api, + int ret, char *extra); static inline void build_path(char *target, char *mountpoint, - char *group, char *file); + const char *group, const char *file); /* Allocate memory and populate info messages */ void set_info_msgs(); diff --git a/tests/libcgrouptest01.c b/tests/libcgrouptest01.c index 46d2805..690b8fe 100644 --- a/tests/libcgrouptest01.c +++ b/tests/libcgrouptest01.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) char group[FILENAME_MAX]; /* Get controllers name from script */ - int ctl1, ctl2; + int ctl1 = CPU, ctl2 = MEMORY; if ((argc < 2) || (argc > 6) || (atoi(argv[1]) < 0)) { printf("ERROR: Wrong no of parameters recieved from script\n"); @@ -954,7 +954,8 @@ void test_cgroup_init(int retcode, int i) } void test_cgroup_attach_task(int retcode, struct cgroup *cgrp, - char *group1, char *group2, int fs_info, int k, int i) + const char *group1, const char *group2, + int fs_info, int k, int i) { int retval; char tasksfile[FILENAME_MAX], tasksfile2[FILENAME_MAX]; @@ -995,11 +996,11 @@ void test_cgroup_attach_task(int retcode, struct cgroup *cgrp, info[5]); } } else { - message(i, FAIL, "attach_task()", retval, "\n"); + message(i, FAIL, "attach_task()", retval, (char *)"\n"); } } -void get_controllers(char *name, int *exist) +void get_controllers(const char *name, int *exist) { int hierarchy, num_cgroups, enabled; FILE *fd; @@ -1151,6 +1152,7 @@ struct cgroup *new_cgroup(char *group, char *controller_name, char wr[SIZE]; /* Names of wrapper apis */ struct cgroup *newcgroup; struct cgroup_controller *newcontroller; + newcgroup = cgroup_new_cgroup(group); if (newcgroup) { @@ -1158,11 +1160,12 @@ struct cgroup *new_cgroup(char *group, char *controller_name, control_uid, control_gid); if (retval) { - printf("Test[1:%2d]\tFAIL: cgroup_set_uid_gid()\n", - ++i); + snprintf(wr, SIZE, "set_uid_gid()"); + message(i++, FAIL, wr, retval, extra); } - newcontroller = cgroup_add_controller(newcgroup, controller_name); + newcontroller = cgroup_add_controller(newcgroup, + controller_name); if (newcontroller) { retval = add_control_value(newcontroller, control_file, wr, value_type); @@ -1250,7 +1253,7 @@ static int check_task(char *tasksfile) return pass; } -static inline void message(int num, int pass, char *api, +static inline void message(int num, int pass, const char *api, int retval, char *extra) { char res[10]; @@ -1267,7 +1270,7 @@ static inline void message(int num, int pass, char *api, /* builds the path to target file/group */ static inline void build_path(char *target, char *mountpoint, - char *group, char *file) + const char *group, const char *file) { strncpy(target, mountpoint, FILENAME_MAX); -- cgit