All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mtd-utils] integck: only use execinfo.h when INTEGCK_DEBUG is enabled
@ 2016-07-16  9:48 Thomas Petazzoni
  2016-07-16 13:31 ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2016-07-16  9:48 UTC (permalink / raw)
  To: linux-mtd; +Cc: Brian Norris, Thomas Petazzoni

Guard the usage of execinfo.h by INTEGCK_DEBUG so that by defaut,
integck builds properly on systems without <execinfo.h> (uClibc and
musl based systems). As stated in the code, the backtrace()
functionality of <execinfo.h> will anyway only work properly when
INTEGCK_DEBUG is defined (it makes all functions non-static, which is
needed for backtrace to provide some useful information).

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 tests/fs-tests/integrity/integck.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index 8badd1f..6ef817e 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -31,7 +31,9 @@
 #include <getopt.h>
 #include <assert.h>
 #include <mntent.h>
+#ifdef INTEGCK_DEBUG
 #include <execinfo.h>
+#endif
 #include <bits/stdio_lim.h>
 #include <sys/mman.h>
 #include <sys/vfs.h>
@@ -248,14 +250,18 @@ static char *random_name_buf;
 static void check_failed(const char *cond, const char *func, const char *file,
 			 int line)
 {
-	int error = errno, count;
+	int error = errno;
+#ifdef INTEGCK_DEBUG
+	int count;
 	void *addresses[128];
+#endif
 
 	fflush(stdout);
 	fflush(stderr);
 	errmsg("condition '%s' failed in %s() at %s:%d",
 	       cond, func, file, line);
 	normsg("error %d (%s)", error, strerror(error));
+#ifdef INTEGCK_DEBUG
 	/*
 	 * Note, to make this work well you need:
 	 * 1. Make all functions non-static - add "#define static'
@@ -264,6 +270,7 @@ static void check_failed(const char *cond, const char *func, const char *file,
 	 */
 	count = backtrace(addresses, 128);
 	backtrace_symbols_fd(addresses, count, fileno(stdout));
+#endif
 	exit(EXIT_FAILURE);
 }
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH mtd-utils] integck: only use execinfo.h when INTEGCK_DEBUG is enabled
  2016-07-16  9:48 [PATCH mtd-utils] integck: only use execinfo.h when INTEGCK_DEBUG is enabled Thomas Petazzoni
@ 2016-07-16 13:31 ` Richard Weinberger
  2016-07-16 13:34   ` Thomas Petazzoni
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2016-07-16 13:31 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: linux-mtd, Brian Norris

Thomas,

On Sat, Jul 16, 2016 at 11:48 AM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Guard the usage of execinfo.h by INTEGCK_DEBUG so that by defaut,
> integck builds properly on systems without <execinfo.h> (uClibc and
> musl based systems). As stated in the code, the backtrace()
> functionality of <execinfo.h> will anyway only work properly when
> INTEGCK_DEBUG is defined (it makes all functions non-static, which is
> needed for backtrace to provide some useful information).

But this means in uClibc and musl systems INTEGCK_DEBUG is still not
usable, right?
Instead of papering over the issue we should bite the bullet and add a
libmissing to mtd-utils
to same functionality across all kind of libcs.
IOW when mtd-utils is built against non-glibc we add -lmissing to the
compiler command line.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH mtd-utils] integck: only use execinfo.h when INTEGCK_DEBUG is enabled
  2016-07-16 13:31 ` Richard Weinberger
@ 2016-07-16 13:34   ` Thomas Petazzoni
  2016-07-16 15:03     ` Richard Weinberger
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2016-07-16 13:34 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-mtd, Brian Norris

Hello,

On Sat, 16 Jul 2016 15:31:15 +0200, Richard Weinberger wrote:

> But this means in uClibc and musl systems INTEGCK_DEBUG is still not
> usable, right?

Correct.

> Instead of papering over the issue we should bite the bullet and add a
> libmissing to mtd-utils to same functionality across all kind of libcs.

I'm not sure you really want a copy in libmissing of the backtrace
functionality.

It would be so much better if mtd-utils were using autoconf to
automatically detect the availability of execinfo.h, and adjust the
functionality accordingly. Indeed, having the backtrace is useful, but
is also not mandatory to use integck.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH mtd-utils] integck: only use execinfo.h when INTEGCK_DEBUG is enabled
  2016-07-16 13:34   ` Thomas Petazzoni
@ 2016-07-16 15:03     ` Richard Weinberger
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2016-07-16 15:03 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: linux-mtd, Brian Norris, David Oberhollenzer

Thomas,

On Sat, Jul 16, 2016 at 3:34 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> On Sat, 16 Jul 2016 15:31:15 +0200, Richard Weinberger wrote:
>
>> But this means in uClibc and musl systems INTEGCK_DEBUG is still not
>> usable, right?
>
> Correct.
>
>> Instead of papering over the issue we should bite the bullet and add a
>> libmissing to mtd-utils to same functionality across all kind of libcs.
>
> I'm not sure you really want a copy in libmissing of the backtrace
> functionality.

It is not only backtraceing, there are more features we gave up in
favor to non-glibc.
Using a libmissing we could better deal with that.
This is patch is by far not the first one to make mtd-utils work/build
on non-glibc systems.

> It would be so much better if mtd-utils were using autoconf to
> automatically detect the availability of execinfo.h, and adjust the
> functionality accordingly. Indeed, having the backtrace is useful, but
> is also not mandatory to use integck.

David is currently reviving my autoconf patch. That's why we're
currently thinking of
mechanisms to make mtd-utils better.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-16 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-16  9:48 [PATCH mtd-utils] integck: only use execinfo.h when INTEGCK_DEBUG is enabled Thomas Petazzoni
2016-07-16 13:31 ` Richard Weinberger
2016-07-16 13:34   ` Thomas Petazzoni
2016-07-16 15:03     ` Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.