> *At line 2131 is a for loop that re-uses the index variable of the for
> loop at 2122.
> Should there be 2 variables one for each loop?

So if I am right, the code for this is,

        for (i = 0; i < CG_CONTROLLER_MAX; i++) {
                int j = 0;
                if (!controllers[i])
                        return 0;
                controller = controllers[i];

                /* If first string is "*" that means all the mounted
                 * controllers. */
                if (strcmp(controller, "*") == 0) {
                        pthread_rwlock_rdlock(&cg_mount_table_lock);
                        for (i = 0; i < CG_CONTROLLER_MAX &&
                                cg_mount_table[i].name[0] != '\0'; i++) {
                                cgroup_dbg("Adding controller %s\n",
                                        cg_mount_table[i].name);
                                cptr = cgroup_add_controller(cgroup,
                                                cg_mount_table[i].name);
                                if (!cptr) {
                                        cgroup_dbg("Adding controller '%s'"
                                                " failed\n",
                                                cg_mount_table[i].name);

pthread_rwlock_unlock(&cg_mount_table_lock);
                                        cgroup_free_controllers(cgroup);
                                        return ECGROUPNOTALLOWED;
                                }
                        }
                        pthread_rwlock_unlock(&cg_mount_table_lock);
                        return ret;
                }

(sorry for the gmail paste)

Now, this is safe since the inner loop does not exit out of the loop.
It will always return out, so its just fine. Having said that, it is
ugly and hard to read, so I am just putting up a patch adding the
extra counter.

Dhaval

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to