mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] proc: make struct proc_dir_entry::namelen unsigned int
@ 2011-03-08 10:54 Alexey Dobriyan
  2011-03-09 23:03 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Dobriyan @ 2011-03-08 10:54 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

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>
---

 fs/proc/generic.c       |    8 ++++----
 include/linux/proc_fs.h |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -28,7 +28,7 @@
 
 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)
 		return 0;
@@ -303,7 +303,7 @@ static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret,
 {
 	const char     		*cp = name, *next;
 	struct proc_dir_entry	*de;
-	int			len;
+	unsigned int		len;
 
 	de = *ret;
 	if (!de)
@@ -602,7 +602,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
 {
 	struct proc_dir_entry *ent = NULL;
 	const char *fn = name;
-	int len;
+	unsigned int len;
 
 	/* make sure name is valid */
 	if (!name || !strlen(name)) goto out;
@@ -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 *de = NULL;
 	const char *fn = name;
-	int len;
+	unsigned int len;
 
 	spin_lock(&proc_subdir_lock);
 	if (__xlate_proc_name(name, &parent, &fn) != 0) {
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -50,7 +50,7 @@ typedef	int (write_proc_t)(struct file *file, const char __user *buffer,
 
 struct proc_dir_entry {
 	unsigned int low_ino;
-	unsigned short namelen;
+	unsigned int namelen;
 	const char *name;
 	mode_t mode;
 	nlink_t nlink;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] proc: make struct proc_dir_entry::namelen unsigned int
  2011-03-08 10:54 [PATCH] proc: make struct proc_dir_entry::namelen unsigned int Alexey Dobriyan
@ 2011-03-09 23:03 ` Andrew Morton
  2011-03-09 23:22   ` Alexey Dobriyan
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2011-03-09 23:03 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel

On Tue, 8 Mar 2011 12:54:28 +0200
Alexey Dobriyan <adobriyan@gmail.com> wrote:

> Space is not really conserved, because of natural alignment for the next field.
> sizeof(struct proc_dir_entry) remains the same.
> 

What is the reason for this patch??


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] proc: make struct proc_dir_entry::namelen unsigned int
  2011-03-09 23:03 ` Andrew Morton
@ 2011-03-09 23:22   ` Alexey Dobriyan
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2011-03-09 23:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

On Wed, Mar 09, 2011 at 03:03:06PM -0800, Andrew Morton wrote:
> On Tue, 8 Mar 2011 12:54:28 +0200
> Alexey Dobriyan <adobriyan@gmail.com> wrote:
> 
> > Space is not really conserved, because of natural alignment for the next field.
> > sizeof(struct proc_dir_entry) remains the same.
> > 
> 
> What is the reason for this patch??

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-09 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-08 10:54 [PATCH] proc: make struct proc_dir_entry::namelen unsigned int Alexey Dobriyan
2011-03-09 23:03 ` Andrew Morton
2011-03-09 23:22   ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome