Commit 312ec7e5 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

proc: make struct proc_dir_entry::namelen unsigned int

1. namelen is declared "unsigned short" which hints for "maybe space savings".
   Indeed in 2.4 struct proc_dir_entry looked like:

        struct proc_dir_entry {
                unsigned short low_ino;
                unsigned short namelen;

   Now, low_ino is "unsigned int", all savings were gone for a long time.
   "struct proc_dir_entry" is not that countless to worry about it's size,
   anyway.

2. converting from unsigned short to int/unsigned int can only create
   problems, we better play it safe.

Space is not really conserved, because of natural alignment for the next
field.  sizeof(struct proc_dir_entry) remains the same.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fc3d8767
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
DEFINE_SPINLOCK(proc_subdir_lock); DEFINE_SPINLOCK(proc_subdir_lock);
static int proc_match(int len, const char *name, struct proc_dir_entry *de) static int proc_match(unsigned int len, const char *name, struct proc_dir_entry *de)
{ {
if (de->namelen != len) if (de->namelen != len)
return 0; return 0;
...@@ -303,7 +303,7 @@ static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret, ...@@ -303,7 +303,7 @@ static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret,
{ {
const char *cp = name, *next; const char *cp = name, *next;
struct proc_dir_entry *de; struct proc_dir_entry *de;
int len; unsigned int len;
de = *ret; de = *ret;
if (!de) if (!de)
...@@ -602,7 +602,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, ...@@ -602,7 +602,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
{ {
struct proc_dir_entry *ent = NULL; struct proc_dir_entry *ent = NULL;
const char *fn = name; const char *fn = name;
int len; unsigned int len;
/* make sure name is valid */ /* make sure name is valid */
if (!name || !strlen(name)) goto out; if (!name || !strlen(name)) goto out;
...@@ -786,7 +786,7 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent) ...@@ -786,7 +786,7 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
struct proc_dir_entry **p; struct proc_dir_entry **p;
struct proc_dir_entry *de = NULL; struct proc_dir_entry *de = NULL;
const char *fn = name; const char *fn = name;
int len; unsigned int len;
spin_lock(&proc_subdir_lock); spin_lock(&proc_subdir_lock);
if (__xlate_proc_name(name, &parent, &fn) != 0) { if (__xlate_proc_name(name, &parent, &fn) != 0) {
......
...@@ -50,7 +50,7 @@ typedef int (write_proc_t)(struct file *file, const char __user *buffer, ...@@ -50,7 +50,7 @@ typedef int (write_proc_t)(struct file *file, const char __user *buffer,
struct proc_dir_entry { struct proc_dir_entry {
unsigned int low_ino; unsigned int low_ino;
unsigned short namelen; unsigned int namelen;
const char *name; const char *name;
mode_t mode; mode_t mode;
nlink_t nlink; nlink_t nlink;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment