* [PATCH v2] fixed some coding style issues
@ 2013-07-31 2:49 Dong Fang
2013-07-31 2:50 ` [PATCH 1/3] vfs: fixed some CamelCase coding style issue Dong Fang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dong Fang @ 2013-07-31 2:49 UTC (permalink / raw)
To: viro, miklos; +Cc: linux-fsdevel, fuse-devel
i fixed some coding style issues and use list_for_each_entry()
for list traversing in this patchs
---
[PATCH 1/3] vfs: fixed some CamelCase coding style issue
[PATCH 2/3] fs/fuse: use list_for_each_entry() for list traversing
[PATCH 3/3] fs/vfs: use list_for_each_entry() for list traversing
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] vfs: fixed some CamelCase coding style issue
2013-07-31 2:49 [PATCH v2] fixed some coding style issues Dong Fang
@ 2013-07-31 2:50 ` Dong Fang
2013-08-05 8:16 ` Dong Fang
2013-07-31 2:50 ` [PATCH 2/3] fs/fuse: use list_for_each_entry() for list traversing Dong Fang
2013-07-31 2:50 ` [PATCH 3/3] fs/vfs: " Dong Fang
2 siblings, 1 reply; 5+ messages in thread
From: Dong Fang @ 2013-07-31 2:50 UTC (permalink / raw)
To: viro, miklos; +Cc: linux-fsdevel, fuse-devel, Dong Fang
---
fs/binfmt_misc.c | 39 ++++++++++++++++++++-------------------
1 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 1c740e1..e02b857 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -45,7 +45,7 @@ enum {Enabled, Magic};
#define MISC_FMT_OPEN_BINARY (1<<30)
#define MISC_FMT_CREDENTIALS (1<<29)
-typedef struct {
+struct bm_node {
struct list_head list;
unsigned long flags; /* type, status, etc. */
int offset; /* offset of magic */
@@ -55,7 +55,7 @@ typedef struct {
char *interpreter; /* filename of interpreter */
char *name;
struct dentry *dentry;
-} Node;
+};
static DEFINE_RWLOCK(entries_lock);
static struct file_system_type bm_fs_type;
@@ -67,13 +67,13 @@ static int entry_count;
* if we do, return the node, else NULL
* locking is done in load_misc_binary
*/
-static Node *check_file(struct linux_binprm *bprm)
+static struct bm_node *check_file(struct linux_binprm *bprm)
{
+ struct bm_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;
@@ -107,7 +107,7 @@ static Node *check_file(struct linux_binprm *bprm)
*/
static int load_misc_binary(struct linux_binprm *bprm)
{
- Node *fmt;
+ struct bm_node *fmt;
struct file * interp_file = NULL;
char iname[BINPRM_BUF_SIZE];
const char *iname_addr = iname;
@@ -235,7 +235,7 @@ static char *scanarg(char *s, char del)
return s;
}
-static char * check_special_flags (char * sfs, Node * e)
+static char *check_special_flags(char *sfs, struct bm_node *e)
{
char * p = sfs;
int cont = 1;
@@ -270,9 +270,9 @@ static char * check_special_flags (char * sfs, Node * e)
* ':name:type:offset:magic:mask:interpreter:flags'
* where the ':' is the IFS, that can be chosen with the first char
*/
-static Node *create_entry(const char __user *buffer, size_t count)
+static struct bm_node *create_entry(const char __user *buffer, size_t count)
{
- Node *e;
+ struct bm_node *e;
int memsize, err;
char *buf, *p;
char del;
@@ -283,14 +283,14 @@ static Node *create_entry(const char __user *buffer, size_t count)
goto out;
err = -ENOMEM;
- memsize = sizeof(Node) + count + 8;
+ memsize = sizeof(struct bm_node) + count + 8;
e = kmalloc(memsize, GFP_USER);
if (!e)
goto out;
- p = buf = (char *)e + sizeof(Node);
+ p = buf = (char *)e + sizeof(*e);
- memset(e, 0, sizeof(Node));
+ memset(e, 0, sizeof(*e));
if (copy_from_user(buf, buffer, count))
goto Efault;
@@ -415,7 +415,7 @@ static int parse_command(const char __user *buffer, size_t count)
/* generic stuff */
-static void entry_status(Node *e, char *page)
+static void entry_status(struct bm_node *e, char *page)
{
char *dp;
char *status = "disabled";
@@ -490,7 +490,7 @@ static void bm_evict_inode(struct inode *inode)
kfree(inode->i_private);
}
-static void kill_node(Node *e)
+static void kill_node(struct bm_node *e)
{
struct dentry *dentry;
@@ -515,7 +515,7 @@ static void kill_node(Node *e)
static ssize_t
bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
{
- Node *e = file_inode(file)->i_private;
+ struct bm_node *e = file_inode(file)->i_private;
ssize_t res;
char *page;
@@ -534,7 +534,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
struct dentry *root;
- Node *e = file_inode(file)->i_private;
+ struct bm_node *e = file_inode(file)->i_private;
int res = parse_command(buffer, count);
switch (res) {
@@ -566,7 +566,7 @@ static const struct file_operations bm_entry_operations = {
static ssize_t bm_register_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
- Node *e;
+ struct bm_node *e;
struct inode *inode;
struct dentry *root, *dentry;
struct super_block *sb = file->f_path.dentry->d_sb;
@@ -652,7 +652,8 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
mutex_lock(&root->d_inode->i_mutex);
while (!list_empty(&entries))
- kill_node(list_entry(entries.next, Node, list));
+ kill_node(list_entry(entries.next,
+ struct bm_node, list));
mutex_unlock(&root->d_inode->i_mutex);
dput(root);
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] fs/fuse: use list_for_each_entry() for list traversing
2013-07-31 2:49 [PATCH v2] fixed some coding style issues Dong Fang
2013-07-31 2:50 ` [PATCH 1/3] vfs: fixed some CamelCase coding style issue Dong Fang
@ 2013-07-31 2:50 ` Dong Fang
2013-07-31 2:50 ` [PATCH 3/3] fs/vfs: " Dong Fang
2 siblings, 0 replies; 5+ messages in thread
From: Dong Fang @ 2013-07-31 2:50 UTC (permalink / raw)
To: viro, miklos; +Cc: linux-fsdevel, fuse-devel, Dong Fang
---
fs/fuse/dev.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
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;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] fs/vfs: use list_for_each_entry() for list traversing
2013-07-31 2:49 [PATCH v2] fixed some coding style issues Dong Fang
2013-07-31 2:50 ` [PATCH 1/3] vfs: fixed some CamelCase coding style issue Dong Fang
2013-07-31 2:50 ` [PATCH 2/3] fs/fuse: use list_for_each_entry() for list traversing Dong Fang
@ 2013-07-31 2:50 ` Dong Fang
2 siblings, 0 replies; 5+ messages in thread
From: Dong Fang @ 2013-07-31 2:50 UTC (permalink / raw)
To: viro, miklos; +Cc: linux-fsdevel, fuse-devel, Dong Fang
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] vfs: fixed some CamelCase coding style issue
2013-07-31 2:50 ` [PATCH 1/3] vfs: fixed some CamelCase coding style issue Dong Fang
@ 2013-08-05 8:16 ` Dong Fang
0 siblings, 0 replies; 5+ messages in thread
From: Dong Fang @ 2013-08-05 8:16 UTC (permalink / raw)
To: Dong Fang; +Cc: viro, miklos, linux-fsdevel, fuse-devel, Dan Carpenter
On 07/30/2013 10:50 PM, Dong Fang wrote:
> ---
> fs/binfmt_misc.c | 39 ++++++++++++++++++++-------------------
> 1 files changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
> index 1c740e1..e02b857 100644
> --- a/fs/binfmt_misc.c
> +++ b/fs/binfmt_misc.c
> @@ -45,7 +45,7 @@ enum {Enabled, Magic};
> #define MISC_FMT_OPEN_BINARY (1<<30)
> #define MISC_FMT_CREDENTIALS (1<<29)
>
> -typedef struct {
> +struct bm_node {
> struct list_head list;
> unsigned long flags; /* type, status, etc. */
> int offset; /* offset of magic */
> @@ -55,7 +55,7 @@ typedef struct {
> char *interpreter; /* filename of interpreter */
> char *name;
> struct dentry *dentry;
> -} Node;
> +};
>
> static DEFINE_RWLOCK(entries_lock);
> static struct file_system_type bm_fs_type;
> @@ -67,13 +67,13 @@ static int entry_count;
> * if we do, return the node, else NULL
> * locking is done in load_misc_binary
> */
> -static Node *check_file(struct linux_binprm *bprm)
> +static struct bm_node *check_file(struct linux_binprm *bprm)
> {
> + struct bm_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;
>
> @@ -107,7 +107,7 @@ static Node *check_file(struct linux_binprm *bprm)
> */
> static int load_misc_binary(struct linux_binprm *bprm)
> {
> - Node *fmt;
> + struct bm_node *fmt;
> struct file * interp_file = NULL;
> char iname[BINPRM_BUF_SIZE];
> const char *iname_addr = iname;
> @@ -235,7 +235,7 @@ static char *scanarg(char *s, char del)
> return s;
> }
>
> -static char * check_special_flags (char * sfs, Node * e)
> +static char *check_special_flags(char *sfs, struct bm_node *e)
> {
> char * p = sfs;
> int cont = 1;
> @@ -270,9 +270,9 @@ static char * check_special_flags (char * sfs, Node * e)
> * ':name:type:offset:magic:mask:interpreter:flags'
> * where the ':' is the IFS, that can be chosen with the first char
> */
> -static Node *create_entry(const char __user *buffer, size_t count)
> +static struct bm_node *create_entry(const char __user *buffer, size_t count)
> {
> - Node *e;
> + struct bm_node *e;
> int memsize, err;
> char *buf, *p;
> char del;
> @@ -283,14 +283,14 @@ static Node *create_entry(const char __user *buffer, size_t count)
> goto out;
>
> err = -ENOMEM;
> - memsize = sizeof(Node) + count + 8;
> + memsize = sizeof(struct bm_node) + count + 8;
> e = kmalloc(memsize, GFP_USER);
> if (!e)
> goto out;
>
> - p = buf = (char *)e + sizeof(Node);
> + p = buf = (char *)e + sizeof(*e);
>
> - memset(e, 0, sizeof(Node));
> + memset(e, 0, sizeof(*e));
> if (copy_from_user(buf, buffer, count))
> goto Efault;
>
> @@ -415,7 +415,7 @@ static int parse_command(const char __user *buffer, size_t count)
>
> /* generic stuff */
>
> -static void entry_status(Node *e, char *page)
> +static void entry_status(struct bm_node *e, char *page)
> {
> char *dp;
> char *status = "disabled";
> @@ -490,7 +490,7 @@ static void bm_evict_inode(struct inode *inode)
> kfree(inode->i_private);
> }
>
> -static void kill_node(Node *e)
> +static void kill_node(struct bm_node *e)
> {
> struct dentry *dentry;
>
> @@ -515,7 +515,7 @@ static void kill_node(Node *e)
> static ssize_t
> bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
> {
> - Node *e = file_inode(file)->i_private;
> + struct bm_node *e = file_inode(file)->i_private;
> ssize_t res;
> char *page;
>
> @@ -534,7 +534,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
> size_t count, loff_t *ppos)
> {
> struct dentry *root;
> - Node *e = file_inode(file)->i_private;
> + struct bm_node *e = file_inode(file)->i_private;
> int res = parse_command(buffer, count);
>
> switch (res) {
> @@ -566,7 +566,7 @@ static const struct file_operations bm_entry_operations = {
> static ssize_t bm_register_write(struct file *file, const char __user *buffer,
> size_t count, loff_t *ppos)
> {
> - Node *e;
> + struct bm_node *e;
> struct inode *inode;
> struct dentry *root, *dentry;
> struct super_block *sb = file->f_path.dentry->d_sb;
> @@ -652,7 +652,8 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
> mutex_lock(&root->d_inode->i_mutex);
>
> while (!list_empty(&entries))
> - kill_node(list_entry(entries.next, Node, list));
> + kill_node(list_entry(entries.next,
> + struct bm_node, list));
>
> mutex_unlock(&root->d_inode->i_mutex);
> dput(root);
>
can anyone give me some suggestion? dan?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-05 0:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-31 2:49 [PATCH v2] fixed some coding style issues Dong Fang
2013-07-31 2:50 ` [PATCH 1/3] vfs: fixed some CamelCase coding style issue Dong Fang
2013-08-05 8:16 ` Dong Fang
2013-07-31 2:50 ` [PATCH 2/3] fs/fuse: use list_for_each_entry() for list traversing Dong Fang
2013-07-31 2:50 ` [PATCH 3/3] fs/vfs: " Dong Fang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).