This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: Small code cleanup in dwfl_segment_report_module.c (Was: [commit] [PATCHv2 1/2] Add is_executable to Dwfl_Module.)
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Tue, 23 Sep 2014 14:58:58 +0200
- Subject: Re: Small code cleanup in dwfl_segment_report_module.c (Was: [commit] [PATCHv2 1/2] Add is_executable to Dwfl_Module.)
On Tue, 23 Sep 2014 14:50:13 +0200, Mark Wielaard wrote:
> Updated cleanup based on current master attached.
FYI I find that patch rather hiding what the code really does, in summary it
has done:
- if (ehdr.e32.e_ident[EI_DATA] == MY_ELFDATA)
+ ei_data = ((const unsigned char *) buffer)[EI_DATA];
+ if (ei_data == MY_ELFDATA)
- if (ehdr.e32.e_ident[EI_CLASS] == ELFCLASS32)
+ ei_class = ((const unsigned char *) buffer)[EI_CLASS];
+ if (ei_class == ELFCLASS32)
By jumping on the 'e_ident' tag one could say what is being referenced.
But now 'buffer' is 'void *' and it is being cast to 'const unsigned char *'.
And neither 'EI_DATA' nor 'EI_CLASS' reference 'e_ident' in their comment.
Not that it matters much but when there has been already some effort put into
it.
Jan