On Wed, 2025-10-08 at 22:59 +0300, Costa Shulyupin wrote: > The code contains some technical debt in error handling, > which complicates the consolidation of duplicated code. > > Introduce an fatal() function to replace the common pattern of > err_msg() followed by exit(EXIT_FAILURE), reducing the length of an > already long function. > > Further patches using fatal() follow. > > Signed-off-by: Costa Shulyupin <[email protected]> > --- > tools/tracing/rtla/src/osnoise_hist.c | 42 ++++++++-------------- > tools/tracing/rtla/src/osnoise_top.c | 42 ++++++++-------------- > tools/tracing/rtla/src/timerlat_hist.c | 50 +++++++++----------------- > tools/tracing/rtla/src/timerlat_top.c | 48 +++++++++---------------- > tools/tracing/rtla/src/timerlat_u.c | 12 +++---- > tools/tracing/rtla/src/utils.c | 14 ++++++++ > tools/tracing/rtla/src/utils.h | 1 + > 7 files changed, 80 insertions(+), 129 deletions(-) > > diff --git a/tools/tracing/rtla/src/osnoise_hist.c > b/tools/tracing/rtla/src/osnoise_hist.c > index dffb6d0a98d7..43c323521f55 100644 > --- a/tools/tracing/rtla/src/osnoise_hist.c > +++ b/tools/tracing/rtla/src/osnoise_hist.c > @@ -592,10 +592,8 @@ static struct common_params > break; > case 'e': > tevent = trace_event_alloc(optarg); > - if (!tevent) { > - err_msg("Error alloc trace event"); > - exit(EXIT_FAILURE); > - } > + if (!tevent) > + fatal("Error alloc trace event"); > > if (params->common.events) > tevent->next = params->common.events; > @@ -615,10 +613,8 @@ static struct common_params > case 'H': > params->common.hk_cpus = 1; > retval = parse_cpu_set(optarg, > ¶ms->common.hk_cpu_set); > - if (retval) { > - err_msg("Error parsing house keeping CPUs\n"); > - exit(EXIT_FAILURE); > - } > + if (retval) > + fatal("Error parsing house keeping CPUs\n");
Looks like there was existing inconsistency with newlines... maybe have fatal() include the newline automatically to simplify callers slightly? We're not going to print a continuation if we're exiting. Otherwise, for the whole series: Reviewed-by: Crystal Wood <[email protected]> -Crystal
