linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/2] seq_file/netfilter: Start removing returns from seq_<foo>
@ 2013-12-12  3:44 Joe Perches
  2013-12-12  3:44 ` [PATCH -next 1/2] seq_file: Rename static bool seq_overflow to public bool seq_is_buf_full Joe Perches
  2013-12-12 23:47 ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches
  0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2013-12-12  3:44 UTC (permalink / raw)
  To: Alexander Viro
  Cc: Kees Cook, linux-doc, linux-kernel, linux-fsdevel,
	netfilter-devel, netfilter, coreteam, netdev

The return value from seq_printf/puts/putc/etc are frequently misused.
Start removing the uses of the return values.

Joe Perches (2):
  seq_file: Rename static bool seq_overflow to public bool seq_is_buf_full
  netfilter: Convert print_tuple functions to return void

 Documentation/filesystems/seq_file.txt       | 28 ++++++++++++++++------------
 fs/seq_file.c                                | 28 ++++++++++++++--------------
 include/linux/seq_file.h                     |  8 ++++++++
 include/net/netfilter/nf_conntrack_core.h    |  2 +-
 include/net/netfilter/nf_conntrack_l3proto.h |  4 ++--
 include/net/netfilter/nf_conntrack_l4proto.h |  4 ++--
 net/netfilter/nf_conntrack_l3proto_generic.c |  5 ++---
 net/netfilter/nf_conntrack_proto_dccp.c      | 10 +++++-----
 net/netfilter/nf_conntrack_proto_generic.c   |  5 ++---
 net/netfilter/nf_conntrack_proto_gre.c       | 10 +++++-----
 net/netfilter/nf_conntrack_proto_sctp.c      | 10 +++++-----
 net/netfilter/nf_conntrack_proto_tcp.c       | 10 +++++-----
 net/netfilter/nf_conntrack_proto_udp.c       | 10 +++++-----
 net/netfilter/nf_conntrack_proto_udplite.c   | 10 +++++-----
 net/netfilter/nf_conntrack_standalone.c      | 15 +++++++--------
 15 files changed, 84 insertions(+), 75 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.dirty


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

* [PATCH -next 1/2] seq_file: Rename static bool seq_overflow to public bool seq_is_buf_full
  2013-12-12  3:44 [PATCH -next 0/2] seq_file/netfilter: Start removing returns from seq_<foo> Joe Perches
@ 2013-12-12  3:44 ` Joe Perches
  2013-12-12 23:47 ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2013-12-12  3:44 UTC (permalink / raw)
  To: Alexander Viro
  Cc: Kees Cook, Rob Landley, Alexander Viro, linux-doc, linux-kernel,
	linux-fsdevel

The return values of seq_printf/puts/putc are frequently misused.

Start down a path to remove all the return value uses of these
functions.

Make the static bool seq_overflow public along with a rename of
the function to seq_is_buf_full.  Rename the still static
seq_set_overflow to seq_set_buf_full.

Update the documentation to not show return types for seq_printf
et al.  Add a description of seq_is_buf_full.

Signed-off-by: Joe Perches <joe@perches.com>
---
 Documentation/filesystems/seq_file.txt | 28 ++++++++++++++++------------
 fs/seq_file.c                          | 28 ++++++++++++++--------------
 include/linux/seq_file.h               |  8 ++++++++
 3 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/Documentation/filesystems/seq_file.txt b/Documentation/filesystems/seq_file.txt
index a1e2e0d..794dbde 100644
--- a/Documentation/filesystems/seq_file.txt
+++ b/Documentation/filesystems/seq_file.txt
@@ -171,27 +171,23 @@ output must be passed to the seq_file code. Some utility functions have
 been defined which make this task easy.
 
 Most code will simply use seq_printf(), which works pretty much like
-printk(), but which requires the seq_file pointer as an argument. It is
-common to ignore the return value from seq_printf(), but a function
-producing complicated output may want to check that value and quit if
-something non-zero is returned; an error return means that the seq_file
-buffer has been filled and further output will be discarded.
+printk(), but which requires the seq_file pointer as an argument.
 
 For straight character output, the following functions may be used:
 
