*/
int cgroup_init()
{
- FILE *proc_mount;
- struct mntent *ent, *temp_ent;
+ FILE *proc_mount = NULL;
+ struct mntent *ent = NULL;
+ struct mntent *temp_ent = NULL;
int found_mnt = 0;
int ret = 0;
static char *controllers[CG_CONTROLLER_MAX];
- FILE *proc_cgroup;
+ FILE *proc_cgroup = NULL;
char subsys_name[FILENAME_MAX];
int hierarchy, num_cgroups, enabled;
int i=0;
- char *mntopt;
+ char *mntopt = NULL;
int err;
- char *buf;
+ char *buf = NULL;
char mntent_buffer[4 * FILENAME_MAX];
- char *strtok_buffer;
+ char *strtok_buffer = NULL;
pthread_rwlock_wrlock(&cg_mount_table_lock);
static int cg_test_mounted_fs()
{
- FILE *proc_mount;
- struct mntent *ent, *temp_ent;
+ FILE *proc_mount = NULL;
+ struct mntent *ent = NULL;
+ struct mntent *temp_ent = NULL;
char mntent_buff[4 * FILENAME_MAX];
int ret = 1;
int cgroup_attach_task_pid(struct cgroup *cgroup, pid_t tid)
{
char path[FILENAME_MAX];
- FILE *tasks;
+ FILE *tasks = NULL;
int i, ret = 0;
if (!cgroup_initialized) {
*/
static int cg_mkdir_p(const char *path)
{
- char *real_path, *wd;
+ char *real_path = NULL;
+ char *wd = NULL;
int i = 0, j = 0;
- char pos, *str;
+ char pos;
+ char *str = NULL;
int ret = 0;
- char cwd[FILENAME_MAX], *buf;
+ char cwd[FILENAME_MAX];
+ char *buf = NULL;
buf = getcwd(cwd, FILENAME_MAX);
if (!buf)
*/
static int cg_set_control_value(char *path, char *val)
{
- FILE *control_file;
+ FILE *control_file = NULL;
if (!cg_test_mounted_fs())
return ECGROUPNOTMOUNTED;
*/
int cgroup_create_cgroup(struct cgroup *cgroup, int ignore_ownership)
{
- char *fts_path[2], base[FILENAME_MAX], *path;
+ char *fts_path[2], base[FILENAME_MAX];
+ char *path = NULL;
int i, j, k;
int error = 0;
int retval = 0;
*/
char *cgroup_find_parent(char *name)
{
- char child[FILENAME_MAX], *parent;
+ char child[FILENAME_MAX];
+ char *parent = NULL;
struct stat stat_child, stat_parent;
- char *type;
- char *dir;
+ char *type = NULL;
+ char *dir = NULL;
pthread_rwlock_rdlock(&cg_mount_table_lock);
type = cg_mount_table[0].name;
int cgroup_create_cgroup_from_parent(struct cgroup *cgroup,
int ignore_ownership)
{
- char *parent;
- struct cgroup *parent_cgroup;
+ char *parent = NULL;
+ struct cgroup *parent_cgroup = NULL;
int ret = ECGFAIL;
if (!cgroup_initialized)
*/
int cgroup_delete_cgroup(struct cgroup *cgroup, int ignore_migration)
{
- FILE *delete_tasks, *base_tasks = NULL;
+ FILE *delete_tasks = NULL, *base_tasks = NULL;
int tids;
char path[FILENAME_MAX];
int error = ECGROUPNOTALLOWED;
static int cg_rd_ctrl_file(char *subsys, char *cgroup, char *file, char **value)
{
char path[FILENAME_MAX];
- FILE *ctrl_file;
+ FILE *ctrl_file = NULL;
int ret;
if (!cg_build_path_locked(cgroup, path, subsys))
static int cgroup_fill_cgc(struct dirent *ctrl_dir, struct cgroup *cgroup,
struct cgroup_controller *cgc, int index)
{
- char *ctrl_name;
- char *ctrl_file;
+ char *ctrl_name = NULL;
+ char *ctrl_file = NULL;
char *ctrl_value = NULL;
- char *d_name;
+ char *d_name = NULL;
char path[FILENAME_MAX+1];
- char *buffer;
+ char *buffer = NULL;
int error = 0;
struct stat stat_buffer;
{
int i;
char path[FILENAME_MAX];
- DIR *dir;
- struct dirent *ctrl_dir;
- char *control_path;
+ DIR *dir = NULL;
+ struct dirent *ctrl_dir = NULL;
+ char *control_path = NULL;
int error;
if (!cgroup_initialized) {
char *controllers[])
{
int ret = 0, i;
- char *controller;
- struct cgroup_controller *cptr;
+ char *controller = NULL;
+ struct cgroup_controller *cptr = NULL;
/* Fill in cgroup details. */
dbg("Will move pid %d to cgroup '%s'\n", pid, dest);
static int cg_prepare_controller_array(char *cstr, char *controllers[])
{
int j = 0;
- char *temp, *saveptr = NULL;
+ char *temp = NULL;
+ char *saveptr = NULL;
do {
if (j == 0)
void cgroup_print_rules_config(FILE *fp)
{
/* Iterator */
- struct cgroup_rule *itr;
+ struct cgroup_rule *itr = NULL;
/* Loop variable */
int i = 0;
int cgroup_get_current_controller_path(pid_t pid, const char *controller,
char **current_path)
{
- char *path;
+ char *path = NULL;
int ret;
- FILE *pid_cgroup_fd;
+ FILE *pid_cgroup_fd = NULL;
if (!controller)
return ECGOTHER;