On 01/18/2017 12:01 AM, Michael S. Tsirkin wrote: > On Tue, Jan 17, 2017 at 02:50:38PM +0800, Cao jin wrote: >> forget to cc maintainers in this new patch >> >> On 01/17/2017 02:18 PM, Cao jin wrote: >>> Doesn't do it for megasas & hcd-xhci, later patches will fix them. >>> >>> Signed-off-by: Cao jin <caoj.f...@cn.fujitsu.com> > > I don't like this one, frankly. That's a bunch of code duplication.
Yes, code duplication, seems inevitable if move the asserts into a separate patch. > I suspect vfio is the only one who might reasonably get EINVAL here. > So how about e.g. msix_validate_and_init that doesn't assert and use that > from vfio, then switch msix_init to assert instead? > Not sure if I get your idea. Do you mean: do param check via assert in msix_init(), so that no need check its returned error outside, and introduce new api msix_validate_and_init(same content as msix_init, except param check) dedicated to vfio? If I understand you right, the way we do param check for msi_init[*] & msix_init will be inconsistent. [*] patch: msi_init: convert assert to return -errno -- Sincerely, Cao jin