diff options
author | Matt Helsley <mhelsley@vmware.com> | 2019-07-31 11:24:15 -0700 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-08-31 12:19:40 -0400 |
commit | c97fea26254b284c93a67b788968622f9cc03b30 (patch) | |
tree | 9e527e732824fa37b2c0e8a5ee2ef04855a1c8aa /scripts/recordmcount.h | |
parent | 2e63152bc1909e10b7bc844bbbef5a815f585b45 (diff) |
recordmcount: Remove redundant cleanup() calls
Redundant cleanup calls were introduced when transitioning from
the old error/success handling via setjmp/longjmp -- the longjmp
ensured the cleanup() call only happened once but replacing
the success_file()/fail_file() calls with cleanup() meant that
multiple cleanup() calls can happen as we return from function
calls.
In do_file(), looking just before and after the "goto out" jumps we
can see that multiple cleanups() are being performed. We remove
cleanup() calls from the nested functions because it makes the code
easier to review -- the resources being cleaned up are generally
allocated and initialized in the callers so freeing them there
makes more sense.
Other redundant cleanup() calls:
mmap_file() is only called from do_file() and, if mmap_file() fails,
then we goto out and do cleanup() there too.
write_file() is only called from do_file() and do_file()
calls cleanup() unconditionally after returning from write_file()
therefore the cleanup() calls in write_file() are not necessary.
find_secsym_ndx(), called from do_func()'s for-loop, when we are
cleaning up here it's obvious that we break out of the loop and
do another cleanup().
__has_rel_mcount() is called from two parts of do_func()
and calls cleanup(). In theory we move them into do_func(), however
these in turn prove redundant so another simplification step
removes them as well.
Link: http://lkml.kernel.org/r/de197e17fc5426623a847ea7cf3a1560a7402a4b.1564596289.git.mhelsley@vmware.com
Signed-off-by: Matt Helsley <mhelsley@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'scripts/recordmcount.h')
-rw-r--r-- | scripts/recordmcount.h | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h index ca9aaac89bfb..8f0a278ce0af 100644 --- a/scripts/recordmcount.h +++ b/scripts/recordmcount.h @@ -463,7 +463,6 @@ static int find_secsym_ndx(unsigned const txtndx, } fprintf(stderr, "Cannot find symbol for section %u: %s.\n", txtndx, txtname); - cleanup(); return -1; } @@ -480,7 +479,6 @@ static char const * __has_rel_mcount(Elf_Shdr const *const relhdr, /* reltype */ if (strcmp("__mcount_loc", txtname) == 0) { fprintf(stderr, "warning: __mcount_loc already exists: %s\n", fname); - cleanup(); return already_has_rel_mcount; } if (w(txthdr->sh_type) != SHT_PROGBITS || |