lkml.org 
[lkml]   [2018]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 04/13] proc: rename "p" variable in proc_map_files_readdir()
Date
Use "mfi", add "const" and move structure definition closer while I'm at it.

Note: moving "struct map_files_info info;" declaration to the scope
where it is used bloats the code by ~90 bytes. I'm not sure what's
going on.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
fs/proc/base.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index f96babf3cffc..17666bd61ac8 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2014,12 +2014,6 @@ static int map_files_get_link(struct dentry *dentry, struct path *path)
return rc;
}

-struct map_files_info {
- unsigned long start;
- unsigned long end;
- fmode_t mode;
-};
-
/*
* Only allow CAP_SYS_ADMIN to follow the links, due to concerns about how the
* symlinks may be used to bypass permissions on ancestor directories in the
@@ -2119,6 +2113,12 @@ static const struct inode_operations proc_map_files_inode_operations = {
.setattr = proc_setattr,
};

+struct map_files_info {
+ unsigned long start;
+ unsigned long end;
+ fmode_t mode;
+};
+
static int
proc_map_files_readdir(struct file *file, struct dir_context *ctx)
{
@@ -2128,7 +2128,6 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
unsigned long nr_files, pos, i;
struct flex_array *fa = NULL;
struct map_files_info info;
- struct map_files_info *p;
int ret;

ret = -ENOENT;
@@ -2196,16 +2195,17 @@ proc_map_files_readdir(struct file *file, struct dir_context *ctx)
mmput(mm);

for (i = 0; i < nr_files; i++) {
+ const struct map_files_info *mfi;
char buf[4 * sizeof(long) + 2]; /* max: %lx-%lx\0 */
unsigned int len;

- p = flex_array_get(fa, i);
- len = snprintf(buf, sizeof(buf), "%lx-%lx", p->start, p->end);
+ mfi = flex_array_get(fa, i);
+ len = snprintf(buf, sizeof(buf), "%lx-%lx", mfi->start, mfi->end);
if (!proc_fill_cache(file, ctx,
buf, len,
proc_map_files_instantiate,
task,
- (void *)(unsigned long)p->mode))
+ (void *)(unsigned long)mfi->mode))
break;
ctx->pos++;
}
--
2.16.4
\
 
 \ /
  Last update: 2018-08-28 01:16    [W:0.161 / U:8.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site