clean code of ring_buf.