lkml.org 
[lkml]   [2004]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[patch] inotify: don't opencode the size of filename
From
Date
The size of "filename" in "struct inotify_event" is currently open coded
at 256.

Change that to INOTIFY_FILENAME_MAX and replace uses of the size with
this define.

Best,

Robert Love

Don't opencode the size of filename. Make it a define

Signed-Off-By: Robert Love <rml@novell.com>

drivers/char/inotify.c | 11 +++++++----
include/linux/inotify.h | 5 ++++-
2 files changed, 11 insertions(+), 5 deletions(-)

diff -urN linux-inotify/drivers/char/inotify.c linux/drivers/char/inotify.c
--- linux-inotify/drivers/char/inotify.c 2004-09-22 13:45:26.697470176 -0400
+++ linux/drivers/char/inotify.c 2004-09-22 13:44:41.236381312 -0400
@@ -143,10 +143,13 @@
INIT_LIST_HEAD(&kevent->list);

if (filename) {
- iprintk(INOTIFY_DEBUG_FILEN, "filename for event was %p %s\n", filename, filename);
- strncpy (kevent->event.filename, filename, 256);
- kevent->event.filename[255] = '\0';
- iprintk(INOTIFY_DEBUG_FILEN, "filename after copying %s\n", kevent->event.filename);
+ iprintk(INOTIFY_DEBUG_FILEN,
+ "filename for event was %p %s\n", filename, filename);
+ strncpy (kevent->event.filename, filename,
+ INOTIFY_FILENAME_MAX);
+ kevent->event.filename[INOTIFY_FILENAME_MAX-1] = '\0';
+ iprintk(INOTIFY_DEBUG_FILEN,
+ "filename after copying %s\n", kevent->event.filename);
} else {
iprintk(INOTIFY_DEBUG_FILEN, "no filename for event\n");
kevent->event.filename[0] = '\0';
diff -urN linux-inotify/include/linux/inotify.h linux/include/linux/inotify.h
--- linux-inotify/include/linux/inotify.h 2004-09-22 13:30:09.763865272 -0400
+++ linux/include/linux/inotify.h 2004-09-22 13:42:48.853466112 -0400
@@ -11,6 +11,9 @@

#include <linux/limits.h>

+/* this size could limit things, since technically we could need PATH_MAX */
+#define INOTIFY_FILENAME_MAX 256
+
/*
* struct inotify_event - structure read from the inotify device for each event
*
@@ -23,7 +26,7 @@
struct inotify_event {
int wd;
int mask;
- char filename[256]; /* XXX: This size may be a problem */
+ char filename[INOTIFY_FILENAME_MAX];
};

/* the following are legal, implemented events */
\
 
 \ /
  Last update: 2005-03-22 14:06    [W:0.024 / U:0.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site