This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gelf_getauxv: Use memcpy instead of pointer dereference to avoid alignment problems.

On Mon, 2013-08-26 at 15:29 -0700, Roland McGrath wrote:
> Arithmetic on void * is a GNU extension and we use it freely in elfutils
> code.  Don't insert unnecessary casts to char *.

I admit I wasn't aware of that extension
Treating the size of void as 1 does seem to be the only logical (and
convenient) choice. Now that I have seen it I wonder why the standard
doesn't just say that.

Anyway, unnecessary cast removed:

commit 4f017daab51f4281e9d859b2491efe83fd199692
Author: Mark Wielaard <>
Date:   Tue Aug 27 11:39:52 2013 +0200

    gelf_getauxv: Remove unnecessary casts to char *.
    Signed-off-by: Mark Wielaard <>

diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 46d4731..c867010 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2013-08-27  Mark Wielaard  <>
+       * gelf_getauxv.c (gelf_getauxv): Remove unnecessary casts to char *.
 2013-08-25  Kurt Roeckx  <>
        * gelf_getauxv.c (gelf_getauxv): Use memcpy instead of pointer
diff --git a/libelf/gelf_getauxv.c b/libelf/gelf_getauxv.c
index 2a5b6f0..6b91030 100644
--- a/libelf/gelf_getauxv.c
+++ b/libelf/gelf_getauxv.c
@@ -97,7 +97,7 @@ gelf_getauxv (data, ndx, dst)
          goto out;
-      memcpy(dst, (char *) data_scn->d.d_buf + ndx * sizeof (GElf_auxv_t),
+      memcpy(dst, data_scn->d.d_buf + ndx * sizeof (GElf_auxv_t),
             sizeof (GElf_auxv_t));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]