-	int seq_putc(struct seq_file *m, char c);
-	int seq_puts(struct seq_file *m, const char *s);
-	int seq_escape(struct seq_file *m, const char *s, const char *esc);
+	seq_putc(struct seq_file *m, char c);
+	seq_puts(struct seq_file *m, const char *s);
+	seq_escape(struct seq_file *m, const char *s, const char *esc);
 
 The first two output a single character and a string, just like one would
 expect. seq_escape() is like seq_puts(), except that any character in s
 which is in the string esc will be represented in octal form in the output.
 
-There is also a pair of functions for printing filenames:
+There are also a pair of functions for printing filenames:
 
-	int seq_path(struct seq_file *m, struct path *path, char *esc);
-	int seq_path_root(struct seq_file *m, struct path *path,
-			  struct path *root, char *esc)
+	seq_path(struct seq_file *m, struct path *path, char *esc);
+	seq_path_root(struct seq_file *m, struct path *path,
+		      struct path *root, char *esc)
 
 Here, path indicates the file of interest, and esc is a set of characters
 which should be escaped in the output.  A call to seq_path() will output
@@ -200,6 +196,14 @@ root is desired, it can be used with seq_path_root().  Note that, if it
 turns out that path cannot be reached from root, the value of root will be
 changed in seq_file_root() to a root which *does* work.
 
+A function producing complicated output may want to check
+	bool seq_is_buf_full(struct seq_file *m);
+and avoid further seq_<output> calls if true is returned.
+
+A true return from seq_is_buf_full means that the seq_file buffer is full
+and further output will be discarded.  The seq_show function will attempt
+to allocate a larger buffer and retry printing.
+
 
 Making it all work
 
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 1d641bb..2fda3a1 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -14,18 +14,18 @@
 #include <asm/uaccess.h>
 #include <asm/page.h>
 
-
 /*
- * seq_files have a buffer which can may overflow. When this happens a larger
+ * seq_files have a buffer which may overflow. When this happens a larger
  * buffer is reallocated and all the data will be printed again.
  * The overflow state is true when m->count == m->size.
  */
-static bool seq_overflow(struct seq_file *m)
+bool seq_is_buf_full(struct seq_file *m)
 {
 	return m->count == m->size;
 }
+EXPORT_SYMBOL(seq_is_buf_full);
 
-static void seq_set_overflow(struct seq_file *m)
+static void seq_set_buf_full(struct seq_file *m)
 {
 	m->count = m->size;
 }
@@ -112,7 +112,7 @@ static int traverse(struct seq_file *m, loff_t offset)
 			error = 0;
 			m->count = 0;
 		}
-		if (seq_overflow(m))
+		if (seq_is_buf_full(m))
 			goto Eoverflow;
 		if (pos + m->count > offset) {
 			m->from = offset - pos;
@@ -255,7 +255,7 @@ Fill:
 			break;
 		}
 		err = m->op->show(m, p);
-		if (seq_overflow(m) || err) {
+		if (seq_is_buf_full(m) || err) {
 			m->count = offs;
 			if (likely(err <= 0))
 				break;
@@ -384,7 +384,7 @@ int seq_escape(struct seq_file *m, const char *s, const char *esc)
 			*p++ = '0' + (c & 07);
 			continue;
 		}
-		seq_set_overflow(m);
+		seq_set_buf_full(m);
 		return -1;
         }
 	m->count = p - m->buf;
@@ -403,7 +403,7 @@ int seq_vprintf(struct seq_file *m, const char *f, va_list args)
 			return 0;
 		}
 	}
-	seq_set_overflow(m);
+	seq_set_buf_full(m);
 	return -1;
 }
 EXPORT_SYMBOL(seq_vprintf);
@@ -545,7 +545,7 @@ int seq_bitmap(struct seq_file *m, const unsigned long *bits,
 			return 0;
 		}
 	}
-	seq_set_overflow(m);
+	seq_set_buf_full(m);
 	return -1;
 }
 EXPORT_SYMBOL(seq_bitmap);
@@ -561,7 +561,7 @@ int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
 			return 0;
 		}
 	}
-	seq_set_overflow(m);
+	seq_set_buf_full(m);
 	return -1;
 }
 EXPORT_SYMBOL(seq_bitmap_list);
@@ -690,7 +690,7 @@ int seq_puts(struct seq_file *m, const char *s)
 		m->count += len;
 		return 0;
 	}
-	seq_set_overflow(m);
+	seq_set_buf_full(m);
 	return -1;
 }
 EXPORT_SYMBOL(seq_puts);
@@ -724,7 +724,7 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
 	m->count += len;
 	return 0;
 overflow:
-	seq_set_overflow(m);
+	seq_set_buf_full(m);
 	return -1;
 }
 EXPORT_SYMBOL(seq_put_decimal_ull);
@@ -734,7 +734,7 @@ int seq_put_decimal_ll(struct seq_file *m, char delimiter,
 {
 	if (num < 0) {
 		if (m->count + 3 >= m->size) {
-			seq_set_overflow(m);
+			seq_set_buf_full(m);
 			return -1;
 		}
 		if (delimiter)
@@ -762,7 +762,7 @@ int seq_write(struct seq_file *seq, const void *data, size_t len)
 		seq->count += len;
 		return 0;
 	}
-	seq_set_overflow(seq);
+	seq_set_buf_full(seq);
 	return -1;
 }
 EXPORT_SYMBOL(seq_write);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 52e0097..8a8f87f 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -43,6 +43,14 @@ struct seq_operations {
 #define SEQ_SKIP 1
 
 /**
+ * seq_is_buf_full - check if the buffer associated to seq_file is full
+ * @m: the seq_file handle
+ *
+ * Returns true if the buffer is full
+ */
+bool seq_is_buf_full(struct seq_file *m);
+
+/**
  * seq_get_buf - get buffer to write arbitrary data to
  * @m: the seq_file handle
  * @bufp: the beginning of the buffer is stored here
-- 
1.8.1.2.459.gbcd45b4.dirty

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

* [PATCH -next 0/4] fs: Use seq_is_buf_full
  2013-12-12  3:44 [PATCH -next 0/2] seq_file/netfilter: Start removing returns from seq_<foo> Joe Perches
  2013-12-12  3:44 ` [PATCH -next 1/2] seq_file: Rename static bool seq_overflow to public bool seq_is_buf_full Joe Perches
@ 2013-12-12 23:47 ` Joe Perches
  2013-12-12 23:47   ` [PATCH -next 3/4] fs: Convert show_fdinfo functions to void Joe Perches
  2014-01-08 17:47   ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches
  1 sibling, 2 replies; 5+ messages in thread
From: Joe Perches @ 2013-12-12 23:47 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-kernel, cluster-devel, linux-fsdevel

Convert the fs uses and misuses of seq_printf to void

These patches depend on https://lkml.org/lkml/2013/12/11/714

Joe Perches (4):
  dlm: Use seq_is_buf_full - remove seq_printf returns
  dlm: Use seq_puts, remove unnecessary trailing spaces
  fs: Convert show_fdinfo functions to void
  debugfs: Fix misuse of seq_printf return value

 fs/debugfs/file.c  |  14 +--
 fs/dlm/debug_fs.c  | 274 +++++++++++++++++++++++++----------------------------
 fs/eventfd.c       |  15 +--
 fs/eventpoll.c     |  19 ++--
 fs/notify/fdinfo.c |  68 ++++++-------
 fs/notify/fdinfo.h |   4 +-
 fs/proc/fd.c       |   2 +-
 fs/signalfd.c      |  10 +-
 include/linux/fs.h |   2 +-
 9 files changed, 184 insertions(+), 224 deletions(-)

-- 
1.8.1.2.459.gbcd45b4.dirty


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

* [PATCH -next 3/4] fs: Convert show_fdinfo functions to void
  2013-12-12 23:47 ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches
@ 2013-12-12 23:47   ` Joe Perches
  2014-01-08 17:47   ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2013-12-12 23:47 UTC (permalink / raw)
  To: Alexander Viro
  Cc: Alexander Viro, Matthew Wilcox, linux-fsdevel, linux-kernel

seq_printf functions shouldn't really check the return value.
Checking seq_is_buf_full occasionally is used instead.

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/eventfd.c       | 15 ++++--------
 fs/eventpoll.c     | 19 ++++++---------
 fs/notify/fdinfo.c | 68 +++++++++++++++++++++++-------------------------------
 fs/notify/fdinfo.h |  4 ++--
 fs/proc/fd.c       |  2 +-
 fs/signalfd.c      | 10 +++-----
 include/linux/fs.h |  2 +-
 7 files changed, 48 insertions(+), 72 deletions(-)

diff --git a/fs/eventfd.c b/fs/eventfd.c
index 35470d9..c612526 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -286,25 +286,20 @@ static ssize_t eventfd_write(struct file *file, const char __user *buf, size_t c
 	return res;
 }
 
-#ifdef CONFIG_PROC_FS
-static int eventfd_show_fdinfo(struct seq_file *m, struct file *f)
+static void eventfd_show_fdinfo(struct seq_file *m, struct file *f)
 {
+#ifdef CONFIG_PROC_FS
 	struct eventfd_ctx *ctx = f->private_data;
-	int ret;
 
 	spin_lock_irq(&ctx->wqh.lock);
-	ret = seq_printf(m, "eventfd-count: %16llx\n",
-			 (unsigned long long)ctx->count);
+	seq_printf(m, "eventfd-count: %16llx\n",
+		   (unsigned long long)ctx->count);
 	spin_unlock_irq(&ctx->wqh.lock);
-
-	return ret;
-}
 #endif
+}
 
 static const struct file_operations eventfd_fops = {
-#ifdef CONFIG_PROC_FS
 	.show_fdinfo	= eventfd_show_fdinfo,
-#endif
 	.release	= eventfd_release,
 	.poll		= eventfd_poll,
 	.read		= eventfd_read,
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 8b5e258..d364e67 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -869,34 +869,29 @@ static unsigned int ep_eventpoll_poll(struct file *file, poll_table *wait)
 	return pollflags != -1 ? pollflags : 0;
 }
 
-#ifdef CONFIG_PROC_FS
-static int ep_show_fdinfo(struct seq_file *m, struct file *f)
+static void ep_show_fdinfo(struct seq_file *m, struct file *f)
 {
+#ifdef CONFIG_PROC_FS
 	struct eventpoll *ep = f->private_data;
 	struct rb_node *rbp;
-	int ret = 0;
 
 	mutex_lock(&ep->mtx);
 	for (rbp = rb_first(&ep->rbr); rbp; rbp = rb_next(rbp)) {
 		struct epitem *epi = rb_entry(rbp, struct epitem, rbn);
 
-		ret = seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
-				 epi->ffd.fd, epi->event.events,
-				 (long long)epi->event.data);
-		if (ret)
+		seq_printf(m, "tfd: %8d events: %8x data: %16llx\n",
+			   epi->ffd.fd, epi->event.events,
+			   (long long)epi->event.data);
+		if (seq_is_buf_full(m))
 			break;
 	}
 	mutex_unlock(&ep->mtx);
-
-	return ret;
-}
 #endif
+}
 
 /* File callbacks that implement the eventpoll file behaviour */
 static const struct file_operations eventpoll_fops = {
-#ifdef CONFIG_PROC_FS
 	.show_fdinfo	= ep_show_fdinfo,
-#endif
 	.release	= ep_eventpoll_release,
 	.poll		= ep_eventpoll_poll,
 	.llseek		= noop_llseek,
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index 238a593..62595415 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -20,25 +20,24 @@
 
 #if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY)
 
-static int show_fdinfo(struct seq_file *m, struct file *f,
-		       int (*show)(struct seq_file *m, struct fsnotify_mark *mark))
+static void show_fdinfo(struct seq_file *m, struct file *f,
+			void (*show)(struct seq_file *m,
+				     struct fsnotify_mark *mark))
 {
 	struct fsnotify_group *group = f->private_data;
 	struct fsnotify_mark *mark;
-	int ret = 0;
 
 	mutex_lock(&group->mark_mutex);
 	list_for_each_entry(mark, &group->marks_list, g_list) {
-		ret = show(m, mark);
-		if (ret)
+		show(m, mark);
+		if (seq_is_buf_full(m))
 			break;
 	}
 	mutex_unlock(&group->mark_mutex);
-	return ret;
 }
 
 #if defined(CONFIG_EXPORTFS)
-static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
+static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
 {
 	struct {
 		struct file_handle handle;
@@ -52,24 +51,21 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
 	ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
 	if ((ret == 255) || (ret == -ENOSPC)) {
 		WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
-		return 0;
+		return;
 	}
 
 	f.handle.handle_type = ret;
 	f.handle.handle_bytes = size * sizeof(u32);
 
-	ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
-			 f.handle.handle_bytes, f.handle.handle_type);
+	seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
+		   f.handle.handle_bytes, f.handle.handle_type);
 
 	for (i = 0; i < f.handle.handle_bytes; i++)
-		ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
-
-	return ret;
+		seq_printf(m, "%02x", (int)f.handle.f_handle[i]);
 }
 #else
-static int show_mark_fhandle(struct seq_file *m, struct inode *inode)
+static void show_mark_fhandle(struct seq_file *m, struct inode *inode)
 {
-	return 0;
 }
 #endif
 
@@ -79,7 +75,6 @@ static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 {
 	struct inotify_inode_mark *inode_mark;
 	struct inode *inode;
-	int ret = 0;
 
 	if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE)))
 		return 0;
