On Fri, Jul 14, 2017 at 10:15:49PM +0200, Jeremie Courreges-Anglas wrote: > I find this more readable.
yes, it is > /* Step 4, compress the log.0 file if configured to do so and free */ > - while (p) { > + TAILQ_FOREACH_SAFE(p, &runlist, next, tmp) { > if ((p->flags & CE_COMPACT) && (p->flags & CE_ROTATED) && > p->numlogs > 0) > compress_log(p); > - q = p; > - p = p->next; > - free(q); > + free(p); > } The usual idiom for freeing a list is: while ((p = TAILQ_FIRST(&runlist))) { TAILQ_REMOVE(&runlist, p, next); ... free(p); } Your code leaves a list of freed objects which is not clean. As we are close to exit, you could also not free anything and use a TAILQ_FOREACH. otherwise OK bluhm@