bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH hurd 1/2] libshouldbeinlibc: add assert.h variant that prints


From: Samuel Thibault
Subject: Re: [PATCH hurd 1/2] libshouldbeinlibc: add assert.h variant that prints backtraces
Date: Sun, 2 Nov 2014 12:55:14 +0100
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Tue 28 Oct 2014 23:18:37 +0100, a écrit :
> * libshouldbeinlibc/assert-backtrace.h: New file.
> * libshouldbeinlibc/Makefile (installhdrs): Add assert-backtrace.h.

Yes, looks like a good place.  I've always wondered with glibc doesn't
provide a backtraced assertion like most modern programming environment
do :)

> +#ifndef NDEBUG

This will need an #else after the suggestion I make below.

> +/* This prints an "Assertion failed" message and aborts.  */
> +static void __assert_fail_backtrace (const char *__assertion,

This should have an inline qualifier, shouldn't it?

> +                                     const char *__file,
> +                                     unsigned int __line,
> +                                     const char *__function)
> +  __attribute__ ((noreturn, unused));
> +
> +#undef assert
> +#define assert(expr)                                                 \

I'd say rather define another macro, assert_backtrace.  I prefer
to s/assert/assert_backtrace/ in the whole tree than undefine an
other-lib-provided macro :)

> +static inline void
> +__assert_fail_backtrace (const char *__assertion, const char *__file,
> +                         unsigned int __line, const char *__function)
> +{
> +#define SIZE 128
> +#define SKIP 1

Way better use const int size = 128, skip = 1 than risking undefining
something from the includer :)

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]