initctl: let -q silence all commands

This patch introduces ERR(), ERRX(), WARN(), and WARNX() as replacements
to their lower case counterparts.  These log macros respect the 'quiet'
flag to initctl, leaving only the return code as indicator to user.

Fixes #266

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-05-15 10:34:36 +02:00
1 parent fb8a7caa99
commit 9a76f0862c
5 files changed
+68 -60

No files matched your search

+5 -6
View File
@@ -23,7 +23,6 @@
#include "config.h"
#include <err.h>
#include <dirent.h>
#include <stdio.h>
#include <signal.h>
@@ -244,7 +243,7 @@ static float cgroup_cpuload(struct cg *cg)
snprintf(fn, sizeof(fn), "%s/cpu.stat", cg->cg_path);
fp = fopen(fn, "r");
if (!fp)
err(1, "Cannot open %s", fn);
ERR(1, "Cannot open %s", fn);
while (fgets(buf, sizeof(buf), fp)) {
uint64_t curr;
@@ -280,13 +279,13 @@ static struct cg *append(char *path)
if (access(fn, F_OK)) {
/* older kernels, 4.19, don't have summary cpu.stat in root */
if (strcmp(path, FINIT_CGPATH))
warn("not a cgroup path with cpu controller, %s", path);
WARN("not a cgroup path with cpu controller, %s", path);
return NULL;
}
cg = calloc(1, sizeof(struct cg));
if (!cg)
err(1, "failed allocating struct cg");
ERR(1, "failed allocating struct cg");
cg->cg_path = strdup(path);
if (list)
@@ -296,7 +295,7 @@ static struct cg *append(char *path)
item.key = cg->cg_path;
item.data = cg;
if (!hsearch(item, ENTER))
err(1, "failed adding to hash table");
ERR(1, "failed adding to hash table");
return cg;
}
@@ -610,7 +609,7 @@ int show_cgtop(char *arg)
}
if (!hcreate(ttrows + 25))
err(1, "failed creating hash table");
ERR(1, "failed creating hash table");
sysinfo(&si);
total_ram = si.totalram * si.mem_unit;