Index: sys/sys/pslist.h =================================================================== RCS file: /cvsroot/src/sys/sys/pslist.h,v retrieving revision 1.7 diff -u -r1.7 pslist.h --- sys/sys/pslist.h 1 Dec 2019 15:28:19 -0000 1.7 +++ sys/sys/pslist.h 21 Mar 2020 22:58:36 -0000 @@ -127,7 +127,7 @@ static __inline void pslist_writer_insert_before(struct pslist_entry *entry, - struct pslist_entry *new) + const size_t sanity_check __diagused, struct pslist_entry *new) { _PSLIST_ASSERT(entry->ple_next != _PSLIST_POISON); @@ -135,6 +135,7 @@ _PSLIST_ASSERT(*entry->ple_prevp == entry); _PSLIST_ASSERT(new->ple_next == NULL); _PSLIST_ASSERT(new->ple_prevp == NULL); + _PSLIST_ASSERT(sanity_check == 0); new->ple_prevp = entry->ple_prevp; new->ple_next = entry; /* not yet published, so no atomic */ @@ -150,7 +151,7 @@ static __inline void pslist_writer_insert_after(struct pslist_entry *entry, - struct pslist_entry *new) + const size_t sanity_check __diagused, struct pslist_entry *new) { _PSLIST_ASSERT(entry->ple_next != _PSLIST_POISON); @@ -158,6 +159,7 @@ _PSLIST_ASSERT(*entry->ple_prevp == entry); _PSLIST_ASSERT(new->ple_next == NULL); _PSLIST_ASSERT(new->ple_prevp == NULL); + _PSLIST_ASSERT(sanity_check == 0); new->ple_prevp = &entry->ple_next; new->ple_next = entry->ple_next; /* not yet published, so no atomic */ @@ -214,20 +216,24 @@ static __inline void * _pslist_writer_first_container(const struct pslist_head *head, - const ptrdiff_t offset) + const ptrdiff_t offset, const size_t sanity_check __diagused) { struct pslist_entry *first = head->plh_first; + _PSLIST_ASSERT(sanity_check == 0); + return (first == NULL ? NULL : (char *)first - offset); } static __inline void * _pslist_writer_next_container(const struct pslist_entry *entry, - const ptrdiff_t offset) + const ptrdiff_t offset, const size_t sanity_check __diagused) { struct pslist_entry *next = entry->ple_next; _PSLIST_ASSERT(next != _PSLIST_POISON); + _PSLIST_ASSERT(sanity_check == 0); + return (next == NULL ? NULL : (char *)next - offset); } @@ -264,10 +270,12 @@ static __inline void * _pslist_reader_first_container(const struct pslist_head *head, - const ptrdiff_t offset) + const ptrdiff_t offset, const size_t sanity_check __diagused) { struct pslist_entry *first = pslist_reader_first(head); + _PSLIST_ASSERT(sanity_check == 0); + if (first == NULL) return NULL; return (char *)first - offset; @@ -275,10 +283,12 @@ static __inline void * _pslist_reader_next_container(const struct pslist_entry *entry, - const ptrdiff_t offset) + const ptrdiff_t offset, const size_t sanity_check __diagused) { struct pslist_entry *next = pslist_reader_next(entry); + _PSLIST_ASSERT(sanity_check == 0); + if (next == NULL) return NULL; return (char *)next - offset; @@ -309,30 +319,30 @@ #define PSLIST_WRITER_INSERT_HEAD(H, V, F) \ pslist_writer_insert_head((H), &(V)->F) #define PSLIST_WRITER_INSERT_BEFORE(E, N, F) \ - pslist_writer_insert_before(&(E)->F + _PSLIST_VALIDATE_PTRS(E, N), \ + pslist_writer_insert_before(&(E)->F, _PSLIST_VALIDATE_PTRS(E, N), \ &(N)->F) #define PSLIST_WRITER_INSERT_AFTER(E, N, F) \ - pslist_writer_insert_after(&(E)->F + _PSLIST_VALIDATE_PTRS(E, N), \ + pslist_writer_insert_after(&(E)->F, _PSLIST_VALIDATE_PTRS(E, N), \ &(N)->F) #define PSLIST_WRITER_REMOVE(E, F) \ pslist_writer_remove(&(E)->F) #define PSLIST_WRITER_FIRST(H, T, F) \ - ((T *)(_pslist_writer_first_container((H), offsetof(T, F))) + \ - _PSLIST_VALIDATE_CONTAINER(pslist_writer_first(H), T, F)) + ((T *)(_pslist_writer_first_container((H), offsetof(T, F), \ + _PSLIST_VALIDATE_CONTAINER(pslist_writer_first(H), T, F)))) #define PSLIST_WRITER_NEXT(V, T, F) \ - ((T *)(_pslist_writer_next_container(&(V)->F, offsetof(T, F))) + \ - _PSLIST_VALIDATE_CONTAINER(pslist_writer_next(&(V)->F), T, F)) + ((T *)(_pslist_writer_next_container(&(V)->F, offsetof(T, F), \ + _PSLIST_VALIDATE_CONTAINER(pslist_writer_next(&(V)->F), T, F)))) #define PSLIST_WRITER_FOREACH(V, H, T, F) \ for ((V) = PSLIST_WRITER_FIRST((H), T, F); \ (V) != NULL; \ (V) = PSLIST_WRITER_NEXT((V), T, F)) #define PSLIST_READER_FIRST(H, T, F) \ - ((T *)(_pslist_reader_first_container((H), offsetof(T, F))) + \ - _PSLIST_VALIDATE_CONTAINER(pslist_reader_first(H), T, F)) + ((T *)(_pslist_reader_first_container((H), offsetof(T, F), \ + _PSLIST_VALIDATE_CONTAINER(pslist_reader_first(H), T, F)))) #define PSLIST_READER_NEXT(V, T, F) \ - ((T *)(_pslist_reader_next_container(&(V)->F, offsetof(T, F))) + \ - _PSLIST_VALIDATE_CONTAINER(pslist_reader_next(&(V)->F), T, F)) + ((T *)(_pslist_reader_next_container(&(V)->F, offsetof(T, F), \ + _PSLIST_VALIDATE_CONTAINER(pslist_reader_next(&(V)->F), T, F)))) #define PSLIST_READER_FOREACH(V, H, T, F) \ for ((V) = PSLIST_READER_FIRST((H), T, F); \ (V) != NULL; \