]> Git Repo - qemu.git/commitdiff
virtion-net: Prefer is_power_of_2()
authorMichal Privoznik <[email protected]>
Thu, 13 Jul 2017 07:44:38 +0000 (09:44 +0200)
committerJason Wang <[email protected]>
Mon, 17 Jul 2017 12:13:55 +0000 (20:13 +0800)
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 <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
hw/net/virtio-net.c

index 5630a9ec445b82e269a6ef0b7a9c3c6444d16dbc..657d099c5440b0835f8355932394f1caeffd6672 100644 (file)
@@ -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,
This page took 0.022121 seconds and 4 git commands to generate.