On Mon, 08 Oct 2012 21:42:18 +0200, Roland McGrath wrote: > Use assert rather than just a comment for the reg_unspecified==0 > assumption. Usual style is 'sizeof fs->regs[0]'. Also, I'd do the > initialization on BIGGER and before 'fs = bigger;' so the assignment > indicates it is ready to use.
Do you mean plain assert? I would find this case more appropriate for static assertion, in GDB it is: # /* A static assertion. This will cause a compile-time error if EXPR, # which must be a compile-time constant, is false. */ # # #define gdb_static_assert(expr) \ # extern int never_defined_just_used_for_checking[(expr) ? 1 : -1] In elfutils is already BUILD_BUG_ON_ZERO but only in "libebl/libeblP.h". Thanks, Jan libdw/ 2012-10-08 Jan Kratochvil <[email protected]> * cfi.c (BUILD_BUG_ON_ZERO): New macro. (execute_cfi) (enough_registers): Clear new memory after realloc. diff --git a/libdw/cfi.c b/libdw/cfi.c index f59f17d..8c3676b 100644 --- a/libdw/cfi.c +++ b/libdw/cfi.c @@ -41,6 +41,8 @@ #define CFI_PRIMARY_MAX 0x3f +#define BUILD_BUG_ON_ZERO(x) (sizeof (char [(x) ? -1 : 1]) - 1) + static Dwarf_Frame * duplicate_frame_state (const Dwarf_Frame *original, Dwarf_Frame *prev) @@ -89,6 +91,9 @@ execute_cfi (Dwarf_CFI *cache, } else { + bigger += BUILD_BUG_ON_ZERO (reg_unspecified); + memset (bigger->regs + bigger->nregs, 0, + (reg + 1 - bigger->nregs) * sizeof bigger->regs[0]); bigger->nregs = reg + 1; fs = bigger; } _______________________________________________ elfutils-devel mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/elfutils-devel
