Index: uspace/drv/bus/usb/ehci/endpoint_list.c
===================================================================
--- uspace/drv/bus/usb/ehci/endpoint_list.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/drv/bus/usb/ehci/endpoint_list.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -160,11 +160,13 @@
 	const char *qpos = NULL;
 	qh_t *prev_qh;
+	link_t *prev = list_prev(&ep->eplist_link, &instance->endpoint_list);
+
 	/* Remove from the hardware queue */
-	if (list_first(&instance->endpoint_list) == &ep->eplist_link) {
+	if (!prev) {
 		/* I'm the first one here */
 		prev_qh = instance->list_head;
 		qpos = "FIRST";
 	} else {
-		prev_qh = ehci_endpoint_list_instance(ep->eplist_link.prev)->qh;
+		prev_qh = ehci_endpoint_list_instance(prev)->qh;
 		qpos = "NOT FIRST";
 	}
Index: uspace/drv/bus/usb/ohci/endpoint_list.c
===================================================================
--- uspace/drv/bus/usb/ohci/endpoint_list.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/drv/bus/usb/ohci/endpoint_list.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -156,6 +156,7 @@
 	const char *qpos = NULL;
 	ed_t *prev_ed;
+	link_t *prev_link = list_prev(&ep->eplist_link, &instance->endpoint_list);
 	/* Remove from the hardware queue */
-	if (list_first(&instance->endpoint_list) == &ep->eplist_link) {
+	if (!prev_link) {
 		/* I'm the first one here */
 		prev_ed = instance->list_head;
@@ -163,5 +164,5 @@
 	} else {
 		ohci_endpoint_t *prev =
-		    list_get_instance(ep->eplist_link.prev, ohci_endpoint_t, eplist_link);
+		    list_get_instance(prev_link, ohci_endpoint_t, eplist_link);
 		prev_ed = prev->ed;
 		qpos = "NOT FIRST";
Index: uspace/drv/bus/usb/uhci/transfer_list.c
===================================================================
--- uspace/drv/bus/usb/uhci/transfer_list.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/drv/bus/usb/uhci/transfer_list.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -233,9 +233,9 @@
 	const char *qpos = "FIRST";
 	qh_t *prev_qh = instance->queue_head;
+	link_t *prev = list_prev(&uhci_batch->link, &instance->batch_list);
 	/* Remove from the hardware queue */
-	if (list_first(&instance->batch_list) != &uhci_batch->link) {
+	if (prev) {
 		/* There is a batch in front of me */
-		prev_qh =
-		    uhci_transfer_batch_from_link(uhci_batch->link.prev)->qh;
+		prev_qh = uhci_transfer_batch_from_link(prev)->qh;
 		qpos = "NOT FIRST";
 	}
Index: uspace/lib/c/generic/adt/hash_table.c
===================================================================
--- uspace/lib/c/generic/adt/hash_table.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/c/generic/adt/hash_table.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -273,12 +273,12 @@
 
 	size_t idx = h->op->hash(item) % h->bucket_cnt;
+	list_t *list = &h->bucket[idx];
 
 	/* Traverse the circular list until we reach the starting item again. */
-	for (link_t *cur = item->link.next; cur != &first->link;
-	    cur = cur->next) {
-		assert(cur);
-
-		if (cur == &h->bucket[idx].head)
-			continue;
+	for (link_t *cur = list_next(&item->link, list); cur != &first->link;
+	    cur = list_next(cur, list)) {
+
+		if (!cur)
+			cur = list_first(list);
 
 		ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
Index: uspace/lib/c/generic/thread/fibril.c
===================================================================
--- uspace/lib/c/generic/thread/fibril.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/c/generic/thread/fibril.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -601,15 +601,12 @@
 	assert(timeout);
 
-	link_t *tmp = timeout_list.head.next;
-	while (tmp != &timeout_list.head) {
-		_timeout_t *cur = list_get_instance(tmp, _timeout_t, link);
-
-		if (ts_gteq(&cur->expires, &timeout->expires))
-			break;
-
-		tmp = tmp->next;
-	}
-
-	list_insert_before(&timeout->link, tmp);
+	list_foreach(timeout_list, link, _timeout_t, cur) {
+		if (ts_gteq(&cur->expires, &timeout->expires)) {
+			list_insert_before(&timeout->link, &cur->link);
+			return;
+		}
+	}
+
+	list_append(&timeout->link, &timeout_list);
 }
 
Index: uspace/lib/c/include/ipc/devman.h
===================================================================
--- uspace/lib/c/include/ipc/devman.h	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/c/include/ipc/devman.h	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -108,16 +108,12 @@
 static inline void add_match_id(match_id_list_t *ids, match_id_t *id)
 {
-	match_id_t *mid = NULL;
-	link_t *link = ids->ids.head.next;
-
-	while (link != &ids->ids.head) {
-		mid = list_get_instance(link, match_id_t, link);
+	list_foreach(ids->ids, link, match_id_t, mid) {
 		if (mid->score < id->score) {
-			break;
+			list_insert_before(&id->link, &mid->link);
+			return;
 		}
-		link = link->next;
 	}
 
-	list_insert_before(&id->link, link);
+	list_append(&id->link, &ids->ids);
 }
 
Index: uspace/lib/nic/include/nic.h
===================================================================
--- uspace/lib/nic/include/nic.h	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/nic/include/nic.h	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -71,5 +71,8 @@
 } nic_frame_t;
 
-typedef list_t nic_frame_list_t;
+typedef union {
+	list_t list;
+	link_t link;
+} nic_frame_list_t;
 
 /**
Index: uspace/lib/nic/src/nic_driver.c
===================================================================
--- uspace/lib/nic/src/nic_driver.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/nic/src/nic_driver.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -329,9 +329,8 @@
 
 	if (nic_globals.frame_list_cache_size > 0) {
-		frames =
-		    list_get_instance(list_first(&nic_globals.frame_list_cache),
-		    nic_frame_list_t, head);
-		list_remove(&frames->head);
-		list_initialize(frames);
+		frames = list_pop(&nic_globals.frame_list_cache,
+		    nic_frame_list_t, link);
+		assert(frames);
+		list_initialize(&frames->list);
 		nic_globals.frame_list_cache_size--;
 		fibril_mutex_unlock(&nic_globals.lock);
@@ -341,5 +340,5 @@
 		frames = malloc(sizeof (nic_frame_list_t));
 		if (frames != NULL)
-			list_initialize(frames);
+			list_initialize(&frames->list);
 	}
 
@@ -356,5 +355,5 @@
 		free(frames);
 	} else {
-		list_prepend(&frames->head, &nic_globals.frame_list_cache);
+		list_prepend(&frames->link, &nic_globals.frame_list_cache);
 		nic_globals.frame_list_cache_size++;
 		fibril_mutex_unlock(&nic_globals.lock);
@@ -372,5 +371,5 @@
 {
 	assert(frame != NULL && frames != NULL);
-	list_append(&frame->link, frames);
+	list_append(&frame->link, &frames->list);
 }
 
@@ -576,9 +575,6 @@
 	if (frames == NULL)
 		return;
-	while (!list_empty(frames)) {
-		nic_frame_t *frame =
-		    list_get_instance(list_first(frames), nic_frame_t, link);
-
-		list_remove(&frame->link);
+	while (!list_empty(&frames->list)) {
+		nic_frame_t *frame = list_pop(&frames->list, nic_frame_t, link);
 		nic_received_frame(nic_data, frame);
 	}
Index: uspace/lib/posix/src/signal.c
===================================================================
--- uspace/lib/posix/src/signal.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/posix/src/signal.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -383,21 +383,14 @@
 static void _dequeue_unblocked_signals(void)
 {
-	link_t *iterator = _signal_queue.head.next;
-	link_t *next;
-
-	while (iterator != &(_signal_queue).head) {
-		next = iterator->next;
-
+	list_foreach_safe(_signal_queue, cur_link, next_link) {
 		signal_queue_item *item =
-		    list_get_instance(iterator, signal_queue_item, link);
+		    list_get_instance(cur_link, signal_queue_item, link);
 
 		if (!sigismember(&_signal_mask, item->signo) &&
 		    _signal_actions[item->signo].sa_handler != SIG_HOLD) {
-			list_remove(&(item->link));
-			_raise_sigaction(item->signo, &(item->siginfo));
+			list_remove(cur_link);
+			_raise_sigaction(item->signo, &item->siginfo);
 			free(item);
 		}
-
-		iterator = next;
 	}
 }
Index: uspace/lib/usbhid/src/hiddescriptor.c
===================================================================
--- uspace/lib/usbhid/src/hiddescriptor.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/usbhid/src/hiddescriptor.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -89,34 +89,21 @@
     usb_hid_report_path_t *cmp_path)
 {
-	link_t *path_it = report->collection_paths.head.next;
-	usb_hid_report_path_t *path = NULL;
-
-	if ((report == NULL) || (cmp_path == NULL)) {
+	if (report == NULL || cmp_path == NULL)
 		return NULL;
-	}
-
-	while (path_it != &report->collection_paths.head) {
-		path = list_get_instance(path_it, usb_hid_report_path_t,
-		    cpath_link);
-
+
+	list_foreach(report->collection_paths, cpath_link, usb_hid_report_path_t, path) {
 		if (usb_hid_report_compare_usage_path(path, cmp_path,
-		    USB_HID_PATH_COMPARE_STRICT) == 0) {
-			break;
-		}
-		path_it = path_it->next;
-	}
-	if (path_it == &report->collection_paths.head) {
-		path = usb_hid_report_path_clone(cmp_path);
-		if (path == NULL) {
-			return NULL;
-		}
-		list_append(&path->cpath_link, &report->collection_paths);
-		report->collection_paths_count++;
-
-		return path;
-	} else {
-		return list_get_instance(path_it, usb_hid_report_path_t,
-		    cpath_link);
-	}
+		    USB_HID_PATH_COMPARE_STRICT) == 0)
+			return path;
+	}
+
+	usb_hid_report_path_t *path = usb_hid_report_path_clone(cmp_path);
+	if (path == NULL)
+		return NULL;
+
+	list_append(&path->cpath_link, &report->collection_paths);
+	report->collection_paths_count++;
+
+	return path;
 }
 
@@ -474,7 +461,11 @@
 				    usb_hid_report_item_t, link);
 
+				link_t *tmp_link = list_prev(
+				    &report_item->usage_path->cpath_link,
+				    &report->collection_paths);
+				assert(tmp_link);
+
 				usb_hid_report_usage_path_t *tmp_usage_path;
-				tmp_usage_path = list_get_instance(
-				    report_item->usage_path->cpath_link.prev,
+				tmp_usage_path = list_get_instance(tmp_link,
 				    usb_hid_report_usage_path_t, rpath_items_link);
 
@@ -486,5 +477,5 @@
 
 				usb_hid_report_path_free(report_item->usage_path);
-				list_remove (item_link);
+				list_remove(item_link);
 
 				break;
Index: uspace/lib/usbhid/src/hidparser.c
===================================================================
--- uspace/lib/usbhid/src/hidparser.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/usbhid/src/hidparser.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -493,10 +493,10 @@
 
 	if (field == NULL) {
-		field_it = report_des->report_items.head.next;
-	} else {
-		field_it = field->ritems_link.next;
-	}
-
-	while (field_it != &report_des->report_items.head) {
+		field_it = list_first(&report_des->report_items);
+	} else {
+		field_it = list_next(&field->ritems_link, &report_des->report_items);
+	}
+
+	while (field_it != NULL) {
 		field = list_get_instance(field_it, usb_hid_report_field_t,
 		    ritems_link);
@@ -514,5 +514,5 @@
 			usb_hid_report_remove_last_item(field->collection_path);
 		}
-		field_it = field_it->next;
+		field_it = list_next(field_it, &report_des->report_items);
 	}
 
@@ -547,11 +547,12 @@
 			return 0;
 		} else {
-			report_it = report_des->reports_link.next;
+			report_it = list_next(&report_des->reports_link,
+			    &report->reports);
 		}
 	} else {
-		report_it = report->reports.head.next;
-	}
-
-	while (report_it != &report->reports.head) {
+		report_it = list_first(&report->reports);
+	}
+
+	while (report_it != NULL) {
 		report_des = list_get_instance(report_it,
 		    usb_hid_report_description_t, reports_link);
@@ -561,5 +562,5 @@
 		}
 
-		report_it = report_it->next;
+		report_it = list_next(report_it, &report->reports);
 	}
 
Index: uspace/lib/usbhid/src/hidpath.c
===================================================================
--- uspace/lib/usbhid/src/hidpath.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/lib/usbhid/src/hidpath.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -250,9 +250,8 @@
 		 * Path is prefix of the report_path
 		 */
-		report_link = report_path->items.head.next;
-		path_link = path->items.head.next;
-
-		while ((report_link != &report_path->items.head) &&
-		    (path_link != &path->items.head)) {
+		report_link = list_first(&report_path->items);
+		path_link = list_first(&path->items);
+
+		while (report_link != NULL && path_link != NULL) {
 
 			report_item = list_get_instance(report_link,
@@ -268,13 +267,12 @@
 				return 1;
 			} else {
-				report_link = report_link->next;
-				path_link = path_link->next;
+				report_link = list_next(report_link, &report_path->items);
+				path_link = list_next(path_link, &path->items);
 			}
 		}
 
 		if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
-		    (path_link == &path->items.head)) ||
-		    ((report_link == &report_path->items.head) &&
-		    (path_link == &path->items.head))) {
+		    (path_link == NULL)) ||
+		    (report_link == NULL && path_link == NULL)) {
 			return 0;
 		} else {
@@ -287,6 +285,6 @@
 		 * Path is suffix of report_path
 		 */
-		report_link = report_path->items.head.prev;
-		path_link = path->items.head.prev;
+		report_link = list_last(&report_path->items);
+		path_link = list_last(&path->items);
 
 		if (list_empty(&path->items)) {
@@ -294,6 +292,5 @@
 		}
 
-		while ((report_link != &report_path->items.head) &&
-		    (path_link != &path->items.head)) {
+		while (report_link != NULL && path_link != NULL) {
 			report_item = list_get_instance(report_link,
 			    usb_hid_report_usage_path_t, rpath_items_link);
@@ -308,10 +305,10 @@
 				return 1;
 			} else {
-				report_link = report_link->prev;
-				path_link = path_link->prev;
+				report_link = list_prev(report_link, &report_path->items);
+				path_link = list_prev(path_link, &path->items);
 			}
 		}
 
-		if (path_link == &path->items.head) {
+		if (path_link == NULL) {
 			return 0;
 		} else {
Index: uspace/srv/devman/driver.c
===================================================================
--- uspace/srv/devman/driver.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/srv/devman/driver.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -435,6 +435,6 @@
 	 * that has not been passed to the driver.
 	 */
-	link = driver->devices.head.next;
-	while (link != &driver->devices.head) {
+	link = list_first(&driver->devices);
+	while (link != NULL) {
 		dev = list_get_instance(link, dev_node_t, driver_devices);
 		fibril_rwlock_write_lock(&tree->rwlock);
@@ -442,5 +442,5 @@
 		if (dev->passed_to_driver) {
 			fibril_rwlock_write_unlock(&tree->rwlock);
-			link = link->next;
+			link = list_next(link, &driver->devices);
 			continue;
 		}
@@ -484,5 +484,5 @@
 		 * Restart the cycle to go through all devices again.
 		 */
-		link = driver->devices.head.next;
+		link = list_first(&driver->devices);
 	}
 
Index: uspace/srv/devman/match.c
===================================================================
--- uspace/srv/devman/match.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/srv/devman/match.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -67,11 +67,9 @@
 int get_match_score(driver_t *drv, dev_node_t *dev)
 {
-	link_t *drv_head = &drv->match_ids.ids.head;
-	link_t *dev_head = &dev->pfun->match_ids.ids.head;
-
-	if (list_empty(&drv->match_ids.ids) ||
-	    list_empty(&dev->pfun->match_ids.ids)) {
+	list_t *drv_list = &drv->match_ids.ids;
+	list_t *dev_list = &dev->pfun->match_ids.ids;
+
+	if (list_empty(drv_list) || list_empty(dev_list))
 		return 0;
-	}
 
 	/*
@@ -80,20 +78,10 @@
 	int highest_score = 0;
 
-	link_t *drv_link = drv->match_ids.ids.head.next;
-	while (drv_link != drv_head) {
-		link_t *dev_link = dev_head->next;
-		while (dev_link != dev_head) {
-			match_id_t *drv_id = list_get_instance(drv_link, match_id_t, link);
-			match_id_t *dev_id = list_get_instance(dev_link, match_id_t, link);
-
+	list_foreach(*drv_list, link, match_id_t, drv_id) {
+		list_foreach(*dev_list, link, match_id_t, dev_id) {
 			int score = compute_match_score(drv_id, dev_id);
-			if (score > highest_score) {
+			if (score > highest_score)
 				highest_score = score;
-			}
-
-			dev_link = dev_link->next;
 		}
-
-		drv_link = drv_link->next;
 	}
 
Index: uspace/srv/fs/exfat/exfat_idx.c
===================================================================
--- uspace/srv/fs/exfat/exfat_idx.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/srv/fs/exfat/exfat_idx.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -284,12 +284,12 @@
 		link_t *lnk;
 		freed_t *n;
-		for (lnk = u->freed_list.head.next; lnk != &u->freed_list.head;
-		    lnk = lnk->next) {
+		for (lnk = list_first(&u->freed_list); lnk != NULL;
+		    lnk = list_next(lnk, &u->freed_list)) {
 			freed_t *f = list_get_instance(lnk, freed_t, link);
 			if (f->first == index + 1) {
 				f->first--;
-				if (lnk->prev != &u->freed_list.head)
-					try_coalesce_intervals(lnk->prev, lnk,
-					    lnk);
+				link_t *prev = list_prev(lnk, &u->freed_list);
+				if (prev)
+					try_coalesce_intervals(prev, lnk, lnk);
 				fibril_mutex_unlock(&unused_lock);
 				return;
@@ -297,7 +297,7 @@
 			if (f->last == index - 1) {
 				f->last++;
-				if (lnk->next != &u->freed_list.head)
-					try_coalesce_intervals(lnk, lnk->next,
-					    lnk);
+				link_t *next = list_next(lnk, &u->freed_list);
+				if (next)
+					try_coalesce_intervals(lnk, next, lnk);
 				fibril_mutex_unlock(&unused_lock);
 				return;
Index: uspace/srv/fs/fat/fat_idx.c
===================================================================
--- uspace/srv/fs/fat/fat_idx.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/srv/fs/fat/fat_idx.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -284,12 +284,12 @@
 		link_t *lnk;
 		freed_t *n;
-		for (lnk = u->freed_list.head.next; lnk != &u->freed_list.head;
-		    lnk = lnk->next) {
+		for (lnk = list_first(&u->freed_list); lnk != NULL;
+		    lnk = list_next(lnk, &u->freed_list)) {
 			freed_t *f = list_get_instance(lnk, freed_t, link);
 			if (f->first == index + 1) {
 				f->first--;
-				if (lnk->prev != &u->freed_list.head)
-					try_coalesce_intervals(lnk->prev, lnk,
-					    lnk);
+				link_t *prev = list_prev(lnk, &u->freed_list);
+				if (prev)
+					try_coalesce_intervals(prev, lnk, lnk);
 				fibril_mutex_unlock(&unused_lock);
 				return;
@@ -297,7 +297,7 @@
 			if (f->last == index - 1) {
 				f->last++;
-				if (lnk->next != &u->freed_list.head)
-					try_coalesce_intervals(lnk, lnk->next,
-					    lnk);
+				link_t *next = list_next(lnk, &u->freed_list);
+				if (next)
+					try_coalesce_intervals(lnk, next, lnk);
 				fibril_mutex_unlock(&unused_lock);
 				return;
Index: uspace/srv/hid/compositor/compositor.c
===================================================================
--- uspace/srv/hid/compositor/compositor.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/srv/hid/compositor/compositor.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -427,15 +427,12 @@
 
 			/* For each window. */
-			for (link_t *link = window_list.head.prev;
-			    link != &window_list.head; link = link->prev) {
-
+			list_foreach_rev(window_list, link, window_t, win) {
 				/*
 				 * Determine what part of the window intersects with the
 				 * updated area of the current viewport.
 				 */
-				window_t *win = list_get_instance(link, window_t, link);
-				if (!win->surface) {
+				if (!win->surface)
 					continue;
-				}
+
 				sysarg_t x_dmg_win, y_dmg_win, w_dmg_win, h_dmg_win;
 				surface_get_resolution(win->surface, &w_dmg_win, &h_dmg_win);
Index: uspace/srv/net/tcp/ncsim.c
===================================================================
--- uspace/srv/net/tcp/ncsim.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/srv/net/tcp/ncsim.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -108,7 +108,5 @@
 		sqe->delay -= old_qe->delay;
 
-		link = link->next;
-		if (link == &sim_queue.head)
-			link = NULL;
+		link = list_next(link, &sim_queue);
 	}
 
Index: uspace/srv/net/tcp/tqueue.c
===================================================================
--- uspace/srv/net/tcp/tqueue.c	(revision 1a374967997b33e560720544b0b126a5f689f6b3)
+++ uspace/srv/net/tcp/tqueue.c	(revision f959a20f7a3197accd28bd8cb040895fed7fae3c)
@@ -245,14 +245,8 @@
 void tcp_tqueue_ack_received(tcp_conn_t *conn)
 {
-	link_t *cur, *next;
-
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: tcp_tqueue_ack_received(%p)", conn->name,
 	    conn);
 
-	cur = conn->retransmit.list.head.next;
-
-	while (cur != &conn->retransmit.list.head) {
-		next = cur->next;
-
+	list_foreach_safe(conn->retransmit.list, cur, next) {
 		tcp_tqueue_entry_t *tqe = list_get_instance(cur,
 		    tcp_tqueue_entry_t, link);
@@ -277,6 +271,4 @@
 			tcp_tqueue_timer_set(conn);
 		}
-
-		cur = next;
 	}
 
