From: Kamalesh Babulal Date: Tue, 22 Mar 2022 10:04:13 +0000 (+0530) Subject: cgconfig.c: adopt err()/info() for printing messages X-Git-Tag: v3.0~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ea10c5d2fb405974d4b626239bab6539c28969e;p=thirdparty%2Flibcgroup.git cgconfig.c: adopt err()/info() for printing messages Replace usage of fprintf(stderr, ...) with err() and printf(...) with info(). Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/tools/cgconfig.c b/src/tools/cgconfig.c index 7d37d5ec..46842323 100644 --- a/src/tools/cgconfig.c +++ b/src/tools/cgconfig.c @@ -32,29 +32,30 @@ static struct cgroup_string_list cfg_files; static void usage(int status, char *progname) { if (status != 0) { - fprintf(stderr, "Wrong input parameters, "); - fprintf(stderr, "try %s -h' for more information.\n", progname); + err("Wrong input parameters, "); + err("try %s '-h' for more information.\n", progname); return; } - printf("Usage: %s [-h] [-f mode] [-d mode] [-s mode] ", progname); - printf("[-t :] [-a :] [-l FILE] "); - printf("[-L DIR] ...\n"); - printf("Parse and load the specified cgroups configuration file\n"); - printf(" -a : Default owner of groups "); - printf("files and directories\n"); - printf(" -d, --dperm=mode Default group directory "); - printf("permissions\n"); - printf(" -f, --fperm=mode Default group file "); - printf("permissions\n"); - printf(" -h, --help Display this help\n"); - printf(" -l, --load=FILE Parse and load the cgroups "); - printf("configuration file\n"); - printf(" -L, --load-directory=DIR Parse and load the cgroups "); - printf("configuration files from a directory\n"); - printf(" -s, --tperm=mode Default tasks file "); - printf("permissions\n"); - printf(" -t : Default owner of the tasks "); - printf("file\n"); + + info("Usage: %s [-h] [-f mode] [-d mode] [-s mode] ", progname); + info("[-t :] [-a :] [-l FILE] "); + info("[-L DIR] ...\n"); + info("Parse and load the specified cgroups configuration file\n"); + info(" -a : Default owner of groups "); + info("files and directories\n"); + info(" -d, --dperm=mode Default group directory "); + info("permissions\n"); + info(" -f, --fperm=mode Default group file "); + info("permissions\n"); + info(" -h, --help Display this help\n"); + info(" -l, --load=FILE Parse and load the cgroups "); + info("configuration file\n"); + info(" -L, --load-directory=DIR Parse and load the cgroups "); + info("configuration files from a directory\n"); + info(" -s, --tperm=mode Default tasks file "); + info("permissions\n"); + info(" -t : Default owner of the tasks "); + info("file\n"); } int main(int argc, char *argv[]) @@ -92,8 +93,8 @@ int main(int argc, char *argv[]) ret = cgroup_init(); if (ret) { - fprintf(stderr, "%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; } @@ -111,8 +112,8 @@ int main(int argc, char *argv[]) case 'l': error = cgroup_string_list_add_item(&cfg_files, optarg); if (error) { - fprintf(stderr, "%s: cannot add file ", argv[0]); - fprintf(stderr, "to list, out of memory?\n"); + err("%s: cannot add file to list, ", argv[0]); + err("out of memory?\n"); goto err; } break; @@ -167,14 +168,14 @@ int main(int argc, char *argv[]) default_group = cgroup_new_cgroup("default"); if (!default_group) { error = -1; - fprintf(stderr, "%s: cannot create default cgroup\n", argv[0]); + err("%s: cannot create default cgroup\n", argv[0]); goto err; } error = cgroup_set_uid_gid(default_group, tuid, tgid, auid, agid); if (error) { - fprintf(stderr, "%s: cannot set default UID and GID: %s\n", - argv[0], cgroup_strerror(error)); + err("%s: cannot set default UID and GID: %s\n", argv[0], + cgroup_strerror(error)); goto free_cgroup; } @@ -185,16 +186,16 @@ int main(int argc, char *argv[]) error = cgroup_config_set_default(default_group); if (error) { - fprintf(stderr, "%s: cannot set config parser defaults: %s\n", - argv[0], cgroup_strerror(error)); + err("%s: cannot set config parser defaults: %s\n", argv[0], + cgroup_strerror(error)); goto free_cgroup; } for (i = 0; i < cfg_files.count; i++) { ret = cgroup_config_load_config(cfg_files.items[i]); if (ret) { - fprintf(stderr, "%s; error loading %s: %s\n", argv[0], - cfg_files.items[i], cgroup_strerror(ret)); + err("%s; error loading %s: %s\n", argv[0], + cfg_files.items[i], cgroup_strerror(ret)); if (!error) error = ret; }