<div dir="ltr">Oops sorry I'll resend with the Signed-off-by.<div>For the underscores, I was trying to keep the same style as the rest of the code, but I can resend a patch with all the "__identifiers" switched to "identifiers__"?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 27, 2017 at 4:58 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:52PM +0200, Damien Grassart wrote:<br>
> To be consistent with the rest of the code, the index paramater should<br>
> not be evaluated multiple times. Calling this with rand() % arr.size<br>
> would otherwise generally segfault.<br>
> ---<br>
> ccan/darray/darray.h | 5 +++--<br>
> 1 file changed, 3 insertions(+), 2 deletions(-)<br>
<br>
</span>Looks like a definite improvement, but I need a Signed-off-by line in<br>
order to apply it.<br>
<br>
Also.. identifiers starting with _ are technically reserved for system<br>
use. You'd probably get away with it, but it's best to avoid them. I<br>
usually put _ after the name instead for this sort of thing.<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> diff --git a/ccan/darray/darray.h b/ccan/darray/darray.h<br>
> index 8d47645b..6dd34f08 100644<br>
> --- a/ccan/darray/darray.h<br>
> +++ b/ccan/darray/darray.h<br>
> @@ -224,8 +224,9 @@ typedef darray(unsigned long) darray_ulong;<br>
> #define darray_pop_check(arr) ((arr).size ? darray_pop(arr) : NULL)<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-index)*sizeof(*(<wbr>arr).item)); \<br>
> + size_t __index = index; \<br>
> + if (__index < arr.size-1) \<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>