Audit for list_for_each_*entry* --- diff/drivers/md/dm-ioctl.c 2004-02-09 10:43:16.000000000 +0000 +++ source/drivers/md/dm-ioctl.c 2004-02-09 15:33:40.000000000 +0000 @@ -96,30 +96,24 @@ *---------------------------------------------------------------*/ static struct hash_cell *__get_name_cell(const char *str) { - struct list_head *tmp; struct hash_cell *hc; unsigned int h = hash_str(str); - list_for_each (tmp, _name_buckets + h) { - hc = list_entry(tmp, struct hash_cell, name_list); + list_for_each_entry (hc, _name_buckets + h, name_list) if (!strcmp(hc->name, str)) return hc; - } return NULL; } static struct hash_cell *__get_uuid_cell(const char *str) { - struct list_head *tmp; struct hash_cell *hc; unsigned int h = hash_str(str); - list_for_each (tmp, _uuid_buckets + h) { - hc = list_entry(tmp, struct hash_cell, uuid_list); + list_for_each_entry (hc, _uuid_buckets + h, uuid_list) if (!strcmp(hc->uuid, str)) return hc; - } return NULL; } @@ -1017,6 +1011,7 @@ unsigned int count = 0; struct list_head *tmp; size_t len, needed; + struct dm_dev *dd; struct dm_target_deps *deps; deps = get_result_buffer(param, param_size, &len); @@ -1024,7 +1019,7 @@ /* * Count the devices. */ - list_for_each(tmp, dm_table_get_devices(table)) + list_for_each (tmp, dm_table_get_devices(table)) count++; /* @@ -1041,10 +1036,8 @@ */ deps->count = count; count = 0; - list_for_each(tmp, dm_table_get_devices(table)) { - struct dm_dev *dd = list_entry(tmp, struct dm_dev, list); + list_for_each_entry (dd, dm_table_get_devices(table), list) deps->dev[count++] = huge_encode_dev(dd->bdev->bd_dev); - } param->data_size = param->data_start + needed; } --- diff/drivers/md/dm-log.c 2004-02-09 11:21:56.000000000 +0000 +++ source/drivers/md/dm-log.c 2004-02-09 15:32:07.000000000 +0000 @@ -46,17 +46,14 @@ static struct dirty_log_type *get_type(const char *type_name) { struct dirty_log_type *type; - struct list_head *tmp; spin_lock(&_lock); - list_for_each (tmp, &_log_types) { - type = list_entry(tmp, struct dirty_log_type, list); + list_for_each_entry (type, &_log_types, list) if (!strcmp(type_name, type->name)) { type->use_count++; spin_unlock(&_lock); return type; } - } spin_unlock(&_lock); return NULL; --- diff/drivers/md/dm-raid1.c 2004-02-09 11:22:06.000000000 +0000 +++ source/drivers/md/dm-raid1.c 2004-02-09 15:32:57.000000000 +0000 @@ -317,8 +317,7 @@ static void rh_update_states(struct region_hash *rh) { - struct list_head *tmp, *tmp2; - struct region *reg; + struct region *reg, *next; LIST_HEAD(clean); LIST_HEAD(recovered); @@ -353,9 +352,7 @@ * now been pulled out of the system, so no need to do * any more locking. */ - list_for_each_safe (tmp, tmp2, &recovered) { - reg = list_entry(tmp, struct region, list); - + list_for_each_entry_safe (reg, next, &recovered, list) { rh->log->type->clear_region(rh->log, reg->key); rh->log->type->complete_resync_work(rh->log, reg->key, 1); dispatch_bios(rh->ms, reg->delayed_bios); @@ -363,10 +360,8 @@ mempool_free(reg, rh->region_pool); } - list_for_each_safe (tmp, tmp2, &clean) { - reg = list_entry(tmp, struct region, list); + list_for_each_entry_safe (reg, next, &clean, list) mempool_free(reg, rh->region_pool); - } } static void rh_inc(struct region_hash *rh, region_t region) --- diff/drivers/md/dm-snap.c 2004-02-09 11:07:59.000000000 +0000 +++ source/drivers/md/dm-snap.c 2004-02-09 15:34:15.000000000 +0000 @@ -135,17 +135,13 @@ static struct origin *__lookup_origin(struct block_device *origin) { - struct list_head *slist; struct list_head *ol; struct origin *o; ol = &_origins[origin_hash(origin)]; - list_for_each(slist, ol) { - o = list_entry(slist, struct origin, hash_list); - + list_for_each_entry (o, ol, hash_list) if (bdev_equal(o->bdev, origin)) return o; - } return NULL; } @@ -225,18 +221,16 @@ static void exit_exception_table(struct exception_table *et, kmem_cache_t *mem) { - struct list_head *slot, *entry, *temp; - struct exception *ex; + struct list_head *slot; + struct exception *ex, *next; int i, size; size = et->hash_mask + 1; for (i = 0; i < size; i++) { slot = et->table + i; - list_for_each_safe(entry, temp, slot) { - ex = list_entry(entry, struct exception, hash_list); + list_for_each_entry_safe (ex, next, slot, hash_list) kmem_cache_free(mem, ex); - } } vfree(et->table); @@ -268,15 +262,13 @@ static struct exception *lookup_exception(struct exception_table *et, chunk_t chunk) { - struct list_head *slot, *el; + struct list_head *slot; struct exception *e; slot = &et->table[exception_hash(et, chunk)]; - list_for_each(el, slot) { - e = list_entry(el, struct exception, hash_list); + list_for_each_entry (e, slot, hash_list) if (e->old_chunk == chunk) return e; - } return NULL; } @@ -981,15 +973,13 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio) { int r = 1, first = 1; - struct list_head *sl; struct dm_snapshot *snap; struct exception *e; struct pending_exception *pe, *last = NULL; chunk_t chunk; /* Do all the snapshots on this origin */ - list_for_each(sl, snapshots) { - snap = list_entry(sl, struct dm_snapshot, list); + list_for_each_entry (snap, snapshots, list) { /* Only deal with valid snapshots */ if (!snap->valid) @@ -1129,17 +1119,13 @@ struct dm_dev *dev = (struct dm_dev *) ti->private; struct dm_snapshot *snap; struct origin *o; - struct list_head *sl; chunk_t chunk_size = 0; down_read(&_origins_lock); o = __lookup_origin(dev->bdev); - if (o) { - list_for_each(sl, &o->snapshots) { - snap = list_entry(sl, struct dm_snapshot, list); + if (o) + list_for_each_entry (snap, &o->snapshots, list) chunk_size = min_not_zero(chunk_size, snap->chunk_size); - } - } up_read(&_origins_lock); ti->split_io = chunk_size; --- diff/drivers/md/dm-table.c 2004-02-09 10:43:22.000000000 +0000 +++ source/drivers/md/dm-table.c 2004-02-09 15:28:59.000000000 +0000 @@ -324,13 +324,11 @@ */ static struct dm_dev *find_device(struct list_head *l, dev_t dev) { - struct list_head *tmp; + struct dm_dev *dd; - list_for_each(tmp, l) { - struct dm_dev *dd = list_entry(tmp, struct dm_dev, list); + list_for_each_entry (dd, l, list) if (dd->bdev->bd_dev == dev) return dd; - } return NULL; } --- diff/drivers/md/dm-target.c 2004-02-09 10:42:43.000000000 +0000 +++ source/drivers/md/dm-target.c 2004-02-09 15:29:19.000000000 +0000 @@ -25,15 +25,11 @@ static inline struct tt_internal *__find_target_type(const char *name) { - struct list_head *tih; struct tt_internal *ti; - list_for_each(tih, &_targets) { - ti = list_entry(tih, struct tt_internal, list); - + list_for_each_entry (ti, &_targets, list) if (!strcmp(name, ti->tt.name)) return ti; - } return NULL; } --- diff/drivers/md/kcopyd.c 2004-02-09 10:43:40.000000000 +0000 +++ source/drivers/md/kcopyd.c 2004-02-09 15:30:48.000000000 +0000 @@ -78,11 +78,11 @@ static void kcopyd_put_pages(struct kcopyd_client *kc, struct list_head *pages) { - struct list_head *tmp, *tmp2; + struct page *page, *next; spin_lock(&kc->lock); - list_for_each_safe (tmp, tmp2, pages) - __push_page(kc, list_entry(tmp, struct page, list)); + list_for_each_entry_safe (page, next, pages, list) + __push_page(kc, page); spin_unlock(&kc->lock); } @@ -91,13 +91,11 @@ */ static void drop_pages(struct list_head *pages) { - struct page *p; - struct list_head *tmp, *tmp2; + struct page *page, *next; - list_for_each_safe (tmp, tmp2, pages) { - p = list_entry(tmp, struct page, list); - ClearPageLocked(p); - __free_page(p); + list_for_each_entry_safe (page, next, pages, list) { + ClearPageLocked(page); + __free_page(page); } }