[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [RFC XEN PATCH v3 07/39] xen/pmem: register valid PMEM regions to Xen hypervisor
> + > +/** > + * Add a PMEM region to a list. All PMEM regions in the list are > + * sorted in the ascending order of the start address. A PMEM region, > + * whose range is overlapped with anyone in the list, cannot be added > + * to the list. > + * > + * Parameters: > + * list: the list to which a new PMEM region will be added > + * smfn, emfn: the range of the new PMEM region > + * entry: return the new entry added to the list > + * > + * Return: > + * On success, return 0 and the new entry added to the list is > + * returned via @entry. Otherwise, return an error number and the > + * value of @entry is undefined. > + */ > +static int pmem_list_add(struct list_head *list, > + unsigned long smfn, unsigned long emfn, > + struct pmem **entry) > +{ > + struct list_head *cur; > + struct pmem *new_pmem; > + int rc = 0; > + > + list_for_each_prev(cur, list) > + { > + struct pmem *cur_pmem = list_entry(cur, struct pmem, link); > + unsigned long cur_smfn = cur_pmem->smfn; > + unsigned long cur_emfn = cur_pmem->emfn; > + > + if ( check_overlap(smfn, emfn, cur_smfn, cur_emfn) ) > + { > + rc = -EEXIST; > + goto out; > + } > + > + if ( cur_smfn < smfn ) > + break; > + } > + > + new_pmem = xzalloc(struct pmem); > + if ( !new_pmem ) > + { > + rc = -ENOMEM; > + goto out; > + } > + new_pmem->smfn = smfn; > + new_pmem->emfn = emfn; > + list_add(&new_pmem->link, cur); > + > + out: > + if ( !rc && entry ) > + *entry = new_pmem; > + > + return rc; It's not necessary to introduce 'out' and 'rc'. You can return directly for failure case. Chao _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |