qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] virtion-net: Prefer is_power_of_2()


From: Jason Wang
Subject: Re: [Qemu-devel] [PATCH] virtion-net: Prefer is_power_of_2()
Date: Fri, 14 Jul 2017 15:43:57 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1



On 2017年07月13日 15:44, Michal Privoznik wrote:
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 <address@hidden>
---
  hw/net/virtio-net.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5630a9ec44..657d099c54 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,

Applied.

Thanks



reply via email to

[Prev in Thread] Current Thread [Next in Thread]