X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Fwaiter%2Fwaiter.c;h=68f483acac03adaea7955cf91dd1fc2f2197a75a;hp=21dd4a589650d207b65441e05b61a0aaf8255aa2;hb=e93e46bfecdef5511953cd3ce1f01b0546d98af8;hpb=812761a1f8ff94e4913529840b905360ff843fc4 diff --git a/lib/waiter/waiter.c b/lib/waiter/waiter.c index 21dd4a5..68f483a 100644 --- a/lib/waiter/waiter.c +++ b/lib/waiter/waiter.c @@ -43,7 +43,8 @@ void waiter_remove(struct waiter *waiter) assert(i >= 0 && i < n_waiters); n_waiters--; - memmove(&waiters[i], &waiters[i+1], n_waiters - i); + memmove(&waiters[i], &waiters[i+1], + (n_waiters - i) * sizeof(waiters[0])); waiters = talloc_realloc(NULL, waiters, struct waiter, n_waiters); } @@ -54,9 +55,10 @@ int waiter_poll(void) static int n_pollfds; int i, rc; - if (n_waiters > n_pollfds) { + if (n_waiters != n_pollfds) { pollfds = talloc_realloc(NULL, pollfds, struct pollfd, n_waiters); + n_pollfds = n_waiters; } for (i = 0; i < n_waiters; i++) {