From: Libo Chen Date: Tue, 10 Sep 2013 06:13:56 +0000 (+0200) Subject: cgconfig: add err check X-Git-Tag: v0.41~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b771e72888a9e52079ef4e763f2718413268b454;p=thirdparty%2Flibcgroup.git cgconfig: add err check cgroup still can be created even if giving invalid -d,-f,-s parameter. e.g. cgconfigparser -d 888 -l /etc/cgconfig.conf "888" is invalid, but cgroup will be created. So we should exit when -d,-f or -s is invalid. v3: - add nonzero return value - use error instead of ret Signed-off-by: Libo Chen Acked-by: Ivana Hutarova Varekova --- diff --git a/src/tools/cgconfig.c b/src/tools/cgconfig.c index 6aeea0f3..81d07c99 100644 --- a/src/tools/cgconfig.c +++ b/src/tools/cgconfig.c @@ -121,15 +121,21 @@ int main(int argc, char *argv[]) break; case 'd': dirm_change = 1; - ret = parse_mode(optarg, &dir_mode, argv[0]); + error = parse_mode(optarg, &dir_mode, argv[0]); + if (error) + goto err; break; case 'f': filem_change = 1; - ret = parse_mode(optarg, &file_mode, argv[0]); + error = parse_mode(optarg, &file_mode, argv[0]); + if (error) + goto err; break; case 's': filem_change = 1; - ret = parse_mode(optarg, &tasks_mode, argv[0]); + error = parse_mode(optarg, &tasks_mode, argv[0]); + if (error) + goto err; break; default: usage(argv[0]);