--- fs/binfmt_elf.c | 22 ++++++++-------------- fs/binfmt_elf_fdpic.c | 34 +++++++++++++--------------------- fs/dcookies.c | 27 ++++++++++----------------- fs/mbcache.c | 6 +++--- 4 files changed, 34 insertions(+), 55 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 100edcc..22b9245 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1867,10 +1867,8 @@ static int fill_note_info(struct elfhdr *elf, int phdrs, list_add(&ets->list, &info->thread_list); } - list_for_each(t, &info->thread_list) { + list_for_each_entry(ets, &info->thread_list, list) { int sz; - - ets = list_entry(t, struct elf_thread_status, list); sz = elf_dump_thread_status(siginfo->si_signo, ets); info->thread_status_size += sz; } @@ -1933,19 +1931,16 @@ static int write_note_info(struct elf_note_info *info, struct file *file, loff_t *foffset) { int i; - struct list_head *t; + struct elf_thread_status *ets; for (i = 0; i < info->numnote; i++) if (!writenote(info->notes + i, file, foffset)) return 0; /* write out the thread status notes section */ - list_for_each(t, &info->thread_list) { - struct elf_thread_status *tmp = - list_entry(t, struct elf_thread_status, list); - - for (i = 0; i < tmp->num_notes; i++) - if (!writenote(&tmp->notes[i], file, foffset)) + list_for_each_entry(ets, &info->thread_list, list) { + for (i = 0; i < ets->num_notes; i++) + if (!writenote(&ets->notes[i], file, foffset)) return 0; } @@ -1954,10 +1949,9 @@ static int write_note_info(struct elf_note_info *info, static void free_note_info(struct elf_note_info *info) { - while (!list_empty(&info->thread_list)) { - struct list_head *tmp = info->thread_list.next; - list_del(tmp); - kfree(list_entry(tmp, struct elf_thread_status, list)); + struct elf_thread_status *ets, *tmp; + list_for_each_entry_safe(ets, tmp, &info->thread_list, list) { + kfree(ets); } /* Free data allocated by fill_files_note(): */ diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index c166f32..2d00655 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1595,7 +1595,6 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) struct elf_prstatus *prstatus = NULL; /* NT_PRSTATUS */ struct elf_prpsinfo *psinfo = NULL; /* NT_PRPSINFO */ LIST_HEAD(thread_list); - struct list_head *t; elf_fpregset_t *fpu = NULL; #ifdef ELF_CORE_COPY_XFPREGS elf_fpxregset_t *xfpu = NULL; @@ -1604,6 +1603,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) elf_addr_t *auxv; struct elf_phdr *phdr4note = NULL; struct elf_shdr *shdr4extnum = NULL; + struct elf_thread_status *ets, *tmp; Elf_Half e_phnum; elf_addr_t e_shoff; @@ -1643,24 +1643,21 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) if (cprm->siginfo->si_signo) { struct core_thread *ct; - struct elf_thread_status *tmp; for (ct = current->mm->core_state->dumper.next; ct; ct = ct->next) { - tmp = kzalloc(sizeof(*tmp), GFP_KERNEL); - if (!tmp) + ets = kzalloc(sizeof(*ets), GFP_KERNEL); + if (!ets) goto cleanup; - tmp->thread = ct->task; - list_add(&tmp->list, &thread_list); + ets->thread = ct->task; + list_add(&ets->list, &thread_list); } - list_for_each(t, &thread_list) { - struct elf_thread_status *tmp; + list_for_each_entry(ets, &thread_list, list) { int sz; - - tmp = list_entry(t, struct elf_thread_status, list); - sz = elf_dump_thread_status(cprm->siginfo->si_signo, tmp); + sz = elf_dump_thread_status(cprm->siginfo->si_signo, + ets); thread_status_size += sz; } } @@ -1800,12 +1797,9 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) goto end_coredump; /* write out the thread status notes section */ - list_for_each(t, &thread_list) { - struct elf_thread_status *tmp = - list_entry(t, struct elf_thread_status, list); - - for (i = 0; i < tmp->num_notes; i++) - if (!writenote(&tmp->notes[i], cprm->file, &foffset)) + list_for_each_entry(ets, &thread_list, list) { + for (i = 0; i < ets->num_notes; i++) + if (!writenote(&ets->notes[i], cprm->file, &foffset)) goto end_coredump; } @@ -1838,10 +1832,8 @@ end_coredump: set_fs(fs); cleanup: - while (!list_empty(&thread_list)) { - struct list_head *tmp = thread_list.next; - list_del(tmp); - kfree(list_entry(tmp, struct elf_thread_status, list)); + list_for_each_entry_safe(ets, tmp, &thread_list, list) { + kfree(ets); } kfree(phdr4note); kfree(elf); diff --git a/fs/dcookies.c b/fs/dcookies.c index ab5954b..f1af239 100644 --- a/fs/dcookies.c +++ b/fs/dcookies.c @@ -64,22 +64,18 @@ static size_t dcookie_hash(unsigned long dcookie) static struct dcookie_struct * find_dcookie(unsigned long dcookie) { - struct dcookie_struct *found = NULL; - struct dcookie_struct * dcs; - struct list_head * pos; - struct list_head * list; + struct dcookie_struct *dcs; + struct list_head *head; - list = dcookie_hashtable + dcookie_hash(dcookie); + head = dcookie_hashtable + dcookie_hash(dcookie); - list_for_each(pos, list) { - dcs = list_entry(pos, struct dcookie_struct, hash_list); + list_for_each_entry(dcs, head, hash_list) { if (dcookie_value(dcs) == dcookie) { - found = dcs; - break; + return dcs; } } - return found; + return NULL; } @@ -283,16 +279,13 @@ static void free_dcookie(struct dcookie_struct * dcs) static void dcookie_exit(void) { - struct list_head * list; - struct list_head * pos; - struct list_head * pos2; - struct dcookie_struct * dcs; + struct list_head *head; + struct dcookie_struct *dcs, *tmp; size_t i; for (i = 0; i < hash_size; ++i) { - list = dcookie_hashtable + i; - list_for_each_safe(pos, pos2, list) { - dcs = list_entry(pos, struct dcookie_struct, hash_list); + head = dcookie_hashtable + i; + list_for_each_entry_safe(dcs, tmp, head, hash_list) { list_del(&dcs->hash_list); free_dcookie(dcs); } diff --git a/fs/mbcache.c b/fs/mbcache.c index 8c32ef3..ae7d9de 100644 --- a/fs/mbcache.c +++ b/fs/mbcache.c @@ -458,14 +458,14 @@ mb_cache_entry_get(struct mb_cache *cache, struct block_device *bdev, sector_t block) { unsigned int bucket; - struct list_head *l; + struct list_head *head; struct mb_cache_entry *ce; bucket = hash_long((unsigned long)bdev + (block & 0xffffffff), cache->c_bucket_bits); spin_lock(&mb_cache_spinlock); - list_for_each(l, &cache->c_block_hash[bucket]) { - ce = list_entry(l, struct mb_cache_entry, e_block_list); + head = &cache->c_block_hash[bucket]; + list_for_each_entry(ce, head, e_block_list) { if (ce->e_bdev == bdev && ce->e_block == block) { DEFINE_WAIT(wait); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html