[PATCH] readelf: Pull advance_pc() in file scope

2021-03-18 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Make advance_pc() a static function so we can get rid of another nested function. Rename it to run_advance_pc() and use a local advance_pc() macro to pass all the local variables. This is similar to what the equivalent code in libdw/dwarf_getsrclines.c is doing. Signed-off-by: T

readelf: Pull advance_pc() in file scope

2021-03-18 Thread Timm Bäder via Elfutils-devel
Giving this another shot since pulling all the parsing code into libdwP.h seems a bit overkill (and potentially buggy of course). The downside is that run_advance_pc() takes 6 arguments instead of the 4 that it takes in libdwarf_getsrclines.c

Re: [PATCH] define SHT_LLVM_ADDRSIG section rather than error out

2021-03-08 Thread Timm Bäder via Elfutils-devel
On 04/03/2021 14:59, Mark Wielaard wrote: Hi Timm, On Thu, 2021-03-04 at 14:44 +0100, Timm Bäder wrote: any update on this? I see that SHT_LLVM_ADDRSIG is still not in upstream glibc. Are you working on that, Navin? As for the checks, I'm not sure we can do anything here since elfutils can't k

Re: [PATCH] define SHT_LLVM_ADDRSIG section rather than error out

2021-03-04 Thread Timm Bäder via Elfutils-devel
On 18/11/2020 06:34, Navin P via Elfutils-devel wrote: diff --git a/src/elflint.c b/src/elflint.c index ef3e3732..62663800 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -3905,6 +3905,7 @@ section [%2zu] '%s': size not multiple of entry size\n"), && shdr->sh_type != SHT_GNU_ATTRIBUTES

[PATCH] debginfod-client: Fix typo in curl feature detection

2021-03-04 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder CURLINFO_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T is one CURLINFO_ too much. Signed-off-by: Timm Bäder --- debuginfod/debuginfod-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index df238e0

debuginfod-client: Fix typo in curl feature detection

2021-03-04 Thread Timm Bäder via Elfutils-devel
I just looked at this for too long and became confused by the naming. It seems like there's one CURLINFO_ too much in there. Googling seems to confirm. - Timm

[PATCH] debuginfod-client: Don't compare a double to a long

