----- Original Message ----- > From: "Libo Chen" <libo.c...@huawei.com> > To: varek...@redhat.com > Cc: "dhaval giani" <dhaval.gi...@gmail.com>, jsafr...@redhat.com, > libcg-devel@lists.sourceforge.net, > lize...@huawei.com, "h huangqiang" huangqi...@huawei.com>, "wengmeiling weng" > <wengmeiling.w...@huawei.com>, > "libo chen" <libo.c...@huawei.com> > Sent: Tuesday, September 3, 2013 10:49:17 AM > Subject: [PATCH v3 4/8] cgconfig: remove redundant variable > > From: Libo Chen <clbchenlibo.c...@huawei.com> > > remove redundant variable ret > > Signed-off-by: Libo Chen <clbchenlibo.c...@huawei.com> > --- > src/tools/cgconfig.c | 11 ++++++----- > 1 files changed, 6 insertions(+), 5 deletions(-) > > diff --git a/src/tools/cgconfig.c b/src/tools/cgconfig.c > index 0b1a2dd..095fe27 100644 > --- a/src/tools/cgconfig.c > +++ b/src/tools/cgconfig.c > @@ -63,7 +63,7 @@ static void usage(char *progname) > int main(int argc, char *argv[]) > { > int c, i; > - int ret, error = 0; > + int error = 0; > static struct option options[] = { > {"help", 0, 0, 'h'}, > {"load", 1, 0, 'l'}, > @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) > if (argc < 2) > usage(argv[0]); /* usage() exits */ > > - ret = cgroup_string_list_init(&cfg_files, argc/2); > + error = cgroup_string_list_init(&cfg_files, argc/2); > > while ((c = getopt_long(argc, argv, "hl:L:t:a:d:f:s:", options, > NULL)) > 0) { > @@ -98,11 +98,11 @@ int main(int argc, char *argv[]) > usage(argv[0]); > break; > case 'l': > - ret = cgroup_string_list_add_item(&cfg_files, > optarg); > - if (ret) { > + error = cgroup_string_list_add_item(&cfg_files, > optarg); > + if (error) { > fprintf(stderr, "%s: cannot add file to > list,"\ > " out of memory?\n", > argv[0]); > - exit(1); > + goto err; > } > break; > case 'L': > @@ -170,6 +170,7 @@ int main(int argc, char *argv[]) > } > > for (i = 0; i < cfg_files.count; i++) { > + int ret; I prefer to define variable at the beginning of the function. But I agree with the second and third hunk. > ret = cgroup_config_load_config(cfg_files.items[i]); > if (ret) { > fprintf(stderr, "%s; error loading %s: %s\n", > argv[0], > -- > 1.7.1 > > >
------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel