note: the ./checkpatch will report coding style error: WARNING: Avoid CamelCase: <Node> ... because i don't want to change more origin code in this patch if need be, i will send a separate patch to fix this problem. Signed-off-by: Dong Fang <yp.fangdong@xxxxxxxxx> --- fs/aio.c | 5 ++--- fs/binfmt_elf.c | 22 ++++++++-------------- fs/binfmt_elf_fdpic.c | 34 +++++++++++++--------------------- fs/binfmt_misc.c | 5 ++--- fs/dcookies.c | 27 ++++++++++----------------- fs/fuse/dev.c | 6 ++---- fs/mbcache.c | 6 +++--- include/linux/aio.h | 5 ----- 8 files changed, 40 insertions(+), 70 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 9b5ca11..909cded 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1223,7 +1223,7 @@ SYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr, static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb, u32 key) { - struct list_head *pos; + struct kiocb *kiocb; assert_spin_locked(&ctx->ctx_lock); @@ -1231,8 +1231,7 @@ static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb, return NULL; /* TODO: use a hash or array, this sucks. */ - list_for_each(pos, &ctx->active_reqs) { - struct kiocb *kiocb = list_kiocb(pos); + list_for_each_entry(kiocb, &ctx->active_reqs, ki_list) { if (kiocb->ki_obj.user == iocb) return kiocb; } 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/binfmt_misc.c b/fs/binfmt_misc.c index 1c740e1..93a24b0 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -69,11 +69,10 @@ static int entry_count; */ static Node *check_file(struct linux_binprm *bprm) { + Node *e; char *p = strrchr(bprm->interp, '.'); - struct list_head *l; - list_for_each(l, &entries) { - Node *e = list_entry(l, Node, list); + list_for_each_entry(e, &entries, list) { char *s; int j; 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/fuse/dev.c b/fs/fuse/dev.c index 1d55f94..ef74ad5 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1765,11 +1765,9 @@ static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code, /* Look up request on processing list by unique ID */ static struct fuse_req *request_find(struct fuse_conn *fc, u64 unique) { - struct list_head *entry; + struct fuse_req *req; - list_for_each(entry, &fc->processing) { - struct fuse_req *req; - req = list_entry(entry, struct fuse_req, list); + list_for_each_entry(req, &fc->processing, list) { if (req->in.h.unique == unique || req->intr_unique == unique) return req; } 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); diff --git a/include/linux/aio.h b/include/linux/aio.h index 1bdf965..77a9436 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h @@ -104,11 +104,6 @@ static inline void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel) { } #endif /* CONFIG_AIO */ -static inline struct kiocb *list_kiocb(struct list_head *h) -{ - return list_entry(h, struct kiocb, ki_list); -} - /* for sysctl: */ extern unsigned long aio_nr; extern unsigned long aio_max_nr; -- 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