diff --git a/src/ring.c b/src/ring.c index c2668afec..6abbe2caf 100644 --- a/src/ring.c +++ b/src/ring.c @@ -115,7 +115,7 @@ struct ring *ring_resize(struct ring *ring, size_t size) { struct ring_storage *new; - if (size <= ring_size(ring) + sizeof(*ring->storage)) + if (size <= ring_data(ring) + sizeof(*ring->storage)) return ring; new = malloc(size); @@ -124,9 +124,8 @@ struct ring *ring_resize(struct ring *ring, size_t size) thread_isolate(); - /* recheck the buffer's size, it may have changed during the malloc */ - - if (size > ring_size(ring) + sizeof(*ring->storage)) { + /* recheck the ring's size, it may have changed during the malloc */ + if (size > ring_data(ring) + sizeof(*ring->storage)) { /* copy old contents */ new->buf = b_make(new->area, size - sizeof(*ring->storage), 0, 0); b_getblk(&ring->storage->buf, new->area, ring_data(ring), 0); diff --git a/src/sink.c b/src/sink.c index 897f6766f..7225ddd7f 100644 --- a/src/sink.c +++ b/src/sink.c @@ -907,9 +907,9 @@ int cfg_parse_ring(const char *file, int linenum, char **args, int kwm) goto err; } - if (size < ring_size(cfg_sink->ctx.ring)) { - ha_warning("parsing [%s:%d] : ignoring new size '%llu' that is smaller than current size '%llu' for ring '%s'.\n", - file, linenum, (ullong)size, (ullong)ring_size(cfg_sink->ctx.ring), cfg_sink->name); + if (size < ring_data(cfg_sink->ctx.ring)) { + ha_warning("parsing [%s:%d] : ignoring new size '%llu' that is smaller than contents '%llu' for ring '%s'.\n", + file, linenum, (ullong)size, (ullong)ring_data(cfg_sink->ctx.ring), cfg_sink->name); err_code |= ERR_WARN; goto err; }