]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
libcgroup Test: suppress-string-constant-warnings-in-compilation
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:22:26 +0000 (15:22 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 17 Dec 2008 15:22:26 +0000 (15:22 +0000)
The following patch removes the string to char * conversion warnings.

Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@276 4f4bb910-9a46-0410-90c8-c897d4f1cd53

tests/libcgrouptest.h
tests/libcgrouptest01.c

index 983d9be901a2c0b167d5308ae2ee566822ce4eb7..1e5295d9e0c2ba92c65f6e1e61c850b56a953ae7 100644 (file)
@@ -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();
index 46d2805de571e451cad1c51afff9eb098da37ac6..690b8fe30197212d11671cc1a60970c9009a895f 100644 (file)
@@ -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);