Skip to contentSkip to conversation

inotify: fsnotify.h: use kstrdup

PATCH In review Adrian Bunk 3 participants 5 messages Jul 1, 2005 Fsnotify: filesystem notification infrastructure

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 inotify: fsnotify.h: use kstrdup

kstrdup was added in 2.6.13-rc1.

include/linux/fsnotify.h renamed from include/linux/fsnotify.h.old +1 -10
@@ -216,19 +216,10 @@
 
 /*
  * fsnotify_oldname_init - save off the old filename before we change it
- *
- * XXX: This could be kstrdup if only we could add that to lib/string.c
  */
 static inline const char *fsnotify_oldname_init(const char *name)
 {
-	size_t len;
-	char *buf;
-
-	len = strlen(name) + 1;
-	buf = kmalloc(len, GFP_KERNEL);
-	if (likely(buf))
-		memcpy(buf, name, len);
-	return buf;
+	return kstrdup(name, GFP_KERNEL);
 }
 
 /*
#1 lore raw

Why not just convert all calls of fsnotify_oldname_init() to kstrdup() and delete the inline function? The wrapper isn't adding much beyond hard-coding GFP_KERNEL.

- R.

#2 lore raw
Quoted 3 lines · Roland Dreier

Why not just convert all calls of fsnotify_oldname_init() to kstrdup() and delete the inline function? The wrapper isn't adding much beyond hard-coding GFP_KERNEL.

There's a different wrapper for CONFIG_INOTIFY=n.

Quoted 1 line

- R.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#3 lore raw
In reply to Roland Dreier
Quoted 3 lines · Roland Dreier

Why not just convert all calls of fsnotify_oldname_init() to kstrdup() and delete the inline function? The wrapper isn't adding much beyond hard-coding GFP_KERNEL.

Good idea, but the function is different if !CONFIG_INOTIFY. It exists to save us some ugly ifdefs in the source.

Robert Love