From: mikeb Date: Fri, 5 Aug 2016 18:05:44 +0000 (+0000) Subject: Remove incorrect optimization: ring data portion size is not power of 2 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0cfd58174bdeb92e8bbb188693d7a4c569405c5d;p=openbsd Remove incorrect optimization: ring data portion size is not power of 2 --- diff --git a/sys/dev/pv/hyperv.c b/sys/dev/pv/hyperv.c index ddd21e3aceb..b7970a092f1 100644 --- a/sys/dev/pv/hyperv.c +++ b/sys/dev/pv/hyperv.c @@ -1226,7 +1226,7 @@ hv_ring_put(struct hv_ring_data *wrd, uint8_t *data, uint32_t datalen) memcpy(&wrd->rd_ring->buffer[wrd->rd_prod], data, left); memcpy(&wrd->rd_ring->buffer[0], data + left, datalen - left); wrd->rd_prod += datalen; - wrd->rd_prod &= wrd->rd_data_size - 1; + wrd->rd_prod %= wrd->rd_data_size; } static inline void @@ -1239,7 +1239,7 @@ hv_ring_get(struct hv_ring_data *rrd, uint8_t *data, uint32_t datalen, memcpy(data + left, &rrd->rd_ring->buffer[0], datalen - left); if (!peek) { rrd->rd_cons += datalen; - rrd->rd_cons &= rrd->rd_data_size - 1; + rrd->rd_cons %= rrd->rd_data_size; } } @@ -1418,7 +1418,7 @@ hv_ring_read(struct hv_ring_data *rrd, void *data, uint32_t datalen, if (offset) { rrd->rd_cons += offset; - rrd->rd_cons &= rrd->rd_data_size - 1; + rrd->rd_cons %= rrd->rd_data_size; } hv_ring_get(rrd, (uint8_t *)data, datalen, 0);