diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2015-03-23 15:29:27 +0000 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2015-04-28 15:36:08 +0200 |
commit | bd2a88840e2496e29442f333c8fdd6491e831a35 (patch) | |
tree | 95ced0dfbbd8ac39d8e73b55a414398dccb106ad /kvm-all.c | |
parent | 786a4ea82ec9c87e3a895cf41081029b285a5fe5 (diff) | |
download | qemu-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.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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; |