Index: uspace/lib/c/include/adt/list.h
===================================================================
--- uspace/lib/c/include/adt/list.h	(revision e0f52bf734d3ec774636ecbab7cd664786001b5c)
+++ uspace/lib/c/include/adt/list.h	(revision 9c75782060ff62e5868fdca2b26e311fe5e9be29)
@@ -49,8 +49,16 @@
  *
  */
-#define LIST_INITIALIZE(name)  link_t name = { \
-	.prev = &name, \
-	.next = &name \
-}
+#define LIST_INITIALIZE(name) \
+	link_t name = { \
+		.prev = &name, \
+		.next = &name \
+	}
+
+#define list_get_instance(link, type, member) \
+	((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
+
+#define list_foreach(list, iterator) \
+	for (link_t *iterator = (list).next; \
+	    iterator != &(list); iterator = iterator->next)
 
 /** Initialize doubly-linked circular list link
@@ -71,11 +79,11 @@
  * Initialize doubly-linked circular list.
  *
- * @param head Pointer to link_t structure representing head of the list.
- *
- */
-static inline void list_initialize(link_t *head)
-{
-	head->prev = head;
-	head->next = head;
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+static inline void list_initialize(link_t *list)
+{
+	list->prev = list;
+	list->next = list;
 }
 
@@ -85,13 +93,13 @@
  *
  * @param link Pointer to link_t structure to be added.
- * @param head Pointer to link_t structure representing head of the list.
- *
- */
-static inline void list_prepend(link_t *link, link_t *head)
-{
-	link->next = head->next;
-	link->prev = head;
-	head->next->prev = link;
-	head->next = link;
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+static inline void list_prepend(link_t *link, link_t *list)
+{
+	link->next = list->next;
+	link->prev = list;
+	list->next->prev = link;
+	list->next = link;
 }
 
@@ -101,25 +109,29 @@
  *
  * @param link Pointer to link_t structure to be added.
- * @param head Pointer to link_t structure representing head of the list.
- *
- */
-static inline void list_append(link_t *link, link_t *head)
-{
-	link->prev = head->prev;
-	link->next = head;
-	head->prev->next = link;
-	head->prev = link;
-}
-
-/** Insert item before another item in doubly-linked circular list. */
-static inline void list_insert_before(link_t *l, link_t *r)
-{
-	list_append(l, r);
-}
-
-/** Insert item after another item in doubly-linked circular list. */
-static inline void list_insert_after(link_t *r, link_t *l)
-{
-	list_prepend(l, r);
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+static inline void list_append(link_t *link, link_t *list)
+{
+	link->prev = list->prev;
+	link->next = list;
+	list->prev->next = link;
+	list->prev = link;
+}
+
+/** Insert item before another item in doubly-linked circular list.
+ *
+ */
+static inline void list_insert_before(link_t *link, link_t *list)
+{
+	list_append(link, list);
+}
+
+/** Insert item after another item in doubly-linked circular list.
+ *
+ */
+static inline void list_insert_after(link_t *link, link_t *list)
+{
+	list_prepend(list, link);
 }
 
@@ -143,10 +155,23 @@
  * Query emptiness of doubly-linked circular list.
  *
- * @param head Pointer to link_t structure representing head of the list.
- *
- */
-static inline int list_empty(link_t *head)
-{
-	return ((head->next == head) ? 1 : 0);
+ * @param list Pointer to link_t structure representing the list.
+ *
+ */
+static inline int list_empty(link_t *list)
+{
+	return (list->next == list);
+}
+
+/** Get head item of a list.
+ *
+ * @param list Pointer to link_t structure representing the list.
+ *
+ * @return Head item of the list.
+ * @return NULL if the list is empty.
+ *
+ */
+static inline link_t *list_head(link_t *list)
+{
+	return ((list->next == list) ? NULL : list->next);
 }
 
@@ -205,10 +230,26 @@
 }
 
-#define list_get_instance(link, type, member) \
-	((type *) (((void *)(link)) - ((void *) &(((type *) NULL)->member))))
-
-#define list_foreach(list, iterator) \
-	for (link_t *iterator = (list).next; \
-	    iterator != &(list); iterator = iterator->next)
+/** Get n-th item of a list.
+ *
+ * @param list Pointer to link_t structure representing the list.
+ * @param n    Item number (indexed from zero).
+ *
+ * @return n-th item of the list.
+ * @return NULL if no n-th item found.
+ *
+ */
+static inline link_t *list_nth(link_t *list, unsigned int n)
+{
+	unsigned int cnt = 0;
+	
+	list_foreach(*list, link) {
+		if (cnt == n)
+			return link;
+		
+		cnt++;
+	}
+	
+	return NULL;
+}
 
 extern int list_member(const link_t *, const link_t *);
