mirror of https://gitee.com/openkylin/qemu.git
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>
This commit is contained in:
parent
2484ff0624
commit
5f997fd17b
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue