[PATCH] sparse: Use memmove in sort.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using valgrind on the example ctags program I get

==16863== Source and destination overlap in memcpy(0x7ff000100, 0x7ff000108, 192)
==16863==    at 0x4C2A690: memcpy (mc_replace_strmem.c:838)
==16863==    by 0x412D86: merge_block_seqs (sort.c:207)
==16863==    by 0x41303C: sort_list (sort.c:275)
==16863==    by 0x401225: main (ctags.c:224)

Fix it by using memmove instead of memcpy.

Signed-off-by: Rasmus Villemoes <rv@xxxxxxxxxxxxxxxxxx>
---
I'm not familiar with the code; maybe memcpy should be ok and there's
a bug elsewhere. Using memmove shouldn't hurt, though, except for a
small performance hit.

 sort.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sort.c b/sort.c
index afd7184..603f06c 100644
--- a/sort.c
+++ b/sort.c
@@ -97,9 +97,9 @@ static void verify_seq_sorted (struct ptr_list *l, int n,
   do {								\
 	int nr = (b)->nr;					\
 	assert (nbuf >= nr);					\
-	memcpy ((b)->list, buffer, nr * sizeof (void *));	\
+	memmove ((b)->list, buffer, nr * sizeof (void *));	\
 	nbuf -= nr;						\
-	memcpy (buffer, buffer + nr, nbuf * sizeof (void *));	\
+	memmove (buffer, buffer + nr, nbuf * sizeof (void *));	\
   } while (0)
 
 #define DUMP_TO(b)						\
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux