Greetings,
I've tried to build libunwind with Clang, which produced:
src/x86/Gget_save_loc.c:114:28: error: argument to 'sizeof' in
'memset' call is the same expression as the destination; did you mean
to dereference it? [-Werror,-Wsizeof-pointer-memaccess]  memset (sloc,
0, sizeof (sloc));          ~~~~             ^~~~

This does look like a bug to me.
I've audited other memset() calls, and believe there was one more bug
of the same kind.
Tested on Linux/x86_64; no new failures.
Thanks,-- Paul Pluzhnikov
diff --git a/src/arm/Gget_save_loc.c b/src/arm/Gget_save_loc.c
index ba7bf17..151ba0f 100644
--- a/src/arm/Gget_save_loc.c
+++ b/src/arm/Gget_save_loc.c
@@ -57,7 +57,7 @@ unw_get_save_loc (unw_cursor_t *cursor, int reg, 
unw_save_loc_t *sloc)
       break;
     }
 
-  memset (sloc, 0, sizeof (sloc));
+  memset (sloc, 0, sizeof (*sloc));
 
   if (DWARF_IS_NULL_LOC (loc))
     {
diff --git a/src/hppa/Gget_save_loc.c b/src/hppa/Gget_save_loc.c
index 7aa6f31..1b21919 100644
--- a/src/hppa/Gget_save_loc.c
+++ b/src/hppa/Gget_save_loc.c
@@ -35,7 +35,7 @@ unw_get_save_loc (unw_cursor_t *cursor, int reg, 
unw_save_loc_t *sloc)
 
 #warning FIX ME!
 
-  memset (sloc, 0, sizeof (sloc));
+  memset (sloc, 0, sizeof (*sloc));
 
   if (DWARF_IS_NULL_LOC (loc))
     {
diff --git a/src/ia64/Gget_save_loc.c b/src/ia64/Gget_save_loc.c
index 7bc2b19..49bdaba 100644
--- a/src/ia64/Gget_save_loc.c
+++ b/src/ia64/Gget_save_loc.c
@@ -142,7 +142,7 @@ unw_get_save_loc (unw_cursor_t *cursor, int reg, 
unw_save_loc_t *sloc)
       break;
     }
 
-  memset (sloc, 0, sizeof (sloc));
+  memset (sloc, 0, sizeof (*sloc));
 
   if (IA64_IS_NULL_LOC (loc))
     {
diff --git a/src/mips/Gget_save_loc.c b/src/mips/Gget_save_loc.c
index dbccea8..262e23e 100644
--- a/src/mips/Gget_save_loc.c
+++ b/src/mips/Gget_save_loc.c
@@ -75,7 +75,7 @@ unw_get_save_loc (unw_cursor_t *cursor, int reg, 
unw_save_loc_t *sloc)
       break;
     }
 
-  memset (sloc, 0, sizeof (sloc));
+  memset (sloc, 0, sizeof (*sloc));
 
   if (DWARF_IS_NULL_LOC (loc))
     {
diff --git a/src/x86/Gget_save_loc.c b/src/x86/Gget_save_loc.c
index 6e6f9dc..e8cc79e 100644
--- a/src/x86/Gget_save_loc.c
+++ b/src/x86/Gget_save_loc.c
@@ -109,7 +109,7 @@ unw_get_save_loc (unw_cursor_t *cursor, int reg, 
unw_save_loc_t *sloc)
       break;
     }
 
-  memset (sloc, 0, sizeof (sloc));
+  memset (sloc, 0, sizeof (*sloc));
 
   if (DWARF_IS_NULL_LOC (loc))
     {
diff --git a/src/x86_64/Gget_save_loc.c b/src/x86_64/Gget_save_loc.c
index db81db3..20b14a5 100644
--- a/src/x86_64/Gget_save_loc.c
+++ b/src/x86_64/Gget_save_loc.c
@@ -49,7 +49,7 @@ unw_get_save_loc (unw_cursor_t *cursor, int reg, 
unw_save_loc_t *sloc)
       break;
     }
 
-  memset (sloc, 0, sizeof (sloc));
+  memset (sloc, 0, sizeof (*sloc));
 
   if (DWARF_IS_NULL_LOC (loc))
     {
diff --git a/tests/test-proc-info.c b/tests/test-proc-info.c
index 9e039c6..e8915fb 100644
--- a/tests/test-proc-info.c
+++ b/tests/test-proc-info.c
@@ -72,7 +72,7 @@ access_fpreg (unw_addr_space_t as, unw_regnum_t regnum, 
unw_fpreg_t *valp,
              int write, void *arg)
 {
   if (!write)
-    memset (valp, 0, sizeof (valp));
+    memset (valp, 0, sizeof (*valp));
   return 0;
 }
 
_______________________________________________
Libunwind-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/libunwind-devel

Reply via email to