Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/xen/grant_table/grant_table.c
Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | gnttab_query_foreign_access(grant_ref_t ref) | ||||
return (nflags & (GTF_reading|GTF_writing)); | return (nflags & (GTF_reading|GTF_writing)); | ||||
} | } | ||||
int | int | ||||
gnttab_end_foreign_access_ref(grant_ref_t ref) | gnttab_end_foreign_access_ref(grant_ref_t ref) | ||||
{ | { | ||||
uint16_t flags, nflags; | uint16_t flags, nflags; | ||||
KASSERT(ref != GRANT_REF_INVALID, ("Trying to free an invalid grant ref")); | |||||
royger: I would turn this into a KASSERT(ref != GRANT_REF_INVALID, ("trying to free an invalid grant… | |||||
nflags = shared[ref].flags; | nflags = shared[ref].flags; | ||||
do { | do { | ||||
if ( (flags = nflags) & (GTF_reading|GTF_writing) ) { | if ( (flags = nflags) & (GTF_reading|GTF_writing) ) { | ||||
printf("%s: WARNING: g.e. still in use!\n", __func__); | printf("%s: WARNING: g.e. still in use!\n", __func__); | ||||
return (0); | return (0); | ||||
} | } | ||||
} while ((nflags = synch_cmpxchg(&shared[ref].flags, flags, 0)) != | } while ((nflags = synch_cmpxchg(&shared[ref].flags, flags, 0)) != | ||||
flags); | flags); | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
gnttab_alloc_grant_references(uint16_t count, grant_ref_t *head) | gnttab_alloc_grant_references(uint16_t count, grant_ref_t *head) | ||||
{ | { | ||||
int ref, error; | int ref, error; | ||||
error = get_free_entries(count, &ref); | error = get_free_entries(count, &ref); | ||||
if (__predict_false(error)) | if (__predict_false(error)) | ||||
return (error); | return (error); | ||||
Done Inline ActionsI don't think you need to do this. If the function returns an error the caller shouldn't poke at head and expect it to be a valid list. I think the callers should be fixed instead of adding this workaround here. royger: I don't think you need to do this. If the function returns an error the caller shouldn't poke… | |||||
*head = ref; | *head = ref; | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
gnttab_empty_grant_references(const grant_ref_t *private_head) | gnttab_empty_grant_references(const grant_ref_t *private_head) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 340 Lines • Show Last 20 Lines |
I would turn this into a KASSERT(ref != GRANT_REF_INVALID, ("trying to free an invalid grant ref"));
I don't think calling gnttab_end_foreign_access_ref with an explicit invalid grant reference is a valid use-case.