2021-03-04 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder clang warns about this: ../../debuginfod/debuginfod-client.c:899:28: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion] pa = (dl > LONG_MAX ? LONG_MAX : (lon

[PATCH] debuginfod-client: Remove always-false comparisons

2021-03-02 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder When comparing a long to a double, clang prints the following warning: ../../debuginfod/debuginfod-client.c:917:28: error: implicit conversion from 'long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]

debuginfod: Remove always-false comparisons with LONG_MAX

2021-03-02 Thread Timm Bäder via Elfutils-devel
If I understand the code correctly, these comparisons exist only for the curl_off_t cases, in which case dl and cl might be greater than LONG_MAX. However, in case they are declares as double values, this cannot be the case and the comparisons are unnecessary. - Timm

[PATCH] elfcompress: Replace cleanup() with label

2021-03-02 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder This unifies the error handling with the rest of the code base and gets rid of a nested function. Signed-off-by: Timm Bäder --- src/ChangeLog | 6 ++ src/elfcompress.c | 215 +++--- 2 files changed, 112 insertions(+), 109 deletions

Re: Remove misleading XOR

2021-02-25 Thread Timm Bäder via Elfutils-devel
On 24/02/2021 14:16, Mark Wielaard wrote:>>> -#define NO_RESIZING 0u -#define ALLOCATING_MEMORY 1u -#define MOVING_DATA 3u -#define CLEANING 2u +#define NO_RESIZING 0x0 +#define ALLOCATING_MEMORY 0x1 +#define MOVING_DATA 0x3 +#define CLEANING 0x2 Nope, same result. :( Hmm

Re: Remove misleading XOR

2021-02-24 Thread Timm Bäder via Elfutils-devel
On 24/02/2021 14:16, Mark Wielaard wrote:> Hmmm. I am not sure why that doesn't work. What if you make them explicitly unsinged (adding u at the end). Or does it simply ignore the values and just warn because it sees the macro name and not an explicit number? Another viable workaround is to jus

Re: Remove misleading XOR

2021-02-24 Thread Timm Bäder via Elfutils-devel
On 24/02/2021 14:46, Timm Bäder wrote: On 24/02/2021 14:16, Mark Wielaard wrote: Hmmm. I am not sure why that doesn't work. What if you make them explicitly unsinged (adding u at the end). Or does it simply ignore the values and just warn because it sees the macro name and not an explicit number

Re: Remove misleading XOR

2021-02-24 Thread Timm Bäder via Elfutils-devel
On 24/02/2021 14:16, Mark Wielaard wrote: Hmmm. I am not sure why that doesn't work. What if you make them explicitly unsinged (adding u at the end). Or does it simply ignore the values and just warn because it sees the macro name and not an explicit number? I think I don't really understand any

Re: Remove misleading XOR

2021-02-17 Thread Timm Bäder via Elfutils-devel
On 17/02/2021 17:49, Mark Wielaard wrote: I think both the comment and the warning message are a little misleading. The comment should really read "Change state from CLEANING to NO_RESIZING". You are right that NO_RESIZING is just zero, but still removing it seems to make the code less clear.

[PATCH] Remove misleading XOR

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Clang complains about this because it has -Wxor-used-as-pow: ../../lib/dynamicsizehash_concurrent.c:288:61: error: result of 'CLEANING ^ NO_RESIZING' is 2; did you mean '1 << NO_RESIZING' (1)? [-Werror,-Wxor-used-as-pow] atomic_fetch_xor_explicit(&htab->resizing_state, CLEAN

Remove misleading XOR

2021-02-17 Thread Timm Bäder via Elfutils-devel
Hi, I'm mainly leaving this patch here to discuss what to do about it. Clang complains because of -Wxor-used-as-pow. So of course one possibility is to use -Wno-xor-used-as-pow. It also prints '0x2 ^ NO_RESIZING' as an alternative to silence the warning. Given the comment just above the changed li

[PATCH 2/3] build: Check for -Wtrampolines support

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Clang does not support -Wtrampolines, so check if the compiler supports it before using it. Signed-off-by: Timm Bäder --- config/eu.am | 10 -- configure.ac | 9 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config/eu.am b/config/eu.am inde

[PATCH 1/3] build: Check for -Wimplicit-fallthrough=5 separately

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder GCC accepts the =5, which means it doesn't try to parse any comments and only accepts the fallthrough attribute in code. Clang does not ever parse any comments and always wants the fallthrough attribute anyway. Clang also doesn't accept the =n parameter for -Wimplicit-fallthrough

[PATCH 3/3] build: Check for -Wno-packed-not-aligned support

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Clang does not support this warning, so check for compiler support before using it. Signed-off-by: Timm Bäder --- config/eu.am | 10 -- configure.ac | 9 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config/eu.am b/config/eu.am index 025125

[PATCH 2/2] elfstrmerge: Pull new_data_buf() into file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- tests/elfstrmerge.c | 32 +--- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c index 00f025ec..197c6a5d 100644 --- a/tests

[PATCH 1/2] elfstrmerge: Pull newsecndx() info file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- tests/elfstrmerge.c | 76 + 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c index abbdf3fd..00f025ec 10064

[PATCH 4/4] elfcompress: Replace cleanup() with label

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/elfcompress.c | 218 +++--- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/src/elfcompress.c b/src/elfcompress.c index 65e28f0e..ba08e73f 100644

[PATCH 3/4] elfcompress: Pull get_sections() into file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/elfcompress.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/elfcompress.c b/src/elfcompress.c index 2dc74a0c..65e28f0e 100644 --- a/src/elfcompress.c +++

[PATCH 1/4] elfcompress: Pull set_section() into file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/elfcompress.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/elfcompress.c b/src/elfcompress.c index 1b5b1e36..65a922a7 100644 --- a/src/elfcompress.c +++ b/src/e

[PATCH 2/4] elfcompress: Pull get_section() into file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/elfcompress.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/elfcompress.c b/src/elfcompress.c index 65a922a7..2dc74a0c 100644 --- a/src/elfcompress.c +++ b/src/elfc

[PATCH 5/5] unstrip: Remove nested next() function

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder This is a simple one-liner, so inline this into the few callers. Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/unstrip.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/unstrip.c b/src/unstrip.c index 3822a19b..

[PATCH 3/5] unstrip: Inline find_unalloc_section() into only caller

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of an unnecessary nested function this way. Signed-off-by: Timm Bäder --- src/unstrip.c | 47 +-- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/unstrip.c b/src/unstrip.c index 72fabac8..90e02831 100644 -

[PATCH 4/5] unstrip: Pull warn() into file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/unstrip.c | 35 --- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/unstrip.c b/src/unstrip.c index 90e02831..3822a19b 100644 --- a/src/unstrip.c +++ b/

[PATCH 2/5] unstrip: Pull check_match() into file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/unstrip.c | 28 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/unstrip.c b/src/unstrip.c index 6e874c3a..72fabac8 100644 --- a/src/unstrip.c +++ b/src/uns

[PATCH 1/5] unstrip: Pull adjust_reloc() into file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/unstrip.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/unstrip.c b/src/unstrip.c index 85803295..6e874c3a 100644 --- a/src/unstrip.c +++ b/src/uns

[PATCH 2/2] elflint: Pull left() in file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder And rename it to buffer_left() to be a bit more descriptive Signed-off-by: Timm Bäder --- src/elflint.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/elflint.c b/src/elflint.c index 4df6f6e5..85cc7833 100644 --- a/src/elflint.c +++ b

[PATCH 1/2] elflint: Pull pos() info file scope

2021-02-17 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Rename it to buffer_pos() to be a bit more descriptive and get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/elflint.c | 39 --- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/elflint.c b/src/elfli

Pull header reading code into libdwP.h

2021-02-09 Thread Timm Bäder via Elfutils-devel
There is quite a bit of code duplication between src/readelf.c and libdw/dwarf_getsrclines.c when parsing header_length, unit_length, etc. Pull the code out into libdwP.h and use it in both of those files. It doesn't save a much code as I'd hoped and I'm not sure about the naming, but here's the

[PATCH] Pull header reading code into libdwP.h

2021-02-09 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder src/readelf.c and libdw/dwarf_getsrclines.c contain the same code to read header_length, unit_length, minimum_instr_len, etc. Pull this code out into libdwP.h and into a header_state struct that goes with the line_state struct in dwarf_getsrclines.c. Signed-off-by: Timm Bäder -

[PATCH] ar: Pull should_truncate_fname() into file scope

2021-02-03 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/ar.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ar.c b/src/ar.c index 2a17d0d3..66b2c4fd 100644 --- a/src/ar.c +++ b/src/ar.c @@ -436,6 +4

Re: [PATCH 3/4] ar: Pull should_truncate_fname() into file scope

2021-02-02 Thread Timm Bäder via Elfutils-devel
On 29/01/2021 21:48, Mark Wielaard wrote: Hi Timm, On Fri, 2021-01-08 at 09:13 +0100, Timm Bäder via Elfutils-devel wrote: Get rid of a nested function this way. Skipping this one for now since I don't believe I understand this code. Could you explain what the code does what it does an

[PATCH] readelf: Remove show_op_index variable

2021-02-02 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder advance_pc() uses show_op_index to save whether the current op_index is > 0 OR the new op_index is > 0. The new op index is calculated via new_op_index = (op_index + op_advance) % max_ops_per_instr; since all of the variables involved are unsigned, new_op_index >= op_index is

Re: Remove nested functions from readelf.c

2021-02-02 Thread Timm Bäder via Elfutils-devel
On 01/02/2021 15:21, Mark Wielaard wrote: On Fri, 2021-01-08 at 09:16 +0100, Timm Bäder via Elfutils-devel wrote: here another round for src/readelf.c. I think they are simple, but I'm not happy with the advance_pc() commit. I'm open for suggestions here but I can't come up

[PATCH 5/5] readelf: Pull advance_pc() into file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way Signed-off-by: Timm Bäder --- src/readelf.c | 39 +++ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index e0163891..9758d338 100644 --- a/src/readelf.c +++

[PATCH 4/5] readelf: Pull regname() into file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/readelf.c | 42 -- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index 99e90c34..e0163891 100644 --- a/src/readelf.c

[PATCH 3/5] readelf: Pull left() info file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/readelf.c | 16 +--- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index 0157f8a2..99e90c34 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -357

[PATCH 2/5] readelf: Pull same_set() info file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way Signed-off-by: Timm Bäder --- src/readelf.c | 24 ++-- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index a95fc0aa..0157f8a2 100644 --- a/src/readelf.c +++ b/src/readelf.

[PATCH 1/5] readelf: Pull add_dump_section() into file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/readelf.c | 34 ++ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/readelf.c b/src/readelf.c index 829a418d..a95fc0aa 100644 --- a/src/readelf.c +++ b/s

Remove nested functions from readelf.c

2021-01-08 Thread Timm Bäder via Elfutils-devel
Hi, here another round for src/readelf.c. I think they are simple, but I'm not happy with the advance_pc() commit. I'm open for suggestions here but I can't come up with something better right now. I'll keep looking in to that in the meantime. - Timm

[PATCH 4/4] arlib-argp: Pull text_for_default() into file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/arlib-argp.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/arlib-argp.c b/src/arlib-argp.c index c07d9299..a3c12e4d 100644 --- a/src/arlib-argp.c +++ b/sr

[PATCH 3/4] ar: Pull should_truncate_fname() into file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/ar.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ar.c b/src/ar.c index 2a17d0d3..7d0298dd 100644 --- a/src/ar.c +++ b/src/ar.c @@ -436,6 +4

[PATCH 2/4] zstrptr: Pull print_string() into file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- tests/zstrptr.c | 43 ++- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/tests/zstrptr.c b/tests/zstrptr.c index 6d8e19f7..9fb42e28 100644 --- a/tests/

[PATCH 1/4] addr2line: Pull show_note() and show_int() in file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of the nested functions Signed-off-by: Timm Bäder --- src/addr2line.c | 47 ++- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/addr2line.c b/src/addr2line.c index ea01c1be..34945046 100644 --- a/src/addr2

Misc single nested function removals

2021-01-08 Thread Timm Bäder via Elfutils-devel
Hi, here a few patches to remove single nested functions from - addr2line.c - tests/zstrptr.c - ar.c - arlib-argp.c I think they are pretty straight-forward again. - Timm

[PATCH 2/2] elf-from-memory: Refactor to get rid of nested function

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Try to unify the 32/64 bit code paths and get rid of the nested handle_segment() this way. Signed-off-by: Timm Bäder --- libdwfl/elf-from-memory.c | 115 +- 1 file changed, 50 insertions(+), 65 deletions(-) diff --git a/libdwfl/elf-from-mem

[PATCH 1/2] elf-from-memory: Restructure code to get rid of nested handle_segment()

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Use one loop for both 32 and 64 bit case. This allows for only one call site of the old handle_segment(), which we can then inline into the for loop. Signed-off-by: Timm Bäder --- libdwfl/elf-from-memory.c | 81 --- 1 file changed, 34 inser

Remove nested functions from elf-from-memory.c

2021-01-08 Thread Timm Bäder via Elfutils-devel
Hey, these are relatively straight-forward I think. Let me know if that's not the case. :) - Timm

[PATCH 4/4] strip: Remove no_symtab_updates() function

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder The no_symtab_updates() function was being called at the beginning of all case labels in this switch, so we can just call it once before the switch. Then it only has one call-site, so inline this short function there. Signed-off-by: Timm Bäder --- src/strip.c | 152 +++

[PATCH 3/4] strip: Pull update_section_size() into file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- src/strip.c | 51 --- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/strip.c b/src/strip.c index 71913fac..e608dc5e 100644 --- a/src/strip.

[PATCH 2/4] strip: Pull relocate() info file scope

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Pull relocate() info file scope and get rid of a nested function this way. Refactor remove_debug_relocations() to minimize the parameters we need to pass to relocate(). Signed-off-by: Timm Bäder --- src/strip.c | 347 1 file

[PATCH 1/4] strip: Replace nested check_preserved function with loop

2021-01-08 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Signed-off-by: Timm Bäder --- src/strip.c | 37 + 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/strip.c b/src/strip.c index 7ce14ab8..c971b6c2 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1535,25 +1535,30 @@ handle_elf

Remove nested functions from src/strip.c

2021-01-08 Thread Timm Bäder via Elfutils-devel
Hi, here a couple of patches to remove the nested functions from src/strip.c. I tried to keep the resulting code clean but had to do some refactorings to get that done. I hope the result is worth considering. Otherwise, I'm open for suggestions. - Timm

[PATCH 2/2] link_map: Pull read_addrs() into file scope

2020-12-07 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Signed-off-by: Timm Bäder --- libdwfl/ChangeLog | 5 +++ libdwfl/link_map.c | 104 + 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog ind

[PATCH 1/2] link_map: Pull release_buffer() into file scope

2020-12-07 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. Add a memory_closure struct to keep the functions clean. Signed-off-by: Timm Bäder --- libdwfl/ChangeLog | 5 + libdwfl/link_map.c | 48 ++ 2 files changed, 37 insertions(+), 16 deletions(

Remove nested functions from link_map.c V2

2020-12-07 Thread Timm Bäder via Elfutils-devel
Same as the old thread. I used a memory_closure struct this time. I quickly looked over the patches and I think we could even save buffer and buffer_available in there to reduce the parameter count further but then we should rename the struct (but read_data isn't the best name either). Hope the ch

[PATCH 3/3] link_map: Inline consider_phdr() into only caller

2020-12-01 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder This gets rid of the tested function and is shorter. --- libdwfl/link_map.c | 66 ++ 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 64baaec4..8a19f358 100644 --- a/libdwfl/

[PATCH 2/3] link_map: Pull read_addrs() in file scope

2020-12-01 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of another nested function this way --- libdwfl/link_map.c | 114 ++--- 1 file changed, 66 insertions(+), 48 deletions(-) diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 5c39c631..64baaec4 100644 --- a/libdwfl/link_map.

[PATCH 1/3] link_map: Pull release_buffer() into file scope

2020-12-01 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of another nested function --- libdwfl/link_map.c | 47 +++--- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 29307c74..5c39c631 100644 --- a/libdwfl/link_map.c +++ b/l

link_map: Remove nested functions

2020-12-01 Thread Timm Bäder via Elfutils-devel
Hi, the attached patches get rid of nested functions in libdwfl/link_map.c. I wrote these a while back and just looked at them again and we could use the same read_state struct here as well. I just quickly checked, but it seems a bit more involved due to the integrated_memory_callback handling. I

[PATCH 3/3] segment_report_module: Inline consider_notes() into only caller

2020-11-26 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of a nested function this way. --- libdwfl/dwfl_segment_report_module.c | 162 +-- 1 file changed, 80 insertions(+), 82 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index a082886a..c48d9ab

[PATCH 2/3] segment_report_module: Pull read_portion() into file scope

2020-11-26 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 65 +++- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 391fd761..a082886a 100644 --- a/libdwfl/dwfl_segment_rep

[PATCH 1/3] segment_report_module: Pull finish_portion() into file scope

2020-11-26 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Use a read_state struct here to minimize the amount of parameters we pass. --- libdwfl/dwfl_segment_report_module.c | 38 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_rep

Remove remaining nested functions from libdwfl

2020-11-26 Thread Timm Bäder via Elfutils-devel
Here are the three patches to remove the three remaining nested functions from libdwfl/dwfl_segment_report_module.c.

Re: Remove nested functions from libdwfl V2

2020-11-26 Thread Timm Bäder via Elfutils-devel
On 25/11/2020 17:33, Mark Wielaard wrote: Hi Timm, On Mon, 2020-11-23 at 13:27 +0100, Timm Bäder via Elfutils-devel wrote: version 2 of this patch set. I removed segmend_read() entirely now, which meant modifying a bunch of later patches. Other than that, they are the same. Hope the --from to

[PATCH 08/12] segment_report_module: Use one loop for p32/p64 arrays

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Do one loop check for 32/64 bit inside the loop, instead of outside. This way we have only one call site for the function called in the loop body. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 52 +++- 1 file changed, 27 insertion

[PATCH 10/12] segment_report_module: Unify d32/d64 loops

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Just like we did before, use only one loop here and check for 32/64 bit in the loop body. This way we only have one call site for consider_dyn Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 28 ++-- 1 file changed, 14 insertions(+)

[PATCH 11/12] segment_report_module: Inline consider_dyn() into only caller

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 40 +--- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 8613ce21..046d5381 100644 ---

[PATCH 03/12] segment_report_module: Pull finish_portion() info file scope

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 24 ++-- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 848c3bec..c55168ed 100644 --- a/l

[PATCH 04/12] segment_report_module: Pull read_portion() into file scope

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 77 +--- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index c55168ed..01adfe9e 100644 ---

[PATCH 12/12] segment_report_module: Inline consider_phdr() into only caller

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Get rid of the nested function this way Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 142 +-- 1 file changed, 66 insertions(+), 76 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_mod

[PATCH 09/12] segment_report_module: Inline read_phdr() into only caller

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder There is now only one caller for this nested function, so get rid of it by just inlining it there. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 24 +--- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/libdwfl/dwfl_segm

[PATCH 07/12] segment_report_module: Get rid of nested final_read() function

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 6c6f9f37..a69ead8f 100644 --- a/

[PATCH 06/12] segment_report_module: Pull consider_notes() into file scope

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 187 +++ 1 file changed, 101 insertions(+), 86 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 6abbf992..6c6f9f37 100644 --

[PATCH 05/12] segment_report_module: Use a struct for build id information

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Keep the three build id fields in a struct. This will be an important clean up later. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 54 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/libdwfl/dwfl_segment_repo

[PATCH 02/12] segment_report_module: Remove nested release_buffer() function

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index c587efd7..848c3bec 100644 --- a/libdwfl/dw

[PATCH 01/12] segment_report_module: Get rid of segment_read()

2020-11-23 Thread Timm Bäder via Elfutils-devel
From: Timm Bäder Just inline the memory_callback call everywhere segmenty_read was used. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 24 +--- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libd

Remove nested functions from libdwfl V2

2020-11-23 Thread Timm Bäder via Elfutils-devel
Hi again, version 2 of this patch set. I removed segmend_read() entirely now, which meant modifying a bunch of later patches. Other than that, they are the same. Hope the --from to git send-email worked out, too. Thanks, Timm

Re: Removing gnu99 constructs from elfutils

2020-11-13 Thread Timm Bäder via Elfutils-devel
On 13/11/2020 13:38, Mark Wielaard wrote: OK. The mail subject is a little misleading, this is far from turning the code base into ISO C99. gnu99 is much more than those two features: https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html Right, I wasn't trying to get rid of all the gnu99 feature

Re: [PATCH 14/14] segment_report_module: Inline consider_phdr() into only caller

2020-11-12 Thread Timm Bäder via Elfutils-devel
On 12/11/2020 17:52, Navin P wrote: Hi, I already have a patch that makes elfutils compile with clang. Since you are working this will be of use to you. I've attached the patch since it is big. Here are some of the changes 1. All functions at file scope have static qualifier so that no col

[PATCH 11/14] segment_report_module: Inline read_phdr() into only caller

2020-11-12 Thread Timm Bäder via Elfutils-devel
There is now only one caller for this nested function, so get rid of it by just inlining it there. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 25 + 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.

[PATCH 03/14] segment_report_module: Remove nested finish() function

2020-11-12 Thread Timm Bäder via Elfutils-devel
This works just as well with a goto-out style label. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 50 +--- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c

[PATCH 01/14] segment_report_module: Get rid of variable-length arrays

2020-11-12 Thread Timm Bäder via Elfutils-devel
This prevents a jump which is needed in a later patch. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 36 ++-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.

[PATCH 10/14] segment_report_module: Use one loop for p32/p64 arrays

2020-11-12 Thread Timm Bäder via Elfutils-devel
Do one loop check for 32/64 bit inside the loop, instead of outside. This way we have only one call site for the function called in the loop body. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 52 +++- 1 file changed, 27 insertions(+), 25 deletions(

Removing gnu99 constructs from elfutils

2020-11-12 Thread Timm Bäder via Elfutils-devel
Hi, I'm looking into removing both the nested functions as well as variable-length arrays in the elfutils source code, so it can be built using clang. This is a continuation of https://sourceware.org/bugzilla/show_bug.cgi?id=24964 basically. I did try to incorporate some cleanup commits as well s

[PATCH 09/14] segment_report_module: Get rid of nested final_read() function

2020-11-12 Thread Timm Bäder via Elfutils-devel
Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 26 +++--- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 76686a72..80f97cfd 100644 --- a/libdwfl/dwfl_segme

[PATCH 12/14] segment_report_module: Unify d32/d64 loops

2020-11-12 Thread Timm Bäder via Elfutils-devel
Just like we did before, use only one loop here and check for 32/64 bit in the loop body. This way we only have one call site for consider_dyn Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-)

[PATCH 08/14] segment_report_module: Pull consider_notes() into file scope

2020-11-12 Thread Timm Bäder via Elfutils-devel
Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 187 +++ 1 file changed, 101 insertions(+), 86 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 44743fab..76686a72 100644 --- a/libdwfl/dwfl_se

[PATCH 04/14] segment_report_module: Remove nested release_buffer() function

2020-11-12 Thread Timm Bäder via Elfutils-devel
Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index d06d0ba0..ba11b60a 100644 --- a/libdwfl/dwfl_segment_report_m

[PATCH 13/14] segment_report_module: Inline consider_dyn() into only caller

2020-11-12 Thread Timm Bäder via Elfutils-devel
Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 40 +--- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 7c97784f..0679453e 100644 --- a/libdwfl/dwfl_seg

[PATCH 07/14] segment_report_module: Use a struct for build id information

2020-11-12 Thread Timm Bäder via Elfutils-devel
Keep the three build id fields in a struct. This will be an important clean up later. Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 54 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libd

[PATCH 05/14] segment_report_module: Pull finish_portion() info file scope

2020-11-12 Thread Timm Bäder via Elfutils-devel
Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index ba11b60a..751a96f1 100644 --- a/libdwfl/dwfl_segm

[PATCH 14/14] segment_report_module: Inline consider_phdr() into only caller

2020-11-12 Thread Timm Bäder via Elfutils-devel
Get rid of the nested function this way Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 142 +-- 1 file changed, 66 insertions(+), 76 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 0679453

[PATCH 02/14] segment_report_module: Pull segment_read into file scope

2020-11-12 Thread Timm Bäder via Elfutils-devel
In preparation of getting rid of nested functions Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 30 +--- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c ind

[PATCH 06/14] segment_report_module: Pull read_portion() into file scope

2020-11-12 Thread Timm Bäder via Elfutils-devel
Signed-off-by: Timm Bäder --- libdwfl/dwfl_segment_report_module.c | 79 +--- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 751a96f1..00455aa4 100644 --- a/libdwfl/dwfl_seg

  1   2   >