This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix uninitialized Dwarf_Frame->regs


On Mon, 08 Oct 2012 23:33:10 +0200, Roland McGrath wrote:
> > static_assert is C++0x keyword (GDB has gdb_static_assert); but system.h is
> > not exported so I found it OK.
> 
> I think it's potentially confusing to define a macro that is the same
> identifier as a keyword.  This also might cause some trouble with the
> C++-heavy code on the dwarf branch.  So let's use a different name.

Maybe eu_static_assert?  I have not found any common elfutils prefix.


Thanks,
Jan


lib/
2012-10-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* system.h (eu_static_assert): New macro.

libdw/
2012-10-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* cfi.c: New include system.h.
	(execute_cfi) (enough_registers): Clear new memory after realloc.

diff --git a/lib/system.h b/lib/system.h
index 9ac01f8..d9adee9 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -121,4 +121,11 @@ extern char *color_weak;
 
 extern const char color_off[];
 
+/* A static assertion.  This will cause a compile-time error if EXPR,
+   which must be a compile-time constant, is false.  */
+
+#define eu_static_assert(expr)						\
+  extern int never_defined_just_used_for_checking[(expr) ? 1 : -1]	\
+    __attribute__ ((unused))
+
 #endif /* system.h */
diff --git a/libdw/cfi.c b/libdw/cfi.c
index f59f17d..b1e8d48 100644
--- a/libdw/cfi.c
+++ b/libdw/cfi.c
@@ -35,6 +35,7 @@
 #include "cfi.h"
 #include "memory-access.h"
 #include "encoded-value.h"
+#include "system.h"
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
@@ -89,6 +90,9 @@ execute_cfi (Dwarf_CFI *cache,
 	    }
 	  else
 	    {
+	      eu_static_assert (reg_unspecified == 0);
+	      memset (bigger->regs + bigger->nregs, 0,
+		      (reg + 1 - bigger->nregs) * sizeof bigger->regs[0]);
 	      bigger->nregs = reg + 1;
 	      fs = bigger;
 	    }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]