Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexey Dobriyan and committed by
Linus Torvalds
312ec7e5 fc3d8767

+5 -5
+4 -4
fs/proc/generic.c
··· 28 28 29 29 DEFINE_SPINLOCK(proc_subdir_lock); 30 30 31 - static int proc_match(int len, const char *name, struct proc_dir_entry *de) 31 + static int proc_match(unsigned int len, const char *name, struct proc_dir_entry *de) 32 32 { 33 33 if (de->namelen != len) 34 34 return 0; ··· 303 303 { 304 304 const char *cp = name, *next; 305 305 struct proc_dir_entry *de; 306 - int len; 306 + unsigned int len; 307 307 308 308 de = *ret; 309 309 if (!de) ··· 602 602 { 603 603 struct proc_dir_entry *ent = NULL; 604 604 const char *fn = name; 605 - int len; 605 + unsigned int len; 606 606 607 607 /* make sure name is valid */ 608 608 if (!name || !strlen(name)) goto out; ··· 786 786 struct proc_dir_entry **p; 787 787 struct proc_dir_entry *de = NULL; 788 788 const char *fn = name; 789 - int len; 789 + unsigned int len; 790 790 791 791 spin_lock(&proc_subdir_lock); 792 792 if (__xlate_proc_name(name, &parent, &fn) != 0) {
+1 -1
include/linux/proc_fs.h
··· 50 50 51 51 struct proc_dir_entry { 52 52 unsigned int low_ino; 53 - unsigned short namelen; 53 + unsigned int namelen; 54 54 const char *name; 55 55 mode_t mode; 56 56 nlink_t nlink;