@@ -87,22 +82,20 @@ static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 	inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
 	inode = igrab(mark->i.inode);
 	if (inode) {
-		ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x "
-				 "mask:%x ignored_mask:%x ",
-				 inode_mark->wd, inode->i_ino,
-				 inode->i_sb->s_dev,
-				 mark->mask, mark->ignored_mask);
-		ret |= show_mark_fhandle(m, inode);
-		ret |= seq_putc(m, '\n');
+		seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
+			   inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
+			   mark->mask, mark->ignored_mask);
+		show_mark_fhandle(m, inode);
+		seq_putc(m, '\n');
 		iput(inode);
 	}
 
-	return ret;
+	return 0;
 }
 
-int inotify_show_fdinfo(struct seq_file *m, struct file *f)
+void inotify_show_fdinfo(struct seq_file *m, struct file *f)
 {
-	return show_fdinfo(m, f, inotify_fdinfo);
+	show_fdinfo(m, f, inotify_fdinfo);
 }
 
 #endif /* CONFIG_INOTIFY_USER */
@@ -113,7 +106,6 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 {
 	unsigned int mflags = 0;
 	struct inode *inode;
-	int ret = 0;
 
 	if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
 		return 0;
@@ -125,25 +117,23 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 		inode = igrab(mark->i.inode);
 		if (!inode)
 			goto out;
-		ret = seq_printf(m, "fanotify ino:%lx sdev:%x "
-				 "mflags:%x mask:%x ignored_mask:%x ",
-				 inode->i_ino, inode->i_sb->s_dev,
-				 mflags, mark->mask, mark->ignored_mask);
-		ret |= show_mark_fhandle(m, inode);
-		ret |= seq_putc(m, '\n');
+		seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ",
+			   inode->i_ino, inode->i_sb->s_dev,
+			   mflags, mark->mask, mark->ignored_mask);
+		show_mark_fhandle(m, inode);
+		seq_putc(m, '\n');
 		iput(inode);
 	} else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
 		struct mount *mnt = real_mount(mark->m.mnt);
 
-		ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x "
-				 "ignored_mask:%x\n", mnt->mnt_id, mflags,
-				 mark->mask, mark->ignored_mask);
+		seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n",
+			   mnt->mnt_id, mflags, mark->mask, mark->ignored_mask);
 	}
 out:
-	return ret;
+	return 0;
 }
 
-int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
+void fanotify_show_fdinfo(struct seq_file *m, struct file *f)
 {
 	struct fsnotify_group *group = f->private_data;
 	unsigned int flags = 0;
@@ -169,7 +159,7 @@ int fanotify_show_fdinfo(struct seq_file *m, struct file *f)
 	seq_printf(m, "fanotify flags:%x event-flags:%x\n",
 		   flags, group->fanotify_data.f_flags);
 
-	return show_fdinfo(m, f, fanotify_fdinfo);
+	show_fdinfo(m, f, fanotify_fdinfo);
 }
 
 #endif /* CONFIG_FANOTIFY */
diff --git a/fs/notify/fdinfo.h b/fs/notify/fdinfo.h
index 556afda..9664c49 100644
--- a/fs/notify/fdinfo.h
+++ b/fs/notify/fdinfo.h
@@ -10,11 +10,11 @@ struct file;
 #ifdef CONFIG_PROC_FS
 
 #ifdef CONFIG_INOTIFY_USER
-extern int inotify_show_fdinfo(struct seq_file *m, struct file *f);
+void inotify_show_fdinfo(struct seq_file *m, struct file *f);
 #endif
 
 #ifdef CONFIG_FANOTIFY
-extern int fanotify_show_fdinfo(struct seq_file *m, struct file *f);
+void fanotify_show_fdinfo(struct seq_file *m, struct file *f);
 #endif
 
 #else /* CONFIG_PROC_FS */
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 985ea88..3f2d7d7 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -51,7 +51,7 @@ static int seq_show(struct seq_file *m, void *v)
                 seq_printf(m, "pos:\t%lli\nflags:\t0%o\n",
 			   (long long)file->f_pos, f_flags);
 		if (file->f_op->show_fdinfo)
-			ret = file->f_op->show_fdinfo(m, file);
+			file->f_op->show_fdinfo(m, file);
 		fput(file);
 	}
 
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 424b7b6..06bd5a2 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -229,24 +229,20 @@ static ssize_t signalfd_read(struct file *file, char __user *buf, size_t count,
 	return total ? total: ret;
 }
 
-#ifdef CONFIG_PROC_FS
-static int signalfd_show_fdinfo(struct seq_file *m, struct file *f)
+static void signalfd_show_fdinfo(struct seq_file *m, struct file *f)
 {
+#ifdef CONFIG_PROC_FS
 	struct signalfd_ctx *ctx = f->private_data;
 	sigset_t sigmask;
 
 	sigmask = ctx->sigmask;
 	signotset(&sigmask);
 	render_sigset_t(m, "sigmask:\t", &sigmask);
-
-	return 0;
-}
 #endif
+}
 
 static const struct file_operations signalfd_fops = {
-#ifdef CONFIG_PROC_FS
 	.show_fdinfo	= signalfd_show_fdinfo,
-#endif
 	.release	= signalfd_release,
 	.poll		= signalfd_poll,
 	.read		= signalfd_read,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 121f11f..d95ca45 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1546,7 +1546,7 @@ struct file_operations {
 	int (*setlease)(struct file *, long, struct file_lock **);
 	long (*fallocate)(struct file *file, int mode, loff_t offset,
 			  loff_t len);
-	int (*show_fdinfo)(struct seq_file *m, struct file *f);
+	void (*show_fdinfo)(struct seq_file *m, struct file *f);
 };
 
 struct inode_operations {
-- 
1.8.1.2.459.gbcd45b4.dirty


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

* Re: [PATCH -next 0/4] fs: Use seq_is_buf_full
  2013-12-12 23:47 ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches
  2013-12-12 23:47   ` [PATCH -next 3/4] fs: Convert show_fdinfo functions to void Joe Perches
@ 2014-01-08 17:47   ` Joe Perches
  1 sibling, 0 replies; 5+ messages in thread
From: Joe Perches @ 2014-01-08 17:47 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-kernel, cluster-devel, linux-fsdevel

On Thu, 2013-12-12 at 15:47 -0800, Joe Perches wrote:
> Convert the fs uses and misuses of seq_printf to void
> 
> These patches depend on https://lkml.org/lkml/2013/12/11/714
> 
> Joe Perches (4):
>   dlm: Use seq_is_buf_full - remove seq_printf returns
>   dlm: Use seq_puts, remove unnecessary trailing spaces
>   fs: Convert show_fdinfo functions to void
>   debugfs: Fix misuse of seq_printf return value

Ping?

>  fs/debugfs/file.c  |  14 +--
>  fs/dlm/debug_fs.c  | 274 +++++++++++++++++++++++++----------------------------
>  fs/eventfd.c       |  15 +--
>  fs/eventpoll.c     |  19 ++--
>  fs/notify/fdinfo.c |  68 ++++++-------
>  fs/notify/fdinfo.h |   4 +-
>  fs/proc/fd.c       |   2 +-
>  fs/signalfd.c      |  10 +-
>  include/linux/fs.h |   2 +-
>  9 files changed, 184 insertions(+), 224 deletions(-)
> 




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

end of thread, other threads:[~2014-01-08 17:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-12  3:44 [PATCH -next 0/2] seq_file/netfilter: Start removing returns from seq_<foo> Joe Perches
2013-12-12  3:44 ` [PATCH -next 1/2] seq_file: Rename static bool seq_overflow to public bool seq_is_buf_full Joe Perches
2013-12-12 23:47 ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches
2013-12-12 23:47   ` [PATCH -next 3/4] fs: Convert show_fdinfo functions to void Joe Perches
2014-01-08 17:47   ` [PATCH -next 0/4] fs: Use seq_is_buf_full Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).