On Mon, Aug 06, 2012 at 03:09:51PM -0600, Eric Blake wrote: > On 08/03/2012 12:36 AM, Hu Tao wrote: > > From: Wen Congyang <wency@xxxxxxxxxxxxxx> > > > > Introduce a new API to move tasks of one controller from a cgroup to another cgroup > > > > Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx> > > Signed-off-by: Tang Chen <tangchen@xxxxxxxxxxxxxx> > > Signed-off-by: Hu Tao <hutao@xxxxxxxxxxxxxx> > > --- > > > +static int virCgroupAddTaskStrController(virCgroupPtr group, > > + const char *pidstr, > > + int controller) > > +{ > > + char *str = NULL, *cur = NULL, *next = NULL; > > + unsigned long long p = 0; > > + int rc = 0; > > + > > + if (virAsprintf(&str, "%s", pidstr) < 0) > > + return -1; > > + > > + cur = str; > > + while ((next = strchr(cur, '\n')) != NULL) { > > + *next = '\0'; > > + rc = virStrToLong_ull(cur, NULL, 10, &p); > > + if (rc != 0) > > + goto cleanup; > > + cur = next + 1; > > + > > + rc = virCgroupAddTaskController(group, p, controller); > > + if (rc != 0) > > + goto cleanup; > > + } > > + if (cur != '\0') { > > + rc = virStrToLong_ull(cur, NULL, 10, &p); > > + if (rc != 0) > > + goto cleanup; > > + rc = virCgroupAddTaskController(group, p, controller); > > + if (rc != 0) > > + goto cleanup; > > + } > > Can this last if statement be folded into the while loop for less code > duplication? If the series passes review now, then I'm probably not > worried enough to change it and would probably push as is; but if we > need a v2, then it's worth improving. OK, I'll improve it. -- Thanks, Hu Tao -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list