From: Jan Kratochvil Date: Thu, 11 Oct 2012 19:47:26 +0000 (+0200) Subject: src/ X-Git-Tag: elfutils-0.156~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69a2852e1d5661bc042dcc90c16e9aa7777c7340;p=thirdparty%2Felfutils.git src/ 2012-10-11 Jan Kratochvil * readelf.c (handle_core_item) : Make run an outer block variable. Increase run only if LASTBIT != 0. Print last element only if RUN > 0. Signed-off-by: Jan Kratochvil --- diff --git a/src/readelf.c b/src/readelf.c index 5d167ebc7..470af4d9c 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -7515,19 +7515,19 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc, } unsigned int lastbit = 0; + unsigned int run = 0; for (const unsigned int *i = data; (void *) i < data + count * size; ++i) { unsigned int bit = ((void *) i - data) * 8; unsigned int w = negate ? ~*i : *i; - unsigned int run = 0; while (w != 0) { int n = ffs (w); w >>= n; bit += n; - if (lastbit + 1 == bit) + if (lastbit != 0 && lastbit + 1 == bit) ++run; else { @@ -7543,8 +7543,8 @@ handle_core_item (Elf *core, const Ebl_Core_Item *item, const void *desc, lastbit = bit; } } - if (lastbit > 0 && lastbit + 1 != nbits) - p += sprintf (p, "-%u", nbits - bias); + if (lastbit > 0 && run > 0 && lastbit + 1 != nbits) + p += sprintf (p, "-%u", lastbit - bias); colno = print_core_item (colno, ',', ITEM_WRAP_COLUMN, 0, item->name, 4 + nbits * 4,