Re: [PATCH] kvm: use insert sort in kvm_io_bus_register_dev function

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

 



>     initialize directly when defining it?
> 
> 
> ​Since the function might exit before range is initialized, I don't see
> a reason to do it on definion.​

Cleaner and we don't optimize for error paths.

>  
> 
>     > +
>     > +     for (i = 0; i < bus->dev_count; i++)
>     > +             if (kvm_io_bus_cmp(&bus->range[i], &range) > 0)
>     > +                     break;
>     > +
>     > +     memcpy(new_bus, bus, sizeof(*bus) + i * sizeof(struct kvm_io_range));
>     > +     new_bus->dev_count++;
>     > +     new_bus->range[i] = range;
>     > +     memcpy(new_bus->range + i + 1, bus->range + i,
>     > +             (bus->dev_count - i) * sizeof(struct kvm_io_range));
> 
>     These offset/size/length calculations are just ugly. Wonder if that can
>     be written any nicer.
> 
> 
> ​I really don't know how to response to that. It might be ugly but it
> has a lovely personality?​
> 
> This is a standard and common pointer arithmetic, but feel free to
> propose another way to implement it.

Will think about it ... But yes, it has personality :)

-- 

Thanks,

David / dhildenb



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux