diff --git a/include/haproxy/buf.h b/include/haproxy/buf.h index bb0f0b73b..2081a2ab7 100644 --- a/include/haproxy/buf.h +++ b/include/haproxy/buf.h @@ -183,8 +183,9 @@ static inline size_t b_peek_ofs(const struct buffer *b, size_t ofs) { size_t ret = __b_peek_ofs(b, ofs); - if (ret >= b->size) - ret -= b->size; + if (likely(!__builtin_constant_p(ofs) || ofs)) + if (ret >= b->size) + ret -= b->size; return ret; }