- if (iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED ||
- iterator->state == BT_SELF_COMPONENT_PORT_INPUT_NOTIFICATION_ITERATOR_STATE_FINALIZED_AND_ENDED) {
- /*
- * The user's "next" method, somehow, cancelled its own
- * notification iterator. This can happen, for example,
- * when the user's method removes the port on which
- * there's the connection from which the iterator was
- * created. In this case, said connection is ended, and
- * all its notification iterators are finalized.
- *
- * Only bt_object_put_ref() the returned notification if
- * the status is BT_NOTIFICATION_ITERATOR_STATUS_OK
- * because otherwise this field could be garbage.
- */
- if (status == BT_NOTIFICATION_ITERATOR_STATUS_OK) {
- uint64_t i;
- bt_notification_array notifs =
- (void *) iterator->base.notifs->pdata;
-
- for (i = 0; i < *user_count; i++) {
- bt_object_put_ref(notifs[i]);
- }
- }
-
- status = BT_NOTIFICATION_ITERATOR_STATUS_CANCELED;
- goto end;
- }
+#ifdef BT_DEV_MODE
+ /*
+ * There is no way that this iterator could have been finalized
+ * during its "next" method, as the only way to do this is to
+ * put the last iterator's reference, and this can only be done
+ * by its downstream owner.
+ */
+ BT_ASSERT(iterator->state ==
+ BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_ACTIVE);
+#endif