[PATCH 2/2] fs: fix checkpatch code warnings for inotify

From: y
Date: Fri Jan 16 2015 - 10:23:27 EST


From: Stefan Haun <tux@xxxxxxxxx>

./fs/notify/inotify/inotify.h:23:
CHECK: extern prototypes should be avoided in .h files
./fs/notify/inotify/inotify.h:25:
CHECK: extern prototypes should be avoided in .h files

Removed extrn keywords; the matter, however, seems to be an open
debate.

./fs/notify/inotify/inotify_fsnotify.c:140:
ERROR: do not initialise statics to 0 or NULL

Replace the initialization by a comment:
Compiler takes care of the proper initialization.

./fs/notify/inotify/inotify_fsnotify.c:159:
WARNING: Prefer [subsystem eg: netdev]_warn([subsystem]dev, ... then
dev_warn(dev, ... then pr_warn(... to printk(KERN_WARNING ...
./fs/notify/inotify/inotify_user.c:473:
WARNING: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then
dev_err(dev, ... then pr_err(... to printk(KERN_ERR ...
./fs/notify/inotify/inotify_user.c:474:
WARNING: quoted string split across lines

Use pr_warn instead of printk and fix line break.

./fs/notify/inotify/inotify_user.c:645:
CHECK: Prefer kmalloc(sizeof(*oevent)...) over
kmalloc(sizeof(struct inotify_event_info)...)

Done that (complies to coding stlye).

Signed-off-by: Stefan Haun <tux@xxxxxxxxx>
---
fs/notify/inotify/inotify.h | 16 ++++++++--------
fs/notify/inotify/inotify_fsnotify.c | 6 +++---
fs/notify/inotify/inotify_user.c | 8 ++++----
3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h
index ed855ef..9d6d4e2 100644
--- a/fs/notify/inotify/inotify.h
+++ b/fs/notify/inotify/inotify.h
@@ -20,13 +20,13 @@ static inline struct inotify_event_info *INOTIFY_E(struct fsnotify_event *fse)
return container_of(fse, struct inotify_event_info, fse);
}

-extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
- struct fsnotify_group *group);
-extern int inotify_handle_event(struct fsnotify_group *group,
- struct inode *inode,
- struct fsnotify_mark *inode_mark,
- struct fsnotify_mark *vfsmount_mark,
- u32 mask, void *data, int data_type,
- const unsigned char *file_name, u32 cookie);
+void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
+ struct fsnotify_group *group);
+
+int inotify_handle_event(struct fsnotify_group *group, struct inode *inode,
+ struct fsnotify_mark *inode_mark,
+ struct fsnotify_mark *vfsmount_mark,
+ u32 mask, void *data, int data_type,
+ const unsigned char *file_name, u32 cookie);

extern const struct fsnotify_ops inotify_fsnotify_ops;
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index 0238615..16efe98 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -137,7 +137,7 @@ static int idr_callback(int id, void *p, void *data)
{
struct fsnotify_mark *fsn_mark;
struct inotify_inode_mark *i_mark;
- static bool warned = false;
+ static bool warned; /* = false; default by GCC */

if (warned)
return 0;
@@ -156,8 +156,8 @@ static int idr_callback(int id, void *p, void *data)
* BUG() that was here.
*/
if (fsn_mark)
- printk(KERN_WARNING "fsn_mark->group=%p inode=%p wd=%d\n",
- fsn_mark->group, fsn_mark->inode, i_mark->wd);
+ pr_warn("fsn_mark->group=%p inode=%p wd=%d\n",
+ fsn_mark->group, fsn_mark->inode, i_mark->wd);
return 0;
}

diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 3214e2b..d7e3e58 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -470,9 +470,9 @@ static void inotify_remove_from_idr(struct fsnotify_group *group,
* one ref grabbed by inotify_idr_find
*/
if (unlikely(atomic_read(&i_mark->fsn_mark.refcnt) < 3)) {
- printk(KERN_ERR "%s: i_mark=%p i_mark->wd=%d i_mark->group=%p"
- " i_mark->inode=%p\n", __func__, i_mark, i_mark->wd,
- i_mark->fsn_mark.group, i_mark->fsn_mark.inode);
+ pr_err("%s: i_mark=%p i_mark->wd=%d i_mark->group=%p i_mark->inode=%p\n",
+ __func__, i_mark, i_mark->wd, i_mark->fsn_mark.group,
+ i_mark->fsn_mark.inode);
/* we can't really recover with bad ref cnting.. */
BUG();
}
@@ -642,7 +642,7 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)
if (IS_ERR(group))
return group;

- oevent = kmalloc(sizeof(struct inotify_event_info), GFP_KERNEL);
+ oevent = kmalloc(sizeof(*oevent), GFP_KERNEL);
if (unlikely(!oevent)) {
fsnotify_destroy_group(group);
return ERR_PTR(-ENOMEM);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/