lkml.org 
[lkml]   [2009]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [KVM PATCH v7 1/2] KVM: make io_bus interface more robust
Avi Kivity wrote:
> On 06/16/2009 04:42 PM, Gregory Haskins wrote:
>> +
>> +/* assumes kvm->lock held */
>> +void kvm_io_bus_unregister_dev(struct kvm_io_bus *bus,
>> + struct kvm_io_device *dev)
>> +{
>> + int i;
>> +
>> + for (i = 0; i< bus->dev_count; i++) {
>> +
>> + if (bus->devs[i] == dev) {
>> + int j;
>> +
>> + /* backfill the hole */
>> + for (j = i; j< bus->dev_count-1; j++)
>> + bus->devs[j] = bus->devs[j+1];
>> +
>> + bus->dev_count--;
>> +
>> + break;
>>
>
> Could be simplified to
>
> if (bus->devs[i] == dev) {
> bus->devs[i] = bus->devs[--bus->dev_count];
> return;
> }
>
Clever!

Will do.

-Greg

[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2009-06-18 13:49    [W:0.049 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site