aboutsummaryrefslogtreecommitdiff
path: root/hw/net
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2017-07-13 09:44:38 +0200
committerJason Wang <jasowang@redhat.com>2017-07-17 20:13:55 +0800
commit5f997fd17b9be6a662fa7b5cc1305076cd6c8894 (patch)
tree0bf2b2fd6571303bd2133bdca851c0762403d098 /hw/net
parent2484ff06249af64896885564b73af4f0750adfa2 (diff)
downloadqemu-5f997fd17b9be6a662fa7b5cc1305076cd6c8894.zip
qemu-5f997fd17b9be6a662fa7b5cc1305076cd6c8894.tar.gz
qemu-5f997fd17b9be6a662fa7b5cc1305076cd6c8894.tar.bz2
virtion-net: Prefer is_power_of_2()
We have a function that checks if given number is power of two. We should prefer it instead of expanding the check on our own. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net')
-rw-r--r--hw/net/virtio-net.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5630a9e..657d099 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1942,7 +1942,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
*/
if (n->net_conf.rx_queue_size < VIRTIO_NET_RX_QUEUE_MIN_SIZE ||
n->net_conf.rx_queue_size > VIRTQUEUE_MAX_SIZE ||
- (n->net_conf.rx_queue_size & (n->net_conf.rx_queue_size - 1))) {
+ !is_power_of_2(n->net_conf.rx_queue_size)) {
error_setg(errp, "Invalid rx_queue_size (= %" PRIu16 "), "
"must be a power of 2 between %d and %d.",
n->net_conf.rx_queue_size, VIRTIO_NET_RX_QUEUE_MIN_SIZE,