From: Michal Marek <mmarek@suse.cz>
To: Daniel Tang <dt.tangr@gmail.com>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
trivial@kernel.org
Subject: Re: [PATCH 1/2] Fix a build warning in scripts/sortextable.h
Date: Wed, 03 Jul 2013 14:06:49 +0200 [thread overview]
Message-ID: <51D413D9.8040604@suse.cz> (raw)
In-Reply-To: <1370745235-12951-1-git-send-email-dt.tangr@gmail.com>
Added David Daney to CC.
On 9.6.2013 04:33, Daniel Tang wrote:
> The pointer passed to the _r() macro does not always match the type
> of the function that it is aliasing and raises several of the following
> warnings at compile time:
>
> warning: passing argument 1 of ‘r8’ from incompatible pointer type
In what environment (arch, compiler, glibc) are you seeing this?
Michal
> Fixed by casting the pointers to (void *) so they work with both the
> 32bit and 64bit code.
>
> Signed-off-by: Daniel Tang <dt.tangr@gmail.com>
> ---
> scripts/sortextable.h | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/sortextable.h b/scripts/sortextable.h
> index f5eb43d..0a38fbd 100644
> --- a/scripts/sortextable.h
> +++ b/scripts/sortextable.h
> @@ -110,9 +110,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
> int i;
> int idx;
>
> - shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
> + shdr = (Elf_Shdr *)((char *)ehdr + _r((void *)&ehdr->e_shoff));
> shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
> - secstrtab = (const char *)ehdr + _r(&shstrtab_sec->sh_offset);
> + secstrtab = (const char *)ehdr + _r((void *)&shstrtab_sec->sh_offset);
> for (i = 0; i < r2(&ehdr->e_shnum); i++) {
> idx = r(&shdr[i].sh_name);
> if (strcmp(secstrtab + idx, "__ex_table") == 0) {
> @@ -122,8 +122,8 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
> if ((r(&shdr[i].sh_type) == SHT_REL ||
> r(&shdr[i].sh_type) == SHT_RELA) &&
> r(&shdr[i].sh_info) == extab_index) {
> - relocs = (void *)ehdr + _r(&shdr[i].sh_offset);
> - relocs_size = _r(&shdr[i].sh_size);
> + relocs = (void *)ehdr + _r((void *)&shdr[i].sh_offset);
> + relocs_size = _r((void *)&shdr[i].sh_size);
> }
> if (strcmp(secstrtab + idx, ".symtab") == 0)
> symtab_sec = shdr + i;
> @@ -142,14 +142,14 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
> fprintf(stderr, "no __ex_table in file: %s\n", fname);
> fail_file();
> }
> - strtab = (const char *)ehdr + _r(&strtab_sec->sh_offset);
> + strtab = (const char *)ehdr + _r((void *)&strtab_sec->sh_offset);
>
> - extab_image = (void *)ehdr + _r(&extab_sec->sh_offset);
> + extab_image = (void *)ehdr + _r((void *)&extab_sec->sh_offset);
>
> if (custom_sort) {
> - custom_sort(extab_image, _r(&extab_sec->sh_size));
> + custom_sort(extab_image, _r((void *)&extab_sec->sh_size));
> } else {
> - int num_entries = _r(&extab_sec->sh_size) / extable_ent_size;
> + int num_entries = _r((void *)&extab_sec->sh_size) / extable_ent_size;
> qsort(extab_image, num_entries,
> extable_ent_size, compare_extable);
> }
> @@ -159,12 +159,13 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
>
> /* find main_extable_sort_needed */
> sort_needed_sym = NULL;
> - for (i = 0; i < _r(&symtab_sec->sh_size) / sizeof(Elf_Sym); i++) {
> - sym = (void *)ehdr + _r(&symtab_sec->sh_offset);
> + for (i = 0; i < _r((void *)&symtab_sec->sh_size) / sizeof(Elf_Sym); i++)
> + {
> + sym = (void *)ehdr + _r((void *)&symtab_sec->sh_offset);
> sym += i;
> if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
> continue;
> - idx = r(&sym->st_name);
> + idx = r((void *)&sym->st_name);
> if (strcmp(strtab + idx, "main_extable_sort_needed") == 0) {
> sort_needed_sym = sym;
> break;
> @@ -178,9 +179,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
> }
> sort_needed_sec = &shdr[r2(&sort_needed_sym->st_shndx)];
> sort_done_location = (void *)ehdr +
> - _r(&sort_needed_sec->sh_offset) +
> - _r(&sort_needed_sym->st_value) -
> - _r(&sort_needed_sec->sh_addr);
> + _r((void *)&sort_needed_sec->sh_offset) +
> + _r((void *)&sort_needed_sym->st_value) -
> + _r((void *)&sort_needed_sec->sh_addr);
>
> #if 0
> printf("sort done marker at %lx\n",
>
next prev parent reply other threads:[~2013-07-03 12:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 2:33 [PATCH 1/2] Fix a build warning in scripts/sortextable.h Daniel Tang
2013-06-09 2:33 ` [PATCH 2/2] Fix a build warning in scripts/mod/file2alias.c Daniel Tang
2013-07-03 12:31 ` Michal Marek
2013-07-03 12:06 ` Michal Marek [this message]
2013-07-03 12:07 ` [PATCH 1/2] Fix a build warning in scripts/sortextable.h Michal Marek
2013-07-03 12:12 ` Daniel Tang
2013-07-03 12:28 ` Michal Marek
2013-07-03 12:37 ` Daniel Tang
2013-07-03 12:57 ` Michal Marek
2013-07-03 13:15 ` Michal Marek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51D413D9.8040604@suse.cz \
--to=mmarek@suse.cz \
--cc=dt.tangr@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox