public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 6/6] Provide assert_perror when it's not defined
@ 2015-05-03 23:25 Max Filippov
  0 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2015-05-03 23:25 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 2910 bytes --]

assert_perror is a GNU extension and is not provided by uClibc. Provide
definition when that macro is not available.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 tests/ChangeLog         |  7 +++++++
 tests/backtrace-child.c | 13 +++++++++++++
 tests/backtrace-data.c  | 12 ++++++++++++
 tests/backtrace-dwarf.c | 12 ++++++++++++
 tests/backtrace.c       | 12 ++++++++++++
 5 files changed, 56 insertions(+)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index f5d9a1b..9b1b18f 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-04  Max Filippov  <jcmvbkbc@gmail.com>
+
+	* backtrace-child.c (assert_perror): Provide conditional definition.
+	* backtrace-data.c: Likewise.
+	* backtrace-dwarf.c: Likewise.
+	* backtrace.c: Likewise.
+
 2015-05-04  Daniel Guzman  <daniel@guzman.io>
 
 	* Makefile.am (line2addr_LDADD, addrscopes_LDADD, funcscopes_LDADD)
diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
index 788801c..2f955e0 100644
--- a/tests/backtrace-child.c
+++ b/tests/backtrace-child.c
@@ -79,6 +79,19 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#ifndef assert_perror
+#define assert_perror(err) \
+  do \
+    { \
+      if (err) \
+	{ \
+	  fprintf (stderr, "%s:%d %s\n", __FILE__, __LINE__, strerror (err)); \
+	  abort (); \
+	} \
+    } \
+  while (0)
+#endif
+
 #ifndef __linux__
 
 int
diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
index 01c1c00..f2ef44c 100644
--- a/tests/backtrace-data.c
+++ b/tests/backtrace-data.c
@@ -40,6 +40,18 @@
 #include <string.h>
 #include ELFUTILS_HEADER(dwfl)
 
+#ifndef assert_perror
+#define assert_perror(err) \
+  do \
+    { \
+      if (err) \
+	{ \
+	  fprintf (stderr, "%s:%d %s\n", __FILE__, __LINE__, strerror (err)); \
+	  abort (); \
+	} \
+    } \
+  while (0)
+#endif
 #if !defined(__x86_64__) || !defined(__linux__)
 
 int
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
index fbcb22e..27aa4a9 100644
--- a/tests/backtrace-dwarf.c
+++ b/tests/backtrace-dwarf.c
@@ -29,6 +29,18 @@
 #include <sys/wait.h>
 #include ELFUTILS_HEADER(dwfl)
 
+#ifndef assert_perror
+#define assert_perror(err) \
+  do \
+    { \
+      if (err) \
+	{ \
+	  fprintf (stderr, "%s:%d %s\n", __FILE__, __LINE__, strerror (err)); \
+	  abort (); \
+	} \
+    } \
+  while (0)
+#endif
 #ifndef __linux__
 
 int
diff --git a/tests/backtrace.c b/tests/backtrace.c
index 8b19b94..9660560 100644
--- a/tests/backtrace.c
+++ b/tests/backtrace.c
@@ -38,6 +38,18 @@
 #include <argp.h>
 #include ELFUTILS_HEADER(dwfl)
 
+#ifndef assert_perror
+#define assert_perror(err) \
+  do \
+    { \
+      if (err) \
+	{ \
+	  fprintf (stderr, "%s:%d %s\n", __FILE__, __LINE__, strerror (err)); \
+	  abort (); \
+	} \
+    } \
+  while (0)
+#endif
 #ifndef __linux__
 
 int
-- 
1.8.1.4


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

* Re: [PATCH 6/6] Provide assert_perror when it's not defined
@ 2015-05-04 17:24 Petr Machata
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Machata @ 2015-05-04 17:24 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 142 bytes --]

Mark Wielaard <mjw@redhat.com> writes:

> [...] this is in the tests a simple assert (errno)
> would IMHO also be fine

Agreed.

Petr

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

* Re: [PATCH 6/6] Provide assert_perror when it's not defined
@ 2015-05-04 14:48 Max Filippov
  0 siblings, 0 replies; 5+ messages in thread
From: Max Filippov @ 2015-05-04 14:48 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 786 bytes --]

On Mon, May 4, 2015 at 5:22 PM, Mark Wielaard <mjw@redhat.com> wrote:
> On Mon, May 04, 2015 at 07:53:27AM +0200, Petr Machata wrote:
>> Max Filippov <jcmvbkbc@gmail.com> writes:
>>
>> > assert_perror is a GNU extension and is not provided by uClibc. Provide
>> > definition when that macro is not available.
>>
>> It looks like it would pay off to have a dedicated header file for this
>> macro.
>
> Yes, but it is only needed in the backtrace tests. So please make it a
> tests only header. But since this is in the tests a simple assert (errno)
> would IMHO also be fine. It is just there to make sure the tests fail on
> something unexpected. For real code we should do proper error checking.

Ok, I'll turn assert_perrors to simple asserts.

-- 
Thanks.
-- Max

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

* Re: [PATCH 6/6] Provide assert_perror when it's not defined
@ 2015-05-04 14:22 Mark Wielaard
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Wielaard @ 2015-05-04 14:22 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 643 bytes --]

On Mon, May 04, 2015 at 07:53:27AM +0200, Petr Machata wrote:
> Max Filippov <jcmvbkbc@gmail.com> writes:
> 
> > assert_perror is a GNU extension and is not provided by uClibc. Provide
> > definition when that macro is not available.
> 
> It looks like it would pay off to have a dedicated header file for this
> macro.

Yes, but it is only needed in the backtrace tests. So please make it a
tests only header. But since this is in the tests a simple assert (errno)
would IMHO also be fine. It is just there to make sure the tests fail on
something unexpected. For real code we should do proper error checking.

Cheers,

Mark

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

* Re: [PATCH 6/6] Provide assert_perror when it's not defined
@ 2015-05-04  5:53 Petr Machata
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Machata @ 2015-05-04  5:53 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

Max Filippov <jcmvbkbc@gmail.com> writes:

> assert_perror is a GNU extension and is not provided by uClibc. Provide
> definition when that macro is not available.

It looks like it would pay off to have a dedicated header file for this
macro.

Similarly in the 3/6 patch for utimes/futimes, it would pay off to
extract that ifdef/else/endif logic to an inline function in some header
file.

Thanks,
Petr

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

end of thread, other threads:[~2015-05-04 17:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03 23:25 [PATCH 6/6] Provide assert_perror when it's not defined Max Filippov
2015-05-04  5:53 Petr Machata
2015-05-04 14:22 Mark Wielaard
2015-05-04 14:48 Max Filippov
2015-05-04 17:24 Petr Machata

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 read-only IMAP folder(s) and NNTP newsgroup(s).