From aac3baa055bcc21802920df6248ecfb1f296394d Mon Sep 17 00:00:00 2001 From: Florian Hofer Date: Thu, 20 Jun 2024 16:25:50 +0200 Subject: [PATCH] orch .. unified use of exit/fatal and err_exit --- src/lib/parse_config.c | 2 +- src/orchestrator/orchestrator.c | 6 ++---- src/orchestrator/resmgnt.c | 6 +++--- src/orchestrator/update.c | 6 +++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/lib/parse_config.c b/src/lib/parse_config.c index 654d17fa..c480e482 100644 --- a/src/lib/parse_config.c +++ b/src/lib/parse_config.c @@ -422,7 +422,7 @@ void parse_dockerfileprefix(prgset_t *set) { set->cpusetdfileprefix = malloc(strlen(set->cgroupfileprefix) + strlen(CGRP_CSET) + strlen(set->cont_cgrp)+1); if (!set->cpusetdfileprefix) - err_exit_n(errno, "Could not allocate memory"); + err_exit("Could not allocate memory"); set->cpusetdfileprefix = strcat(strcat (strcpy(set->cpusetdfileprefix, set->cgroupfileprefix), CGRP_CSET), set->cont_cgrp); } diff --git a/src/orchestrator/orchestrator.c b/src/orchestrator/orchestrator.c index bce2bb2e..f528be8f 100644 --- a/src/orchestrator/orchestrator.c +++ b/src/orchestrator/orchestrator.c @@ -265,10 +265,8 @@ static void process_options (prgset_t *set, int argc, char *argv[], int max_cpus // flag -a with no range = all } else { set->affinity = malloc(14); - if (!set->affinity){ - err_msg("could not allocate memory!"); - exit(EXIT_FAILURE); - } + if (!set->affinity) + err_exit("could not allocate memory!"); (void)sprintf(set->affinity, "0-%d", max_cpus-1); set->setaffinity = AFFINITY_USEALL; } diff --git a/src/orchestrator/resmgnt.c b/src/orchestrator/resmgnt.c index 2ea66152..33862b97 100644 --- a/src/orchestrator/resmgnt.c +++ b/src/orchestrator/resmgnt.c @@ -480,7 +480,7 @@ updatePidCmdline(node_t * node){ free(cmdline); } else // FATAL, exit and execute atExit - err_msg("Could not allocate memory!"); + err_exit("Could not allocate memory!"); } /* @@ -721,8 +721,8 @@ resetRTthrottle (prgset_t *set, int percent){ */ void createResTracer(){ - if (rHead || !(prgset->affinity_mask)) // does it exist? is the mast set? - fatal("Memory management inconsistency: resTracer already present!"); + if (rHead || !(prgset->affinity_mask)) // does it exist? is the mask set? + err_exit("Memory management inconsistency: resTracer already present!"); // backwards, cpu0 on top, we assume affinity_mask ok for (int i=(prgset->affinity_mask->size); i >= 0;i--) diff --git a/src/orchestrator/update.c b/src/orchestrator/update.c index 457cdbd4..ea7f1b56 100644 --- a/src/orchestrator/update.c +++ b/src/orchestrator/update.c @@ -117,7 +117,7 @@ getContPids (node_t **pidlst) char * hex = dir->d_name; #endif if (!(( (*pidlst)->contid = strdup(hex) ))) - fatal("Could not allocate memory!"); + err_exit("Could not allocate memory!"); #ifdef CGROUP2 free(name); #endif @@ -137,7 +137,7 @@ getContPids (node_t **pidlst) } else // FATAL, exit and execute atExit - fatal("Could not allocate memory!"); + err_exit("Could not allocate memory!"); } } closedir(d); @@ -211,7 +211,7 @@ getPids (node_t **pidlst, char * tag, char * ppid) // add command string to pidlist if (!((*pidlst)->psig = strdup(pid))) // alloc memory for string // FATAL, exit and execute atExit - fatal("Could not allocate memory!"); + err_exit("Could not allocate memory!"); (*pidlst)->contid = NULL; count++; }