aboutsummaryrefslogtreecommitdiff
path: root/kvm-all.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2015-03-23 15:29:27 +0000
committerKevin Wolf <kwolf@redhat.com>2015-04-28 15:36:08 +0200
commitbd2a88840e2496e29442f333c8fdd6491e831a35 (patch)
tree95ced0dfbbd8ac39d8e73b55a414398dccb106ad /kvm-all.c
parent786a4ea82ec9c87e3a895cf41081029b285a5fe5 (diff)
downloadqemu-bd2a88840e2496e29442f333c8fdd6491e831a35.zip
qemu-bd2a88840e2496e29442f333c8fdd6491e831a35.tar.gz
qemu-bd2a88840e2496e29442f333c8fdd6491e831a35.tar.bz2
Convert ffs() != 0 callers to ctz32()
There are a number of ffs(3) callers that do roughly: bit = ffs(val); if (bit) { do_something(bit - 1); } This pattern can be converted to ctz32() like this: zeroes = ctz32(val); if (zeroes != 32) { do_something(zeroes); } Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1427124571-28598-6-git-send-email-stefanha@redhat.com Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'kvm-all.c')
-rw-r--r--kvm-all.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/kvm-all.c b/kvm-all.c
index 4ec153d..2a717e5 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1141,18 +1141,18 @@ static int kvm_irqchip_get_virq(KVMState *s)
{
uint32_t *word = s->used_gsi_bitmap;
int max_words = ALIGN(s->gsi_count, 32) / 32;
- int i, bit;
+ int i, zeroes;
bool retry = true;
again:
/* Return the lowest unused GSI in the bitmap */
for (i = 0; i < max_words; i++) {
- bit = ffs(~word[i]);
- if (!bit) {
+ zeroes = ctz32(~word[i]);
+ if (zeroes == 32) {
continue;
}
- return bit - 1 + i * 32;
+ return zeroes + i * 32;
}
if (!s->direct_msi && retry) {
retry = false;