From: Crystal Wood <crwood@redhat.com>
To: Costa Shulyupin <costa.shul@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
	Jan Stancek <jstancek@redhat.com>,
	Tiezhu Yang <yangtiezhu@loongson.cn>,
	linux-trace-kernel@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/5] tools/rtla: Add fatal() and replace error handling pattern
Date: Wed, 08 Oct 2025 16:55:52 -0500	[thread overview]
Message-ID: <34afd8ffbb1c889e91fa536cf60369a697d86575.camel@redhat.com> (raw)
In-Reply-To: <20251008195905.333514-2-costa.shul@redhat.com>
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 <costa.shul@redhat.com>
> ---
>  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 <crwood@redhat.com>
-Crystal
next prev parent reply	other threads:[~2025-10-08 21:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 19:59 [PATCH v1 0/5] tools/rtla: Improve argument processing Costa Shulyupin
2025-10-08 19:59 ` [PATCH v1 1/5] tools/rtla: Add fatal() and replace error handling pattern Costa Shulyupin
2025-10-08 21:55   ` Crystal Wood [this message]
2025-10-10  7:20     ` Costa Shulyupin
2025-10-10 17:50       ` Crystal Wood
2025-10-08 19:59 ` [PATCH v1 2/5] tools/rtla: Replace timerlat_top_usage("...") with fatal("...") Costa Shulyupin
2025-10-08 19:59 ` [PATCH v1 3/5] tools/rtla: Replace timerlat_hist_usage("...") " Costa Shulyupin
2025-10-08 19:59 ` [PATCH v1 4/5] tools/rtla: Replace osnoise_hist_usage("...") " Costa Shulyupin
2025-10-08 19:59 ` [PATCH v1 5/5] tools/rtla: Replace osnoise_top_usage("...") " Costa Shulyupin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=34afd8ffbb1c889e91fa536cf60369a697d86575.camel@redhat.com \
    --to=crwood@redhat.com \
    --cc=costa.shul@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=jstancek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).