<div dir="ltr">Good point about shadowing index(3), I'll send a patch renaming all the uses of 'index'.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 27, 2017 at 4:56 AM, David Gibson <span dir="ltr"><<a href="mailto:david@gibson.dropbear.id.au" target="_blank">david@gibson.dropbear.id.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, Aug 26, 2017 at 06:26:20PM +0200, Damien Grassart wrote:<br>
> The memmove() call should be using the index argument to determine the<br>
> number of bytes to copy.<br>
><br>
> Signed-off-by: Damien Grassart <<a href="mailto:damien@grassart.com">damien@grassart.com</a>><br>
<br>
</span>No question that was a bug. Fix applied.<br>
<br>
Note for a possible future cleanup: calling identifiers 'index' is<br>
usually a bad idea, because it shadows index(3) in the C library,<br>
which means you can get really confusing errors (or lack of errors) if<br>
you remove the declaration but not the users.<br>
<div class="HOEnZb"><div class="h5"><br>
> ---<br>
> ccan/darray/darray.h | 2 +-<br>
> 1 file changed, 1 insertion(+), 1 deletion(-)<br>
><br>
> diff --git a/ccan/darray/darray.h b/ccan/darray/darray.h<br>
> index 75112419..8d47645b 100644<br>
> --- a/ccan/darray/darray.h<br>
> +++ b/ccan/darray/darray.h<br>
> @@ -225,7 +225,7 @@ typedef darray(unsigned long) darray_ulong;<br>
> /* Warning, slow: Requires copying all elements after removed item. */<br>
> #define darray_remove(arr, index) do { \<br>
> if (index < arr.size-1) \<br>
> - memmove(&(arr).item[index], &(arr).item[index+1], ((arr).size-1-i)*sizeof(*(arr)<wbr>.item)); \<br>
> + memmove(&(arr).item[index], &(arr).item[index+1], ((arr).size-1-index)*sizeof(*(<wbr>arr).item)); \<br>
> (arr).size--; \<br>
> } while(0)<br>
><br>
<br>
--<br>
</div></div><span class="HOEnZb"><font color="#888888">David Gibson | I'll have my music baroque, and my code<br>
david AT <a href="http://gibson.dropbear.id.au" rel="noreferrer" target="_blank">gibson.dropbear.id.au</a> | minimalist, thank you. NOT _the_ _other_<br>
| _way_ _around_!<br>
<a href="http://www.ozlabs.org/~dgibson" rel="noreferrer" target="_blank">http://www.ozlabs.org/~dgibson</a><br>
</font></span></blockquote></div><br></div>