linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2] trace-cmd: Remove all die()s from trace-cmd library
Date: Wed, 24 Mar 2021 17:53:09 -0400	[thread overview]
Message-ID: <20210324175309.4e154757@gandalf.local.home> (raw)
In-Reply-To: <20210324135143.445443-1-tz.stoyanov@gmail.com>

On Wed, 24 Mar 2021 15:51:43 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> @@ -366,36 +366,32 @@ void __noreturn __vdie(const char *fmt, va_list ap)
>  	vfprintf(stderr, fmt, ap);
>  
>  	fprintf(stderr, "\n");
> -	exit(ret);
> +	return ret;
>  }
>  
> -void __noreturn __die(const char *fmt, ...)
> +#ifdef LIB_DIE

I wonder if it would be more useful not to have it as a compile time
define, but instead a global variable:

static bool lib_die;

void tracecmd_die_on_error(void)
{
	lib_die = true;
}

Make the "die()" functions into static variables here.

void __hidden _lib_fatal(const char *fmt, ...)
{
	va_list ap;

	va_start(ap, fmt);
	if (lib_die)
		__vdie(fmt, ap);
	else
		__vwarning(fmt, ap);
	va_end(ap);
}

That way if we run trace-cmd with the --debug option, it could then call
the tracecmd_die_on_error() function, and it will crash on any "fatal"
places.

-- Steve


> +
> +void __noreturn _lib_fatal(const char *fmt, ...)
>  {
>  	va_list ap;
> +	int ret;
>  
>  	va_start(ap, fmt);
> -	__vdie(fmt, ap);
> +	ret = __vlib_fatal(fmt, ap);
>  	va_end(ap);
> +	exit(ret);
>  }
>  
> -void __weak __noreturn die(const char *fmt, ...)
> +#else
> +void _lib_fatal(const char *fmt, ...)
>  {
>  	va_list ap;
>  
>  	va_start(ap, fmt);
> -	__vdie(fmt, ap);
> +	__vlib_fatal(fmt, ap);
>  	va_end(ap);
>  }
> -
> -void __weak *malloc_or_die(unsigned int size)
> -{
> -	void *data;
> -
> -	data = malloc(size);
> -	if (!data)
> -		die("malloc");
> -	return data;
> -}
> +#endif
>  

  reply	other threads:[~2021-03-24 21:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 13:51 [PATCH v2] trace-cmd: Remove all die()s from trace-cmd library Tzvetomir Stoyanov (VMware)
2021-03-24 21:53 ` Steven Rostedt [this message]
2021-03-25  7:50   ` Tzvetomir Stoyanov

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=20210324175309.4e154757@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=tz.stoyanov@gmail.com \
    /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).