ccan.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] darray: Fix bug in the darray_remove() macro
@ 2017-08-26 16:26 Damien Grassart
  2017-08-27  2:56 ` David Gibson
  0 siblings, 1 reply; 11+ messages in thread
From: Damien Grassart @ 2017-08-26 16:26 UTC (permalink / raw)
  To: ccan

The memmove() call should be using the index argument to determine the
number of bytes to copy.

Signed-off-by: Damien Grassart <damien@grassart.com>
---
 ccan/darray/darray.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ccan/darray/darray.h b/ccan/darray/darray.h
index 75112419..8d47645b 100644
--- a/ccan/darray/darray.h
+++ b/ccan/darray/darray.h
@@ -225,7 +225,7 @@ typedef darray(unsigned long)  darray_ulong;
 /* Warning, slow: Requires copying all elements after removed item. */
 #define darray_remove(arr, index) do { \
 	if (index < arr.size-1)    \
-		memmove(&(arr).item[index], &(arr).item[index+1], ((arr).size-1-i)*sizeof(*(arr).item)); \
+		memmove(&(arr).item[index], &(arr).item[index+1], ((arr).size-1-index)*sizeof(*(arr).item)); \
 	(arr).size--;  \
 	} while(0)
 
-- 
2.14.1

_______________________________________________
ccan mailing list
ccan@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/ccan

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-08-29 10:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-26 16:26 [PATCH 1/2] darray: Fix bug in the darray_remove() macro Damien Grassart
2017-08-27  2:56 ` David Gibson
2017-08-27 21:02   ` Damien Grassart
2017-08-27 21:26   ` [PATCH 1/2] darray: Rename identifiers starting with an underscore Damien Grassart
2017-08-27 21:26     ` [PATCH 2/2] darray: Fix bug in the darray_remove() macro Damien Grassart
2017-08-28  2:48       ` David Gibson
2017-08-28  5:03         ` Damien Grassart
2017-08-28  5:09         ` [PATCH] " Damien Grassart
2017-08-29  4:54           ` David Gibson
2017-08-29 10:08             ` Damien Grassart
2017-08-28  2:43     ` [PATCH 1/2] darray: Rename identifiers starting with an underscore David Gibson

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 NNTP newsgroup(s).