public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH] libelf: Do not cast pointer to integer in gelf_newphdr
Date: Tue, 11 Oct 2016 23:12:11 +0900	[thread overview]
Message-ID: <20161011141211.11781-1-akihiko.odaki.4i@stu.hosei.ac.jp> (raw)

[-- Attachment #1: Type: text/plain, Size: 2420 bytes --]

unsigned long int is not always capable to have pointer in some cases
(LLP64, for example).

Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
---
 libelf/gelf.h         | 4 ++--
 libelf/gelf_newehdr.c | 6 +++---
 libelf/gelf_newphdr.c | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libelf/gelf.h b/libelf/gelf.h
index 1bc7ee7..0c31c27 100644
--- a/libelf/gelf.h
+++ b/libelf/gelf.h
@@ -166,7 +166,7 @@ extern GElf_Ehdr *gelf_getehdr (Elf *__elf, GElf_Ehdr *__dest);
 extern int gelf_update_ehdr (Elf *__elf, GElf_Ehdr *__src);
 
 /* Create new ELF header if none exists.  */
-extern unsigned long int gelf_newehdr (Elf *__elf, int __class);
+extern void *gelf_newehdr (Elf *__elf, int __class);
 
 /* Get section at OFFSET.  */
 extern Elf_Scn *gelf_offscn (Elf *__elf, GElf_Off __offset);
@@ -184,7 +184,7 @@ extern GElf_Phdr *gelf_getphdr (Elf *__elf, int __ndx, GElf_Phdr *__dst);
 extern int gelf_update_phdr (Elf *__elf, int __ndx, GElf_Phdr *__src);
 
 /* Create new program header with PHNUM entries.  */
-extern unsigned long int gelf_newphdr (Elf *__elf, size_t __phnum);
+extern void *gelf_newphdr (Elf *__elf, size_t __phnum);
 
 /* Get compression header of section if any.  Returns NULL and sets
    elf_errno if the section isn't compressed or an error occurred.  */
diff --git a/libelf/gelf_newehdr.c b/libelf/gelf_newehdr.c
index cfa80e1..2788906 100644
--- a/libelf/gelf_newehdr.c
+++ b/libelf/gelf_newehdr.c
@@ -37,10 +37,10 @@
 #include "libelfP.h"
 
 
-unsigned long int
+void *
 gelf_newehdr (Elf *elf, int class)
 {
   return (class == ELFCLASS32
-	  ? (unsigned long int) INTUSE(elf32_newehdr) (elf)
-	  : (unsigned long int) INTUSE(elf64_newehdr) (elf));
+	  ? (void *) INTUSE(elf32_newehdr) (elf)
+	  : (void *) INTUSE(elf64_newehdr) (elf));
 }
diff --git a/libelf/gelf_newphdr.c b/libelf/gelf_newphdr.c
index 4e95474..84aad78 100644
--- a/libelf/gelf_newphdr.c
+++ b/libelf/gelf_newphdr.c
@@ -37,10 +37,10 @@
 #include "libelfP.h"
 
 
-unsigned long int
+void *
 gelf_newphdr ( Elf *elf, size_t phnum)
 {
   return (elf->class == ELFCLASS32
-	  ? (unsigned long int) INTUSE(elf32_newphdr) (elf, phnum)
-	  : (unsigned long int) INTUSE(elf64_newphdr) (elf, phnum));
+	  ? (void *) INTUSE(elf32_newphdr) (elf, phnum)
+	  : (void *) INTUSE(elf64_newphdr) (elf, phnum));
 }
-- 
2.10.0

             reply	other threads:[~2016-10-11 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-11 14:12 Akihiko Odaki [this message]
2016-10-13 10:28 Mark Wielaard
2016-10-13 16:51 Josh Stone
2016-12-07 14:31 Mark Wielaard

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=20161011141211.11781-1-akihiko.odaki.4i@stu.hosei.ac.jp \
    --to=akihiko.odaki.4i@stu.hosei.ac.jp \
    --cc=elfutils-devel@lists.fedorahosted.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).