From: Kamalesh Babulal Date: Thu, 30 Jun 2022 14:16:13 +0000 (+0530) Subject: tools/cgset: increase the column width to 100 X-Git-Tag: v3.0~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12503cdd6ca8fb773ed1148cbadfca24b4726ebb;p=thirdparty%2Flibcgroup.git tools/cgset: increase the column width to 100 100 column width is more comfortable to read over 80 columns, lets increase it. This patch, also introduced/removes empty lines across the file, making it more readable. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/tools/cgset.c b/src/tools/cgset.c index 438365aa..efe68a53 100644 --- a/src/tools/cgset.c +++ b/src/tools/cgset.c @@ -42,8 +42,7 @@ static struct cgroup *copy_name_value_from_cgroup(char src_cg_path[FILENAME_MAX] /* copy the name-version values to the cgroup structure */ ret = cgroup_get_cgroup(src_cgroup); if (ret != 0) { - err("cgroup %s error: %s\n", src_cg_path, - cgroup_strerror(ret)); + err("cgroup %s error: %s\n", src_cg_path, cgroup_strerror(ret)); goto scgroup_err; } @@ -64,18 +63,15 @@ static void usage(int status, const char *program_name) } info("Usage: %s [-r ] ...\n", program_name); - info(" or: %s --copy-from ", program_name); - info(" ...\n"); + info(" or: %s --copy-from ...\n", program_name); info("Set the parameters of given cgroup(s)\n"); - info(" -r, --variable Define parameter "); - info("to set\n"); + info(" -r, --variable Define parameter to set\n"); info(" --copy-from Control group whose "); info("parameters will be copied\n"); } #endif /* !UNIT_TEST */ -STATIC int parse_r_flag(const char * const program_name, - const char * const name_value_str, +STATIC int parse_r_flag(const char * const program_name, const char * const name_value_str, struct control_value * const name_value) { char *copy, *buf; @@ -91,8 +87,7 @@ STATIC int parse_r_flag(const char * const program_name, /* parse optarg value */ buf = strtok(copy, "="); if (buf == NULL) { - err("%s: wrong parameter of option -r: %s\n", program_name, - optarg); + err("%s: wrong parameter of option -r: %s\n", program_name, optarg); ret = -1; goto err; } @@ -108,8 +103,7 @@ STATIC int parse_r_flag(const char * const program_name, buf++; if (strlen(buf) == 0) { - err("%s: wrong parameter of option -r: %s\n", program_name, - optarg); + err("%s: wrong parameter of option -r: %s\n", program_name, optarg); ret = -1; goto err; } @@ -140,14 +134,12 @@ int main(int argc, char *argv[]) /* no parameter on input */ if (argc < 2) { - err("Usage is %s -r ", argv[0]); - err("\n"); + err("Usage is %s -r relative path to cgroup>\n", argv[0]); return -1; } /* parse arguments */ - while ((c = getopt_long (argc, argv, - "r:h", long_options, NULL)) != -1) { + while ((c = getopt_long (argc, argv, "r:h", long_options, NULL)) != -1) { switch (c) { case 'h': usage(0, argv[0]); @@ -162,15 +154,11 @@ int main(int argc, char *argv[]) } flags |= FL_RULES; - /* - * add name-value pair to buffer - * (= name_value variable) - */ + /* add name-value pair to buffer (= name_value variable) */ if (nv_number >= nv_max) { nv_max += CG_NV_MAX; name_value = (struct control_value *) - realloc(name_value, - nv_max * sizeof(struct control_value)); + realloc(name_value, nv_max * sizeof(struct control_value)); if (!name_value) { err("%s: not enough memory\n", argv[0]); ret = -1; @@ -178,8 +166,7 @@ int main(int argc, char *argv[]) } } - ret = parse_r_flag(argv[0], optarg, - &name_value[nv_number]); + ret = parse_r_flag(argv[0], optarg, &name_value[nv_number]); if (ret) goto err; @@ -218,15 +205,13 @@ int main(int argc, char *argv[]) /* initialize libcgroup */ ret = cgroup_init(); if (ret) { - err("%s: libcgroup initialization failed: %s\n", argv[0], - cgroup_strerror(ret)); + err("%s: libcgroup initialization failed: %s\n", argv[0], cgroup_strerror(ret)); goto err; } /* copy the name-value pairs from -r options */ if ((flags & FL_RULES) != 0) { - src_cgroup = create_cgroup_from_name_value_pairs( - "tmp", name_value, nv_number); + src_cgroup = create_cgroup_from_name_value_pairs("tmp", name_value, nv_number); if (src_cgroup == NULL) goto err; } @@ -243,8 +228,7 @@ int main(int argc, char *argv[]) cgroup = cgroup_new_cgroup(argv[optind]); if (!cgroup) { ret = ECGFAIL; - err("%s: can't add new cgroup: %s\n", argv[0], - cgroup_strerror(ret)); + err("%s: can't add new cgroup: %s\n", argv[0], cgroup_strerror(ret)); goto cgroup_free_err; } @@ -259,8 +243,7 @@ int main(int argc, char *argv[]) /* modify cgroup based on values of the new one */ ret = cgroup_modify_cgroup(cgroup); if (ret) { - err("%s: cgroup modify error: %s\n", argv[0], - cgroup_strerror(ret)); + err("%s: cgroup modify error: %s\n", argv[0], cgroup_strerror(ret)); goto cgroup_free_err; }