* [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
@ 2014-09-29 23:08 ` Joe Perches
2014-09-29 23:44 ` Steven Rostedt
2014-09-30 10:06 ` Petr Mladek
2014-09-29 23:08 ` [PATCH 2/7] netfilter: Convert print_tuple functions to return void Joe Perches
` (6 subsequent siblings)
7 siblings, 2 replies; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, Jiri Kosina,
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_full. Rename the still static
seq_set_overflow to seq_set_full.
Update the documentation to not show return types for seq_printf
et al. Add a description of seq_is_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 8ea3e90..e19c636 100644
--- a/Documentation/filesystems/seq_file.txt
+++ b/Documentation/filesystems/seq_file.txt
@@ -180,27 +180,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
@@ -209,6 +205,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_full(struct seq_file *m);
+and avoid further seq_<output> calls if true is returned.
+
+A true return from seq_is_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 3857b72..555aed6 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -16,18 +16,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_full(struct seq_file *m)
{
return m->count == m->size;
}
+EXPORT_SYMBOL(seq_is_full);
-static void seq_set_overflow(struct seq_file *m)
+static void seq_set_full(struct seq_file *m)
{
m->count = m->size;
}
@@ -124,7 +124,7 @@ static int traverse(struct seq_file *m, loff_t offset)
error = 0;
m->count = 0;
}
- if (seq_overflow(m))
+ if (seq_is_full(m))
goto Eoverflow;
if (pos + m->count > offset) {
m->from = offset - pos;
@@ -267,7 +267,7 @@ Fill:
break;
}
err = m->op->show(m, p);
- if (seq_overflow(m) || err) {
+ if (seq_is_full(m) || err) {
m->count = offs;
if (likely(err <= 0))
break;
@@ -396,7 +396,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_full(m);
return -1;
}
m->count = p - m->buf;
@@ -415,7 +415,7 @@ int seq_vprintf(struct seq_file *m, const char *f, va_list args)
return 0;
}
}
- seq_set_overflow(m);
+ seq_set_full(m);
return -1;
}
EXPORT_SYMBOL(seq_vprintf);
@@ -557,7 +557,7 @@ int seq_bitmap(struct seq_file *m, const unsigned long *bits,
return 0;
}
}
- seq_set_overflow(m);
+ seq_set_full(m);
return -1;
}
EXPORT_SYMBOL(seq_bitmap);
@@ -573,7 +573,7 @@ int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
return 0;
}
}
- seq_set_overflow(m);
+ seq_set_full(m);
return -1;
}
EXPORT_SYMBOL(seq_bitmap_list);
@@ -702,7 +702,7 @@ int seq_puts(struct seq_file *m, const char *s)
m->count += len;
return 0;
}
- seq_set_overflow(m);
+ seq_set_full(m);
return -1;
}
EXPORT_SYMBOL(seq_puts);
@@ -736,7 +736,7 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
m->count += len;
return 0;
overflow:
- seq_set_overflow(m);
+ seq_set_full(m);
return -1;
}
EXPORT_SYMBOL(seq_put_decimal_ull);
@@ -746,7 +746,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_full(m);
return -1;
}
if (delimiter)
@@ -774,7 +774,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_full(seq);
return -1;
}
EXPORT_SYMBOL(seq_write);
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 52e0097..1f36da8 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_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_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] 53+ messages in thread* Re: [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full
2014-09-29 23:08 ` [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full Joe Perches
@ 2014-09-29 23:44 ` Steven Rostedt
2014-09-29 23:48 ` Joe Perches
2014-09-30 10:06 ` Petr Mladek
1 sibling, 1 reply; 53+ messages in thread
From: Steven Rostedt @ 2014-09-29 23:44 UTC (permalink / raw)
To: Joe Perches
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, Jiri Kosina,
linux-doc, linux-kernel, linux-fsdevel
On Mon, 29 Sep 2014 16:08:21 -0700
Joe Perches <joe@perches.com> wrote:
> 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_full. Rename the still static
> seq_set_overflow to seq_set_full.
>
> Update the documentation to not show return types for seq_printf
> et al. Add a description of seq_is_full.
Actually, can you make a separate function that's public that is
seq_is_full(), where m->count >= m->size, and leave seq_overflow()
alone.
That's because I'm working on making seq_overflow be
m->count > m->size, and allow m->count == m->size not be flagged as an
overflow. I'm looking at places that hard code writing into the buffer
(outside of seq_file.c) and they too can fill the buffer exactly.
Thus, all that is needed is the seq_is_full() function added, and you
don't need to modify the seq_set_overflow() either. It makes sense for
external functions to know test for seq_is_full() as if
m->count == m->size, they can't write anymore either.
Thanks!
-- Steve
>
> 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 8ea3e90..e19c636 100644
> --- a/Documentation/filesystems/seq_file.txt
> +++ b/Documentation/filesystems/seq_file.txt
> @@ -180,27 +180,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
> @@ -209,6 +205,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_full(struct seq_file *m);
> +and avoid further seq_<output> calls if true is returned.
> +
> +A true return from seq_is_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 3857b72..555aed6 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -16,18 +16,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_full(struct seq_file *m)
> {
> return m->count == m->size;
> }
> +EXPORT_SYMBOL(seq_is_full);
>
> -static void seq_set_overflow(struct seq_file *m)
> +static void seq_set_full(struct seq_file *m)
> {
> m->count = m->size;
> }
> @@ -124,7 +124,7 @@ static int traverse(struct seq_file *m, loff_t offset)
> error = 0;
> m->count = 0;
> }
> - if (seq_overflow(m))
> + if (seq_is_full(m))
> goto Eoverflow;
> if (pos + m->count > offset) {
> m->from = offset - pos;
> @@ -267,7 +267,7 @@ Fill:
> break;
> }
> err = m->op->show(m, p);
> - if (seq_overflow(m) || err) {
> + if (seq_is_full(m) || err) {
> m->count = offs;
> if (likely(err <= 0))
> break;
> @@ -396,7 +396,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_full(m);
> return -1;
> }
> m->count = p - m->buf;
> @@ -415,7 +415,7 @@ int seq_vprintf(struct seq_file *m, const char *f, va_list args)
> return 0;
> }
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
> return -1;
> }
> EXPORT_SYMBOL(seq_vprintf);
> @@ -557,7 +557,7 @@ int seq_bitmap(struct seq_file *m, const unsigned long *bits,
> return 0;
> }
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
> return -1;
> }
> EXPORT_SYMBOL(seq_bitmap);
> @@ -573,7 +573,7 @@ int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
> return 0;
> }
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
> return -1;
> }
> EXPORT_SYMBOL(seq_bitmap_list);
> @@ -702,7 +702,7 @@ int seq_puts(struct seq_file *m, const char *s)
> m->count += len;
> return 0;
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
> return -1;
> }
> EXPORT_SYMBOL(seq_puts);
> @@ -736,7 +736,7 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
> m->count += len;
> return 0;
> overflow:
> - seq_set_overflow(m);
> + seq_set_full(m);
> return -1;
> }
> EXPORT_SYMBOL(seq_put_decimal_ull);
> @@ -746,7 +746,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_full(m);
> return -1;
> }
> if (delimiter)
> @@ -774,7 +774,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_full(seq);
> return -1;
> }
> EXPORT_SYMBOL(seq_write);
> diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
> index 52e0097..1f36da8 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_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_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
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full
2014-09-29 23:44 ` Steven Rostedt
@ 2014-09-29 23:48 ` Joe Perches
0 siblings, 0 replies; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:48 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, Jiri Kosina,
linux-doc, linux-kernel, linux-fsdevel
On Mon, 2014-09-29 at 19:44 -0400, Steven Rostedt wrote:
> On Mon, 29 Sep 2014 16:08:21 -0700 Joe Perches <joe@perches.com> wrote:
> > 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.
[]
> Actually, can you make a separate function that's public that is
> seq_is_full(), where m->count >= m->size, and leave seq_overflow()
> alone.
Change the first patch to suit your taste.
The rest of the series should not need change.
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full
2014-09-29 23:08 ` [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full Joe Perches
2014-09-29 23:44 ` Steven Rostedt
@ 2014-09-30 10:06 ` Petr Mladek
1 sibling, 0 replies; 53+ messages in thread
From: Petr Mladek @ 2014-09-30 10:06 UTC (permalink / raw)
To: Joe Perches
Cc: Steven Rostedt, Al Viro, Andrew Morton, Linus Torvalds,
Jiri Kosina, linux-doc, linux-kernel, linux-fsdevel
On Mon 29-09-14 16:08:21, Joe Perches wrote:
> 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_full. Rename the still static
> seq_set_overflow to seq_set_full.
>
> Update the documentation to not show return types for seq_printf
> et al. Add a description of seq_is_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 8ea3e90..e19c636 100644
> --- a/Documentation/filesystems/seq_file.txt
> +++ b/Documentation/filesystems/seq_file.txt
> @@ -180,27 +180,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
> @@ -209,6 +205,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_full(struct seq_file *m);
> +and avoid further seq_<output> calls if true is returned.
> +
> +A true return from seq_is_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 3857b72..555aed6 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -16,18 +16,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_full(struct seq_file *m)
> {
> return m->count == m->size;
> }
> +EXPORT_SYMBOL(seq_is_full);
>
> -static void seq_set_overflow(struct seq_file *m)
> +static void seq_set_full(struct seq_file *m)
> {
> m->count = m->size;
> }
> @@ -124,7 +124,7 @@ static int traverse(struct seq_file *m, loff_t offset)
> error = 0;
> m->count = 0;
> }
> - if (seq_overflow(m))
> + if (seq_is_full(m))
> goto Eoverflow;
I would keep seq_overflow() here. seq_is_full() should mean that the
data still fit into the buffer.
> if (pos + m->count > offset) {
> m->from = offset - pos;
> @@ -267,7 +267,7 @@ Fill:
> break;
> }
> err = m->op->show(m, p);
> - if (seq_overflow(m) || err) {
> + if (seq_is_full(m) || err) {
same here
> m->count = offs;
> if (likely(err <= 0))
> break;
> @@ -396,7 +396,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_full(m);
I would keep seq_set_overflow() here because the data did not fit in.
> return -1;
> }
> m->count = p - m->buf;
> @@ -415,7 +415,7 @@ int seq_vprintf(struct seq_file *m, const char *f, va_list args)
> return 0;
> }
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
Hmm, we do not know if the data are shrunken by vsnprintf(). I would
keep seq_set_overflow() here to be on the safe side.
> return -1;
> }
> EXPORT_SYMBOL(seq_vprintf);
> @@ -557,7 +557,7 @@ int seq_bitmap(struct seq_file *m, const unsigned long *bits,
> return 0;
> }
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
same here
> return -1;
> }
> EXPORT_SYMBOL(seq_bitmap);
> @@ -573,7 +573,7 @@ int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
> return 0;
> }
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
and here
> return -1;
> }
> EXPORT_SYMBOL(seq_bitmap_list);
> @@ -702,7 +702,7 @@ int seq_puts(struct seq_file *m, const char *s)
> m->count += len;
> return 0;
> }
> - seq_set_overflow(m);
> + seq_set_full(m);
and here
> return -1;
> }
> EXPORT_SYMBOL(seq_puts);
> @@ -736,7 +736,7 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
> m->count += len;
> return 0;
> overflow:
> - seq_set_overflow(m);
> + seq_set_full(m);
We should change one above contition from
if (m->count + 2 >= m->size) /* we'll write 2 bytes at least */
goto overflow;
to
if (m->count + 2 > m->size) /* we'll write 2 bytes at least */
goto overflow;
> return -1;
> }
> EXPORT_SYMBOL(seq_put_decimal_ull);
> @@ -746,7 +746,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_full(m);
> return -1;
We should change this to:
if (m->count + 3 > m->size) {
seq_set_overflow(m);
> }
> if (delimiter)
> @@ -774,7 +774,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_full(seq);
IMHO, the whole function should be:
void seq_write(struct seq_file *seq, const void *data, size_t len)
{
if (seq->count + len <= seq->size) {
memcpy(seq->buf + seq->count, data, len);
seq->count += len;
return 0;
}
seq_set_overflow(seq);
}
I mean that the overflow should be set only when there is a real overflow.
All in all, this patch should depend on the Steven's work and most of
it will be unused.
Best Regards,
Petr
> return -1;
> }
> EXPORT_SYMBOL(seq_write);
> diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
> index 52e0097..1f36da8 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_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_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 [flat|nested] 53+ messages in thread
* [PATCH 2/7] netfilter: Convert print_tuple functions to return void
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
2014-09-29 23:08 ` [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full Joe Perches
@ 2014-09-29 23:08 ` Joe Perches
2014-09-30 10:22 ` Petr Mladek
2014-09-29 23:08 ` [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns Joe Perches
` (5 subsequent siblings)
7 siblings, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
David S. Miller, netfilter-devel, coreteam, netdev, linux-kernel
Since adding a new function to seq_file (seq_is_full)
there isn't any value for functions called from seq_show to
return anything. Remove the int returns of the various
print_tuple/<foo>_print_tuple functions.
Signed-off-by: Joe Perches <joe@perches.com>
---
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 +++++++--------
12 files changed, 46 insertions(+), 49 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index cc0c188..f2f0fa3 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -72,7 +72,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
return ret;
}
-int
+void
print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
const struct nf_conntrack_l3proto *l3proto,
const struct nf_conntrack_l4proto *proto);
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index adc1fa3..cdc920b 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -38,8 +38,8 @@ struct nf_conntrack_l3proto {
const struct nf_conntrack_tuple *orig);
/* Print out the per-protocol part of the tuple. */
- int (*print_tuple)(struct seq_file *s,
- const struct nf_conntrack_tuple *);
+ void (*print_tuple)(struct seq_file *s,
+ const struct nf_conntrack_tuple *);
/*
* Called before tracking.
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index 4c8d573..fead8ee 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -56,8 +56,8 @@ struct nf_conntrack_l4proto {
u_int8_t pf, unsigned int hooknum);
/* Print out the per-protocol part of the tuple. Return like seq_* */
- int (*print_tuple)(struct seq_file *s,
- const struct nf_conntrack_tuple *);
+ void (*print_tuple)(struct seq_file *s,
+ const struct nf_conntrack_tuple *);
/* Print out the private part of the conntrack. */
int (*print_conntrack)(struct seq_file *s, struct nf_conn *);
diff --git a/net/netfilter/nf_conntrack_l3proto_generic.c b/net/netfilter/nf_conntrack_l3proto_generic.c
index e7eb807..cf9ace7 100644
--- a/net/netfilter/nf_conntrack_l3proto_generic.c
+++ b/net/netfilter/nf_conntrack_l3proto_generic.c
@@ -49,10 +49,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
return true;
}
-static int generic_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void generic_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return 0;
}
static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index cb372f9..40d96f9 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -618,12 +618,12 @@ out_invalid:
return -NF_ACCEPT;
}
-static int dccp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void dccp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.dccp.port),
- ntohs(tuple->dst.u.dccp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.dccp.port),
+ ntohs(tuple->dst.u.dccp.port));
}
static int dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
index d25f293..0a3ded1 100644
--- a/net/netfilter/nf_conntrack_proto_generic.c
+++ b/net/netfilter/nf_conntrack_proto_generic.c
@@ -39,10 +39,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int generic_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void generic_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return 0;
}
static unsigned int *generic_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
index d566573..cd85336 100644
--- a/net/netfilter/nf_conntrack_proto_gre.c
+++ b/net/netfilter/nf_conntrack_proto_gre.c
@@ -226,12 +226,12 @@ static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
}
/* print gre part of tuple */
-static int gre_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void gre_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "srckey=0x%x dstkey=0x%x ",
- ntohs(tuple->src.u.gre.key),
- ntohs(tuple->dst.u.gre.key));
+ seq_printf(s, "srckey=0x%x dstkey=0x%x ",
+ ntohs(tuple->src.u.gre.key),
+ ntohs(tuple->dst.u.gre.key));
}
/* print private data for conntrack */
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index 1314d33..1b1d0e9 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -166,12 +166,12 @@ static bool sctp_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int sctp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void sctp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.sctp.port),
- ntohs(tuple->dst.u.sctp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.sctp.port),
+ ntohs(tuple->dst.u.sctp.port));
}
/* Print out the private part of the conntrack. */
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 44d1ea3..c2693e78 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -302,12 +302,12 @@ static bool tcp_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int tcp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void tcp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.tcp.port),
- ntohs(tuple->dst.u.tcp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.tcp.port),
+ ntohs(tuple->dst.u.tcp.port));
}
/* Print out the private part of the conntrack. */
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 9d7721c..6957281 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -63,12 +63,12 @@ static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int udp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void udp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.udp.port),
- ntohs(tuple->dst.u.udp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.udp.port),
+ ntohs(tuple->dst.u.udp.port));
}
static unsigned int *udp_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
index 2750e6c..c5903d1 100644
--- a/net/netfilter/nf_conntrack_proto_udplite.c
+++ b/net/netfilter/nf_conntrack_proto_udplite.c
@@ -71,12 +71,12 @@ static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int udplite_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void udplite_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.udp.port),
- ntohs(tuple->dst.u.udp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.udp.port),
+ ntohs(tuple->dst.u.udp.port));
}
static unsigned int *udplite_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index cf65a1e..3c2ce5c 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -36,12 +36,13 @@
MODULE_LICENSE("GPL");
#ifdef CONFIG_NF_CONNTRACK_PROCFS
-int
+void
print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
const struct nf_conntrack_l3proto *l3proto,
const struct nf_conntrack_l4proto *l4proto)
{
- return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
+ l3proto->print_tuple(s, tuple);
+ l4proto->print_tuple(s, tuple);
}
EXPORT_SYMBOL_GPL(print_tuple);
@@ -202,9 +203,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
goto release;
- if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
- l3proto, l4proto))
- goto release;
+ print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
+ l3proto, l4proto);
if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
goto release;
@@ -213,9 +213,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
if (seq_printf(s, "[UNREPLIED] "))
goto release;
- if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
- l3proto, l4proto))
- goto release;
+ print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
+ l3proto, l4proto);
if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
goto release;
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 53+ messages in thread* Re: [PATCH 2/7] netfilter: Convert print_tuple functions to return void
2014-09-29 23:08 ` [PATCH 2/7] netfilter: Convert print_tuple functions to return void Joe Perches
@ 2014-09-30 10:22 ` Petr Mladek
2014-09-30 13:04 ` Joe Perches
0 siblings, 1 reply; 53+ messages in thread
From: Petr Mladek @ 2014-09-30 10:22 UTC (permalink / raw)
To: Joe Perches
Cc: Steven Rostedt, Al Viro, Andrew Morton, Linus Torvalds,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
David S. Miller, netfilter-devel, coreteam, netdev, linux-kernel
On Mon 29-09-14 16:08:22, Joe Perches wrote:
> Since adding a new function to seq_file (seq_is_full)
> there isn't any value for functions called from seq_show to
> return anything. Remove the int returns of the various
> print_tuple/<foo>_print_tuple functions.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> 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 +++++++--------
> 12 files changed, 46 insertions(+), 49 deletions(-)
>
> diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
> index cc0c188..f2f0fa3 100644
> --- a/include/net/netfilter/nf_conntrack_core.h
> +++ b/include/net/netfilter/nf_conntrack_core.h
> @@ -72,7 +72,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
> return ret;
> }
>
> -int
> +void
> print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
> const struct nf_conntrack_l3proto *l3proto,
> const struct nf_conntrack_l4proto *proto);
> diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
> index adc1fa3..cdc920b 100644
> --- a/include/net/netfilter/nf_conntrack_l3proto.h
> +++ b/include/net/netfilter/nf_conntrack_l3proto.h
> @@ -38,8 +38,8 @@ struct nf_conntrack_l3proto {
> const struct nf_conntrack_tuple *orig);
>
> /* Print out the per-protocol part of the tuple. */
> - int (*print_tuple)(struct seq_file *s,
> - const struct nf_conntrack_tuple *);
> + void (*print_tuple)(struct seq_file *s,
> + const struct nf_conntrack_tuple *);
>
> /*
> * Called before tracking.
> diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
> index 4c8d573..fead8ee 100644
> --- a/include/net/netfilter/nf_conntrack_l4proto.h
> +++ b/include/net/netfilter/nf_conntrack_l4proto.h
> @@ -56,8 +56,8 @@ struct nf_conntrack_l4proto {
> u_int8_t pf, unsigned int hooknum);
>
> /* Print out the per-protocol part of the tuple. Return like seq_* */
> - int (*print_tuple)(struct seq_file *s,
> - const struct nf_conntrack_tuple *);
> + void (*print_tuple)(struct seq_file *s,
> + const struct nf_conntrack_tuple *);
>
> /* Print out the private part of the conntrack. */
> int (*print_conntrack)(struct seq_file *s, struct nf_conn *);
> diff --git a/net/netfilter/nf_conntrack_l3proto_generic.c b/net/netfilter/nf_conntrack_l3proto_generic.c
> index e7eb807..cf9ace7 100644
> --- a/net/netfilter/nf_conntrack_l3proto_generic.c
> +++ b/net/netfilter/nf_conntrack_l3proto_generic.c
> @@ -49,10 +49,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
> return true;
> }
>
> -static int generic_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void generic_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return 0;
> }
>
> static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
> index cb372f9..40d96f9 100644
> --- a/net/netfilter/nf_conntrack_proto_dccp.c
> +++ b/net/netfilter/nf_conntrack_proto_dccp.c
> @@ -618,12 +618,12 @@ out_invalid:
> return -NF_ACCEPT;
> }
>
> -static int dccp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void dccp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.dccp.port),
> - ntohs(tuple->dst.u.dccp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.dccp.port),
> + ntohs(tuple->dst.u.dccp.port));
> }
>
> static int dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
> index d25f293..0a3ded1 100644
> --- a/net/netfilter/nf_conntrack_proto_generic.c
> +++ b/net/netfilter/nf_conntrack_proto_generic.c
> @@ -39,10 +39,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int generic_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void generic_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return 0;
> }
>
> static unsigned int *generic_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
> index d566573..cd85336 100644
> --- a/net/netfilter/nf_conntrack_proto_gre.c
> +++ b/net/netfilter/nf_conntrack_proto_gre.c
> @@ -226,12 +226,12 @@ static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
> }
>
> /* print gre part of tuple */
> -static int gre_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void gre_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "srckey=0x%x dstkey=0x%x ",
> - ntohs(tuple->src.u.gre.key),
> - ntohs(tuple->dst.u.gre.key));
> + seq_printf(s, "srckey=0x%x dstkey=0x%x ",
> + ntohs(tuple->src.u.gre.key),
> + ntohs(tuple->dst.u.gre.key));
> }
>
> /* print private data for conntrack */
> diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
> index 1314d33..1b1d0e9 100644
> --- a/net/netfilter/nf_conntrack_proto_sctp.c
> +++ b/net/netfilter/nf_conntrack_proto_sctp.c
> @@ -166,12 +166,12 @@ static bool sctp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int sctp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void sctp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.sctp.port),
> - ntohs(tuple->dst.u.sctp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.sctp.port),
> + ntohs(tuple->dst.u.sctp.port));
> }
>
> /* Print out the private part of the conntrack. */
> diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
> index 44d1ea3..c2693e78 100644
> --- a/net/netfilter/nf_conntrack_proto_tcp.c
> +++ b/net/netfilter/nf_conntrack_proto_tcp.c
> @@ -302,12 +302,12 @@ static bool tcp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int tcp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void tcp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.tcp.port),
> - ntohs(tuple->dst.u.tcp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.tcp.port),
> + ntohs(tuple->dst.u.tcp.port));
> }
>
> /* Print out the private part of the conntrack. */
> diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
> index 9d7721c..6957281 100644
> --- a/net/netfilter/nf_conntrack_proto_udp.c
> +++ b/net/netfilter/nf_conntrack_proto_udp.c
> @@ -63,12 +63,12 @@ static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int udp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void udp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.udp.port),
> - ntohs(tuple->dst.u.udp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.udp.port),
> + ntohs(tuple->dst.u.udp.port));
> }
>
> static unsigned int *udp_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
> index 2750e6c..c5903d1 100644
> --- a/net/netfilter/nf_conntrack_proto_udplite.c
> +++ b/net/netfilter/nf_conntrack_proto_udplite.c
> @@ -71,12 +71,12 @@ static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int udplite_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void udplite_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.udp.port),
> - ntohs(tuple->dst.u.udp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.udp.port),
> + ntohs(tuple->dst.u.udp.port));
> }
>
> static unsigned int *udplite_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index cf65a1e..3c2ce5c 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -36,12 +36,13 @@
> MODULE_LICENSE("GPL");
>
> #ifdef CONFIG_NF_CONNTRACK_PROCFS
> -int
> +void
> print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
> const struct nf_conntrack_l3proto *l3proto,
> const struct nf_conntrack_l4proto *l4proto)
> {
> - return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
> + l3proto->print_tuple(s, tuple);
> + l4proto->print_tuple(s, tuple);
> }
> EXPORT_SYMBOL_GPL(print_tuple);
>
> @@ -202,9 +203,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> - l3proto, l4proto))
> - goto release;
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> + l3proto, l4proto);
To be precise, we should add:
if (seq_overflow(s))
goto release;
> if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
> goto release;
> @@ -213,9 +213,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (seq_printf(s, "[UNREPLIED] "))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> - l3proto, l4proto))
> - goto release;
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> + l3proto, l4proto);
same here
> if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
> goto release;
> --
> 1.8.1.2.459.gbcd45b4.dirty
>
Best Regards,
Petr
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 2/7] netfilter: Convert print_tuple functions to return void
2014-09-30 10:22 ` Petr Mladek
@ 2014-09-30 13:04 ` Joe Perches
0 siblings, 0 replies; 53+ messages in thread
From: Joe Perches @ 2014-09-30 13:04 UTC (permalink / raw)
To: Petr Mladek
Cc: Steven Rostedt, Al Viro, Andrew Morton, Linus Torvalds,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
David S. Miller, netfilter-devel, coreteam, netdev, linux-kernel
On Tue, 2014-09-30 at 12:22 +0200, Petr Mladek wrote:
> On Mon 29-09-14 16:08:22, Joe Perches wrote:
> > Since adding a new function to seq_file (seq_is_full)
> > there isn't any value for functions called from seq_show to
> > return anything. Remove the int returns of the various
> > print_tuple/<foo>_print_tuple functions.
[a bunch of quoted stuff]
Please remember to cut out from your replies the unnecessary old stuff.
It can take quite awhile to scan through looking for your comments.
> > diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
[]
> > @@ -202,9 +203,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> > if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> > goto release;
> >
> > - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> > - l3proto, l4proto))
> > - goto release;
> > + print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> > + l3proto, l4proto);
>
> To be precise, we should add:
>
> if (seq_overflow(s))
> goto release;
Precision isn't all that useful when checking seq_<output>.
There really isn't much value in checking each possible
overflow site. A periodic check prior to or in the middle
of a more costly/longish operation should be acceptable.
The entire block that precedes any seq buffer full test will
be redone when the buffer is expanded.
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
2014-09-29 23:08 ` [PATCH 1/7] seq_file: Rename static bool seq_overflow to public bool seq_is_full Joe Perches
2014-09-29 23:08 ` [PATCH 2/7] netfilter: Convert print_tuple functions to return void Joe Perches
@ 2014-09-29 23:08 ` Joe Perches
2014-09-30 10:34 ` Petr Mladek
2014-09-29 23:08 ` [PATCH 4/7] dlm: Use seq_puts, remove unnecessary trailing spaces Joe Perches
` (4 subsequent siblings)
7 siblings, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Christine Caulfield, David Teigland, cluster-devel, linux-kernel
The seq_printf return should be ignored and the
seq_is_full function should be tested instead.
Convert functions returning int to void where
seq_printf is used.
Signed-off-by: Joe Perches <joe@perches.com>
---
fs/dlm/debug_fs.c | 248 +++++++++++++++++++++++++-----------------------------
1 file changed, 116 insertions(+), 132 deletions(-)
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 1323c56..27c8335 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -48,8 +48,8 @@ static char *print_lockmode(int mode)
}
}
-static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
- struct dlm_rsb *res)
+static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
+ struct dlm_rsb *res)
{
seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode));
@@ -68,21 +68,17 @@ static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
if (lkb->lkb_wait_type)
seq_printf(s, " wait_type: %d", lkb->lkb_wait_type);
- return seq_puts(s, "\n");
+ seq_puts(s, "\n");
}
-static int print_format1(struct dlm_rsb *res, struct seq_file *s)
+static void print_format1(struct dlm_rsb *res, struct seq_file *s)
{
struct dlm_lkb *lkb;
int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list;
- int rv;
lock_rsb(res);
- rv = seq_printf(s, "\nResource %p Name (len=%d) \"",
- res, res->res_length);
- if (rv)
- goto out;
+ seq_printf(s, "\nResource %p Name (len=%d) \"", res, res->res_length);
for (i = 0; i < res->res_length; i++) {
if (isprint(res->res_name[i]))
@@ -92,17 +88,16 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
}
if (res->res_nodeid > 0)
- rv = seq_printf(s, "\"\nLocal Copy, Master is node %d\n",
- res->res_nodeid);
+ seq_printf(s, "\"\nLocal Copy, Master is node %d\n",
+ res->res_nodeid);
else if (res->res_nodeid == 0)
- rv = seq_puts(s, "\"\nMaster Copy\n");
+ seq_puts(s, "\"\nMaster Copy\n");
else if (res->res_nodeid == -1)
- rv = seq_printf(s, "\"\nLooking up master (lkid %x)\n",
- res->res_first_lkid);
+ seq_printf(s, "\"\nLooking up master (lkid %x)\n",
+ res->res_first_lkid);
else
- rv = seq_printf(s, "\"\nInvalid master %d\n",
- res->res_nodeid);
- if (rv)
+ seq_printf(s, "\"\nInvalid master %d\n", res->res_nodeid);
+ if (seq_is_full(s))
goto out;
/* Print the LVB: */
@@ -116,8 +111,8 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
}
if (rsb_flag(res, RSB_VALNOTVALID))
seq_puts(s, " (INVALID)");
- rv = seq_puts(s, "\n");
- if (rv)
+ seq_puts(s, "\n");
+ if (seq_is_full(s))
goto out;
}
@@ -125,32 +120,30 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
recover_list = !list_empty(&res->res_recover_list);
if (root_list || recover_list) {
- rv = seq_printf(s, "Recovery: root %d recover %d flags %lx "
- "count %d\n", root_list, recover_list,
- res->res_flags, res->res_recover_locks_count);
- if (rv)
- goto out;
+ seq_printf(s, "Recovery: root %d recover %d flags %lx count %d\n",
+ root_list, recover_list,
+ res->res_flags, res->res_recover_locks_count);
}
/* Print the locks attached to this resource */
seq_puts(s, "Granted Queue\n");
list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) {
- rv = print_format1_lock(s, lkb, res);
- if (rv)
+ print_format1_lock(s, lkb, res);
+ if (seq_is_full(s))
goto out;
}
seq_puts(s, "Conversion Queue\n");
list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) {
- rv = print_format1_lock(s, lkb, res);
- if (rv)
+ print_format1_lock(s, lkb, res);
+ if (seq_is_full(s))
goto out;
}
seq_puts(s, "Waiting Queue\n");
list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) {
- rv = print_format1_lock(s, lkb, res);
- if (rv)
+ print_format1_lock(s, lkb, res);
+ if (seq_is_full(s))
goto out;
}
@@ -159,23 +152,23 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
seq_puts(s, "Lookup Queue\n");
list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) {
- rv = seq_printf(s, "%08x %s", lkb->lkb_id,
- print_lockmode(lkb->lkb_rqmode));
+ seq_printf(s, "%08x %s",
+ lkb->lkb_id, print_lockmode(lkb->lkb_rqmode));
if (lkb->lkb_wait_type)
seq_printf(s, " wait_type: %d", lkb->lkb_wait_type);
- rv = seq_puts(s, "\n");
+ seq_puts(s, "\n");
+ if (seq_is_full(s))
+ goto out;
}
out:
unlock_rsb(res);
- return rv;
}
-static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
- struct dlm_rsb *r)
+static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
+ struct dlm_rsb *r)
{
u64 xid = 0;
u64 us;
- int rv;
if (lkb->lkb_flags & DLM_IFL_USER) {
if (lkb->lkb_ua)
@@ -188,103 +181,97 @@ static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
/* id nodeid remid pid xid exflags flags sts grmode rqmode time_us
r_nodeid r_len r_name */
- rv = seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
- lkb->lkb_id,
- lkb->lkb_nodeid,
- lkb->lkb_remid,
- lkb->lkb_ownpid,
- (unsigned long long)xid,
- lkb->lkb_exflags,
- lkb->lkb_flags,
- lkb->lkb_status,
- lkb->lkb_grmode,
- lkb->lkb_rqmode,
- (unsigned long long)us,
- r->res_nodeid,
- r->res_length,
- r->res_name);
- return rv;
+ seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
+ lkb->lkb_id,
+ lkb->lkb_nodeid,
+ lkb->lkb_remid,
+ lkb->lkb_ownpid,
+ (unsigned long long)xid,
+ lkb->lkb_exflags,
+ lkb->lkb_flags,
+ lkb->lkb_status,
+ lkb->lkb_grmode,
+ lkb->lkb_rqmode,
+ (unsigned long long)us,
+ r->res_nodeid,
+ r->res_length,
+ r->res_name);
}
-static int print_format2(struct dlm_rsb *r, struct seq_file *s)
+static void print_format2(struct dlm_rsb *r, struct seq_file *s)
{
struct dlm_lkb *lkb;
- int rv = 0;
lock_rsb(r);
list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
- rv = print_format2_lock(s, lkb, r);
- if (rv)
+ print_format2_lock(s, lkb, r);
+ if (seq_is_full(s))
goto out;
}
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
- rv = print_format2_lock(s, lkb, r);
- if (rv)
+ print_format2_lock(s, lkb, r);
+ if (seq_is_full(s))
goto out;
}
list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) {
- rv = print_format2_lock(s, lkb, r);
- if (rv)
+ print_format2_lock(s, lkb, r);
+ if (seq_is_full(s))
goto out;
}
out:
unlock_rsb(r);
- return rv;
}
-static int print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
+static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
int rsb_lookup)
{
u64 xid = 0;
- int rv;
if (lkb->lkb_flags & DLM_IFL_USER) {
if (lkb->lkb_ua)
xid = lkb->lkb_ua->xid;
}
- rv = seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n",
- lkb->lkb_id,
- lkb->lkb_nodeid,
- lkb->lkb_remid,
- lkb->lkb_ownpid,
- (unsigned long long)xid,
- lkb->lkb_exflags,
- lkb->lkb_flags,
- lkb->lkb_status,
- lkb->lkb_grmode,
- lkb->lkb_rqmode,
- lkb->lkb_last_bast.mode,
- rsb_lookup,
- lkb->lkb_wait_type,
- lkb->lkb_lvbseq,
- (unsigned long long)ktime_to_ns(lkb->lkb_timestamp),
- (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time));
- return rv;
+ seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n",
+ lkb->lkb_id,
+ lkb->lkb_nodeid,
+ lkb->lkb_remid,
+ lkb->lkb_ownpid,
+ (unsigned long long)xid,
+ lkb->lkb_exflags,
+ lkb->lkb_flags,
+ lkb->lkb_status,
+ lkb->lkb_grmode,
+ lkb->lkb_rqmode,
+ lkb->lkb_last_bast.mode,
+ rsb_lookup,
+ lkb->lkb_wait_type,
+ lkb->lkb_lvbseq,
+ (unsigned long long)ktime_to_ns(lkb->lkb_timestamp),
+ (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time));
}
-static int print_format3(struct dlm_rsb *r, struct seq_file *s)
+static void print_format3(struct dlm_rsb *r, struct seq_file *s)
{
struct dlm_lkb *lkb;
int i, lvblen = r->res_ls->ls_lvblen;
int print_name = 1;
- int rv;
lock_rsb(r);
- rv = seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ",
- r,
- r->res_nodeid,
- r->res_first_lkid,
- r->res_flags,
- !list_empty(&r->res_root_list),
- !list_empty(&r->res_recover_list),
- r->res_recover_locks_count,
- r->res_length);
- if (rv)
+ seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ",
+ r,
+ r->res_nodeid,
+ r->res_first_lkid,
+ r->res_flags,
+ !list_empty(&r->res_root_list),
+ !list_empty(&r->res_recover_list),
+ r->res_recover_locks_count,
+ r->res_length);
+ if (seq_is_full(s))
goto out;
for (i = 0; i < r->res_length; i++) {
@@ -300,8 +287,8 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
else
seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
}
- rv = seq_puts(s, "\n");
- if (rv)
+ seq_puts(s, "\n");
+ if (seq_is_full(s))
goto out;
if (!r->res_lvbptr)
@@ -311,58 +298,55 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
for (i = 0; i < lvblen; i++)
seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]);
- rv = seq_puts(s, "\n");
- if (rv)
+ seq_puts(s, "\n");
+ if (seq_is_full(s))
goto out;
do_locks:
list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
- rv = print_format3_lock(s, lkb, 0);
- if (rv)
+ print_format3_lock(s, lkb, 0);
+ if (seq_is_full(s))
goto out;
}
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
- rv = print_format3_lock(s, lkb, 0);
- if (rv)
+ print_format3_lock(s, lkb, 0);
+ if (seq_is_full(s))
goto out;
}
list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) {
- rv = print_format3_lock(s, lkb, 0);
- if (rv)
+ print_format3_lock(s, lkb, 0);
+ if (seq_is_full(s))
goto out;
}
list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) {
- rv = print_format3_lock(s, lkb, 1);
- if (rv)
+ print_format3_lock(s, lkb, 1);
+ if (seq_is_full(s))
goto out;
}
out:
unlock_rsb(r);
- return rv;
}
-static int print_format4(struct dlm_rsb *r, struct seq_file *s)
+static void print_format4(struct dlm_rsb *r, struct seq_file *s)
{
int our_nodeid = dlm_our_nodeid();
int print_name = 1;
- int i, rv;
+ int i;
lock_rsb(r);
- rv = seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ",
- r,
- r->res_nodeid,
- r->res_master_nodeid,
- r->res_dir_nodeid,
- our_nodeid,
- r->res_toss_time,
- r->res_flags,
- r->res_length);
- if (rv)
- goto out;
+ seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ",
+ r,
+ r->res_nodeid,
+ r->res_master_nodeid,
+ r->res_dir_nodeid,
+ our_nodeid,
+ r->res_toss_time,
+ r->res_flags,
+ r->res_length);
for (i = 0; i < r->res_length; i++) {
if (!isascii(r->res_name[i]) || !isprint(r->res_name[i]))
@@ -377,10 +361,9 @@ static int print_format4(struct dlm_rsb *r, struct seq_file *s)
else
seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
}
- rv = seq_puts(s, "\n");
- out:
+ seq_puts(s, "\n");
+
unlock_rsb(r);
- return rv;
}
struct rsbtbl_iter {
@@ -390,11 +373,12 @@ struct rsbtbl_iter {
int header;
};
-/* seq_printf returns -1 if the buffer is full, and 0 otherwise.
- If the buffer is full, seq_printf can be called again, but it
- does nothing and just returns -1. So, the these printing routines
- periodically check the return value to avoid wasting too much time
- trying to print to a full buffer. */
+/*
+ * If the buffer is full, seq_printf can be called again, but it
+ * does nothing. So, the these printing routines periodically check
+ * seq_is_full to avoid wasting too much time trying to print to
+ * a full buffer.
+ */
static int table_seq_show(struct seq_file *seq, void *iter_ptr)
{
@@ -403,7 +387,7 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
switch (ri->format) {
case 1:
- rv = print_format1(ri->rsb, seq);
+ print_format1(ri->rsb, seq);
break;
case 2:
if (ri->header) {
@@ -412,21 +396,21 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
"r_nodeid r_len r_name\n");
ri->header = 0;
}
- rv = print_format2(ri->rsb, seq);
+ print_format2(ri->rsb, seq);
break;
case 3:
if (ri->header) {
seq_printf(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n");
ri->header = 0;
}
- rv = print_format3(ri->rsb, seq);
+ print_format3(ri->rsb, seq);
break;
case 4:
if (ri->header) {
seq_printf(seq, "version 4 rsb 2\n");
ri->header = 0;
}
- rv = print_format4(ri->rsb, seq);
+ print_format4(ri->rsb, seq);
break;
}
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 53+ messages in thread* Re: [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns
2014-09-29 23:08 ` [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns Joe Perches
@ 2014-09-30 10:34 ` Petr Mladek
2014-10-27 20:17 ` Steven Rostedt
0 siblings, 1 reply; 53+ messages in thread
From: Petr Mladek @ 2014-09-30 10:34 UTC (permalink / raw)
To: Joe Perches
Cc: Steven Rostedt, Al Viro, Andrew Morton, Linus Torvalds,
Christine Caulfield, David Teigland, cluster-devel, linux-kernel
On Mon 29-09-14 16:08:23, Joe Perches wrote:
> The seq_printf return should be ignored and the
> seq_is_full function should be tested instead.
>
> Convert functions returning int to void where
> seq_printf is used.
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> fs/dlm/debug_fs.c | 248 +++++++++++++++++++++++++-----------------------------
> 1 file changed, 116 insertions(+), 132 deletions(-)
>
> diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
> index 1323c56..27c8335 100644
> --- a/fs/dlm/debug_fs.c
> +++ b/fs/dlm/debug_fs.c
> @@ -48,8 +48,8 @@ static char *print_lockmode(int mode)
> }
> }
>
> -static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
> - struct dlm_rsb *res)
> +static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
> + struct dlm_rsb *res)
> {
> seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode));
>
> @@ -68,21 +68,17 @@ static int print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb,
> if (lkb->lkb_wait_type)
> seq_printf(s, " wait_type: %d", lkb->lkb_wait_type);
>
> - return seq_puts(s, "\n");
> + seq_puts(s, "\n");
> }
>
> -static int print_format1(struct dlm_rsb *res, struct seq_file *s)
> +static void print_format1(struct dlm_rsb *res, struct seq_file *s)
> {
> struct dlm_lkb *lkb;
> int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list;
> - int rv;
>
> lock_rsb(res);
>
> - rv = seq_printf(s, "\nResource %p Name (len=%d) \"",
> - res, res->res_length);
> - if (rv)
> - goto out;
> + seq_printf(s, "\nResource %p Name (len=%d) \"", res, res->res_length);
To keep the functionality, we should add
if(seq_overflow(s))
goto out;
> for (i = 0; i < res->res_length; i++) {
> if (isprint(res->res_name[i]))
> @@ -92,17 +88,16 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
> }
>
> if (res->res_nodeid > 0)
> - rv = seq_printf(s, "\"\nLocal Copy, Master is node %d\n",
> - res->res_nodeid);
> + seq_printf(s, "\"\nLocal Copy, Master is node %d\n",
> + res->res_nodeid);
> else if (res->res_nodeid == 0)
> - rv = seq_puts(s, "\"\nMaster Copy\n");
> + seq_puts(s, "\"\nMaster Copy\n");
> else if (res->res_nodeid == -1)
> - rv = seq_printf(s, "\"\nLooking up master (lkid %x)\n",
> - res->res_first_lkid);
> + seq_printf(s, "\"\nLooking up master (lkid %x)\n",
> + res->res_first_lkid);
> else
> - rv = seq_printf(s, "\"\nInvalid master %d\n",
> - res->res_nodeid);
> - if (rv)
> + seq_printf(s, "\"\nInvalid master %d\n", res->res_nodeid);
> + if (seq_is_full(s))
> goto out;
I would check for seq_overflow()
Etc. There are needed many more changes if we agree on introducing
seq_is_full() and seq_overflow().
Well, we will need to touch most of these locations once again when
Steven removes return value from all the seq_* functions.
Best Regards,
Petr
> /* Print the LVB: */
> @@ -116,8 +111,8 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
> }
> if (rsb_flag(res, RSB_VALNOTVALID))
> seq_puts(s, " (INVALID)");
> - rv = seq_puts(s, "\n");
> - if (rv)
> + seq_puts(s, "\n");
> + if (seq_is_full(s))
> goto out;
> }
>
> @@ -125,32 +120,30 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
> recover_list = !list_empty(&res->res_recover_list);
>
> if (root_list || recover_list) {
> - rv = seq_printf(s, "Recovery: root %d recover %d flags %lx "
> - "count %d\n", root_list, recover_list,
> - res->res_flags, res->res_recover_locks_count);
> - if (rv)
> - goto out;
> + seq_printf(s, "Recovery: root %d recover %d flags %lx count %d\n",
> + root_list, recover_list,
> + res->res_flags, res->res_recover_locks_count);
> }
>
> /* Print the locks attached to this resource */
> seq_puts(s, "Granted Queue\n");
> list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) {
> - rv = print_format1_lock(s, lkb, res);
> - if (rv)
> + print_format1_lock(s, lkb, res);
> + if (seq_is_full(s))
> goto out;
> }
>
> seq_puts(s, "Conversion Queue\n");
> list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) {
> - rv = print_format1_lock(s, lkb, res);
> - if (rv)
> + print_format1_lock(s, lkb, res);
> + if (seq_is_full(s))
> goto out;
> }
>
> seq_puts(s, "Waiting Queue\n");
> list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) {
> - rv = print_format1_lock(s, lkb, res);
> - if (rv)
> + print_format1_lock(s, lkb, res);
> + if (seq_is_full(s))
> goto out;
> }
>
> @@ -159,23 +152,23 @@ static int print_format1(struct dlm_rsb *res, struct seq_file *s)
>
> seq_puts(s, "Lookup Queue\n");
> list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) {
> - rv = seq_printf(s, "%08x %s", lkb->lkb_id,
> - print_lockmode(lkb->lkb_rqmode));
> + seq_printf(s, "%08x %s",
> + lkb->lkb_id, print_lockmode(lkb->lkb_rqmode));
> if (lkb->lkb_wait_type)
> seq_printf(s, " wait_type: %d", lkb->lkb_wait_type);
> - rv = seq_puts(s, "\n");
> + seq_puts(s, "\n");
> + if (seq_is_full(s))
> + goto out;
> }
> out:
> unlock_rsb(res);
> - return rv;
> }
>
> -static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
> - struct dlm_rsb *r)
> +static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
> + struct dlm_rsb *r)
> {
> u64 xid = 0;
> u64 us;
> - int rv;
>
> if (lkb->lkb_flags & DLM_IFL_USER) {
> if (lkb->lkb_ua)
> @@ -188,103 +181,97 @@ static int print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb,
> /* id nodeid remid pid xid exflags flags sts grmode rqmode time_us
> r_nodeid r_len r_name */
>
> - rv = seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
> - lkb->lkb_id,
> - lkb->lkb_nodeid,
> - lkb->lkb_remid,
> - lkb->lkb_ownpid,
> - (unsigned long long)xid,
> - lkb->lkb_exflags,
> - lkb->lkb_flags,
> - lkb->lkb_status,
> - lkb->lkb_grmode,
> - lkb->lkb_rqmode,
> - (unsigned long long)us,
> - r->res_nodeid,
> - r->res_length,
> - r->res_name);
> - return rv;
> + seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\"\n",
> + lkb->lkb_id,
> + lkb->lkb_nodeid,
> + lkb->lkb_remid,
> + lkb->lkb_ownpid,
> + (unsigned long long)xid,
> + lkb->lkb_exflags,
> + lkb->lkb_flags,
> + lkb->lkb_status,
> + lkb->lkb_grmode,
> + lkb->lkb_rqmode,
> + (unsigned long long)us,
> + r->res_nodeid,
> + r->res_length,
> + r->res_name);
> }
>
> -static int print_format2(struct dlm_rsb *r, struct seq_file *s)
> +static void print_format2(struct dlm_rsb *r, struct seq_file *s)
> {
> struct dlm_lkb *lkb;
> - int rv = 0;
>
> lock_rsb(r);
>
> list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
> - rv = print_format2_lock(s, lkb, r);
> - if (rv)
> + print_format2_lock(s, lkb, r);
> + if (seq_is_full(s))
> goto out;
> }
>
> list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
> - rv = print_format2_lock(s, lkb, r);
> - if (rv)
> + print_format2_lock(s, lkb, r);
> + if (seq_is_full(s))
> goto out;
> }
>
> list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) {
> - rv = print_format2_lock(s, lkb, r);
> - if (rv)
> + print_format2_lock(s, lkb, r);
> + if (seq_is_full(s))
> goto out;
> }
> out:
> unlock_rsb(r);
> - return rv;
> }
>
> -static int print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
> +static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb,
> int rsb_lookup)
> {
> u64 xid = 0;
> - int rv;
>
> if (lkb->lkb_flags & DLM_IFL_USER) {
> if (lkb->lkb_ua)
> xid = lkb->lkb_ua->xid;
> }
>
> - rv = seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n",
> - lkb->lkb_id,
> - lkb->lkb_nodeid,
> - lkb->lkb_remid,
> - lkb->lkb_ownpid,
> - (unsigned long long)xid,
> - lkb->lkb_exflags,
> - lkb->lkb_flags,
> - lkb->lkb_status,
> - lkb->lkb_grmode,
> - lkb->lkb_rqmode,
> - lkb->lkb_last_bast.mode,
> - rsb_lookup,
> - lkb->lkb_wait_type,
> - lkb->lkb_lvbseq,
> - (unsigned long long)ktime_to_ns(lkb->lkb_timestamp),
> - (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time));
> - return rv;
> + seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu\n",
> + lkb->lkb_id,
> + lkb->lkb_nodeid,
> + lkb->lkb_remid,
> + lkb->lkb_ownpid,
> + (unsigned long long)xid,
> + lkb->lkb_exflags,
> + lkb->lkb_flags,
> + lkb->lkb_status,
> + lkb->lkb_grmode,
> + lkb->lkb_rqmode,
> + lkb->lkb_last_bast.mode,
> + rsb_lookup,
> + lkb->lkb_wait_type,
> + lkb->lkb_lvbseq,
> + (unsigned long long)ktime_to_ns(lkb->lkb_timestamp),
> + (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time));
> }
>
> -static int print_format3(struct dlm_rsb *r, struct seq_file *s)
> +static void print_format3(struct dlm_rsb *r, struct seq_file *s)
> {
> struct dlm_lkb *lkb;
> int i, lvblen = r->res_ls->ls_lvblen;
> int print_name = 1;
> - int rv;
>
> lock_rsb(r);
>
> - rv = seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ",
> - r,
> - r->res_nodeid,
> - r->res_first_lkid,
> - r->res_flags,
> - !list_empty(&r->res_root_list),
> - !list_empty(&r->res_recover_list),
> - r->res_recover_locks_count,
> - r->res_length);
> - if (rv)
> + seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ",
> + r,
> + r->res_nodeid,
> + r->res_first_lkid,
> + r->res_flags,
> + !list_empty(&r->res_root_list),
> + !list_empty(&r->res_recover_list),
> + r->res_recover_locks_count,
> + r->res_length);
> + if (seq_is_full(s))
> goto out;
>
> for (i = 0; i < r->res_length; i++) {
> @@ -300,8 +287,8 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
> else
> seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
> }
> - rv = seq_puts(s, "\n");
> - if (rv)
> + seq_puts(s, "\n");
> + if (seq_is_full(s))
> goto out;
>
> if (!r->res_lvbptr)
> @@ -311,58 +298,55 @@ static int print_format3(struct dlm_rsb *r, struct seq_file *s)
>
> for (i = 0; i < lvblen; i++)
> seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]);
> - rv = seq_puts(s, "\n");
> - if (rv)
> + seq_puts(s, "\n");
> + if (seq_is_full(s))
> goto out;
>
> do_locks:
> list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) {
> - rv = print_format3_lock(s, lkb, 0);
> - if (rv)
> + print_format3_lock(s, lkb, 0);
> + if (seq_is_full(s))
> goto out;
> }
>
> list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) {
> - rv = print_format3_lock(s, lkb, 0);
> - if (rv)
> + print_format3_lock(s, lkb, 0);
> + if (seq_is_full(s))
> goto out;
> }
>
> list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) {
> - rv = print_format3_lock(s, lkb, 0);
> - if (rv)
> + print_format3_lock(s, lkb, 0);
> + if (seq_is_full(s))
> goto out;
> }
>
> list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) {
> - rv = print_format3_lock(s, lkb, 1);
> - if (rv)
> + print_format3_lock(s, lkb, 1);
> + if (seq_is_full(s))
> goto out;
> }
> out:
> unlock_rsb(r);
> - return rv;
> }
>
> -static int print_format4(struct dlm_rsb *r, struct seq_file *s)
> +static void print_format4(struct dlm_rsb *r, struct seq_file *s)
> {
> int our_nodeid = dlm_our_nodeid();
> int print_name = 1;
> - int i, rv;
> + int i;
>
> lock_rsb(r);
>
> - rv = seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ",
> - r,
> - r->res_nodeid,
> - r->res_master_nodeid,
> - r->res_dir_nodeid,
> - our_nodeid,
> - r->res_toss_time,
> - r->res_flags,
> - r->res_length);
> - if (rv)
> - goto out;
> + seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ",
> + r,
> + r->res_nodeid,
> + r->res_master_nodeid,
> + r->res_dir_nodeid,
> + our_nodeid,
> + r->res_toss_time,
> + r->res_flags,
> + r->res_length);
>
> for (i = 0; i < r->res_length; i++) {
> if (!isascii(r->res_name[i]) || !isprint(r->res_name[i]))
> @@ -377,10 +361,9 @@ static int print_format4(struct dlm_rsb *r, struct seq_file *s)
> else
> seq_printf(s, " %02x", (unsigned char)r->res_name[i]);
> }
> - rv = seq_puts(s, "\n");
> - out:
> + seq_puts(s, "\n");
> +
> unlock_rsb(r);
> - return rv;
> }
>
> struct rsbtbl_iter {
> @@ -390,11 +373,12 @@ struct rsbtbl_iter {
> int header;
> };
>
> -/* seq_printf returns -1 if the buffer is full, and 0 otherwise.
> - If the buffer is full, seq_printf can be called again, but it
> - does nothing and just returns -1. So, the these printing routines
> - periodically check the return value to avoid wasting too much time
> - trying to print to a full buffer. */
> +/*
> + * If the buffer is full, seq_printf can be called again, but it
> + * does nothing. So, the these printing routines periodically check
> + * seq_is_full to avoid wasting too much time trying to print to
> + * a full buffer.
> + */
>
> static int table_seq_show(struct seq_file *seq, void *iter_ptr)
> {
> @@ -403,7 +387,7 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
>
> switch (ri->format) {
> case 1:
> - rv = print_format1(ri->rsb, seq);
> + print_format1(ri->rsb, seq);
> break;
> case 2:
> if (ri->header) {
> @@ -412,21 +396,21 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
> "r_nodeid r_len r_name\n");
> ri->header = 0;
> }
> - rv = print_format2(ri->rsb, seq);
> + print_format2(ri->rsb, seq);
> break;
> case 3:
> if (ri->header) {
> seq_printf(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n");
> ri->header = 0;
> }
> - rv = print_format3(ri->rsb, seq);
> + print_format3(ri->rsb, seq);
> break;
> case 4:
> if (ri->header) {
> seq_printf(seq, "version 4 rsb 2\n");
> ri->header = 0;
> }
> - rv = print_format4(ri->rsb, seq);
> + print_format4(ri->rsb, seq);
> break;
> }
>
> --
> 1.8.1.2.459.gbcd45b4.dirty
>
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns
2014-09-30 10:34 ` Petr Mladek
@ 2014-10-27 20:17 ` Steven Rostedt
2014-10-27 20:25 ` Joe Perches
2014-10-29 12:21 ` Petr Mladek
0 siblings, 2 replies; 53+ messages in thread
From: Steven Rostedt @ 2014-10-27 20:17 UTC (permalink / raw)
To: Petr Mladek
Cc: Joe Perches, Al Viro, Andrew Morton, Linus Torvalds,
Christine Caulfield, David Teigland, cluster-devel, linux-kernel
Note, I've started with Joe's patches and I'm massaging them for
something I can work with.
On Tue, 30 Sep 2014 12:34:35 +0200
Petr Mladek <pmladek@suse.cz> wrote:
> > - rv = seq_printf(s, "\"\nInvalid master %d\n",
> > - res->res_nodeid);
> > - if (rv)
> > + seq_printf(s, "\"\nInvalid master %d\n", res->res_nodeid);
> > + if (seq_is_full(s))
> > goto out;
>
> I would check for seq_overflow()
>
> Etc. There are needed many more changes if we agree on introducing
> seq_is_full() and seq_overflow().
As I'm looking at this code, I'm thinking that we never
really care about seq_is_full(). We only really care if
seq_overflowed(), in which the contents will be discarded.
Rational? Because if we break when seq_is_full(), my new logic wont
throw away the result. If we break out of the function when it's full
and not when it has overflowed, then we may never print out the rest of
the content, as the seq_file code will still use a full buffer that
hasn't overflowed.
I'm thinking of switching everything to use seq_has_overflowed() and
try again.
Thoughts?
-- Steve
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns
2014-10-27 20:17 ` Steven Rostedt
@ 2014-10-27 20:25 ` Joe Perches
2014-10-29 12:21 ` Petr Mladek
1 sibling, 0 replies; 53+ messages in thread
From: Joe Perches @ 2014-10-27 20:25 UTC (permalink / raw)
To: Steven Rostedt
Cc: Petr Mladek, Al Viro, Andrew Morton, Linus Torvalds,
Christine Caulfield, David Teigland, cluster-devel, linux-kernel
On Mon, 2014-10-27 at 16:17 -0400, Steven Rostedt wrote:
> Note, I've started with Joe's patches and I'm massaging them for
> something I can work with.
[]
> I'm thinking of switching everything to use seq_has_overflowed() and
> try again.
Fine by me.
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns
2014-10-27 20:17 ` Steven Rostedt
2014-10-27 20:25 ` Joe Perches
@ 2014-10-29 12:21 ` Petr Mladek
1 sibling, 0 replies; 53+ messages in thread
From: Petr Mladek @ 2014-10-29 12:21 UTC (permalink / raw)
To: Steven Rostedt
Cc: Joe Perches, Al Viro, Andrew Morton, Linus Torvalds,
Christine Caulfield, David Teigland, cluster-devel, linux-kernel
On Mon 2014-10-27 16:17:24, Steven Rostedt wrote:
> Note, I've started with Joe's patches and I'm massaging them for
> something I can work with.
>
> On Tue, 30 Sep 2014 12:34:35 +0200
> Petr Mladek <pmladek@suse.cz> wrote:
>
>
> > > - rv = seq_printf(s, "\"\nInvalid master %d\n",
> > > - res->res_nodeid);
> > > - if (rv)
> > > + seq_printf(s, "\"\nInvalid master %d\n", res->res_nodeid);
> > > + if (seq_is_full(s))
> > > goto out;
> >
> > I would check for seq_overflow()
> >
> > Etc. There are needed many more changes if we agree on introducing
> > seq_is_full() and seq_overflow().
>
> As I'm looking at this code, I'm thinking that we never
> really care about seq_is_full(). We only really care if
> seq_overflowed(), in which the contents will be discarded.
>
> Rational? Because if we break when seq_is_full(), my new logic wont
> throw away the result. If we break out of the function when it's full
> and not when it has overflowed, then we may never print out the rest of
> the content, as the seq_file code will still use a full buffer that
> hasn't overflowed.
>
> I'm thinking of switching everything to use seq_has_overflowed() and
> try again.
>
> Thoughts?
Sounds good to me.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH 4/7] dlm: Use seq_puts, remove unnecessary trailing spaces
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
` (2 preceding siblings ...)
2014-09-29 23:08 ` [PATCH 3/7] dlm: Use seq_is_full - remove seq_printf returns Joe Perches
@ 2014-09-29 23:08 ` Joe Perches
2014-09-29 23:08 ` [PATCH 5/7] fs: Convert show_fdinfo functions to void Joe Perches
` (3 subsequent siblings)
7 siblings, 0 replies; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Christine Caulfield, David Teigland, cluster-devel, linux-kernel
Convert the seq_printf output with constant strings to seq_puts.
Remove unnecessary trailing spaces from seq_(printf/puts) output.
Signed-off-by: Joe Perches <joe@perches.com>
---
fs/dlm/debug_fs.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index 27c8335..c69a766 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -279,7 +279,7 @@ static void print_format3(struct dlm_rsb *r, struct seq_file *s)
print_name = 0;
}
- seq_printf(s, "%s", print_name ? "str " : "hex");
+ seq_puts(s, print_name ? "str " : "hex");
for (i = 0; i < r->res_length; i++) {
if (print_name)
@@ -353,7 +353,7 @@ static void print_format4(struct dlm_rsb *r, struct seq_file *s)
print_name = 0;
}
- seq_printf(s, "%s", print_name ? "str " : "hex");
+ seq_puts(s, print_name ? "str " : "hex");
for (i = 0; i < r->res_length; i++) {
if (print_name)
@@ -391,23 +391,21 @@ static int table_seq_show(struct seq_file *seq, void *iter_ptr)
break;
case 2:
if (ri->header) {
- seq_printf(seq, "id nodeid remid pid xid exflags "
- "flags sts grmode rqmode time_ms "
- "r_nodeid r_len r_name\n");
+ seq_puts(seq, "id nodeid remid pid xid exflags flags sts grmode rqmode time_ms r_nodeid r_len r_name\n");
ri->header = 0;
}
print_format2(ri->rsb, seq);
break;
case 3:
if (ri->header) {
- seq_printf(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n");
+ seq_puts(seq, "version rsb 1.1 lvb 1.1 lkb 1.1\n");
ri->header = 0;
}
print_format3(ri->rsb, seq);
break;
case 4:
if (ri->header) {
- seq_printf(seq, "version 4 rsb 2\n");
+ seq_puts(seq, "version 4 rsb 2\n");
ri->header = 0;
}
print_format4(ri->rsb, seq);
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 53+ messages in thread* [PATCH 5/7] fs: Convert show_fdinfo functions to void
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
` (3 preceding siblings ...)
2014-09-29 23:08 ` [PATCH 4/7] dlm: Use seq_puts, remove unnecessary trailing spaces Joe Perches
@ 2014-09-29 23:08 ` Joe Perches
2014-10-28 14:11 ` Steven Rostedt
2014-09-29 23:08 ` [PATCH 6/7] debugfs: Fix misuse of seq_printf return value Joe Perches
` (2 subsequent siblings)
7 siblings, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, Jiri Kosina,
Alexander Viro, Thomas Gleixner, Jeff Layton, J. Bruce Fields,
linux-doc, linux-kernel, netdev, linux-fsdevel
seq_printf functions shouldn't really check the return value.
Checking seq_is_full occasionally is used instead.
Update vfs documentation.
Signed-off-by: Joe Perches <joe@perches.com>
---
Documentation/filesystems/vfs.txt | 2 +-
drivers/net/tun.c | 4 +--
fs/eventfd.c | 15 +++-----
fs/eventpoll.c | 19 ++++------
fs/notify/fdinfo.c | 76 +++++++++++++++++----------------------
fs/notify/fdinfo.h | 4 +--
fs/proc/fd.c | 2 +-
fs/signalfd.c | 10 ++----
fs/timerfd.c | 27 +++++++-------
include/linux/fs.h | 2 +-
10 files changed, 68 insertions(+), 93 deletions(-)
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index fceff7c..af1dbc1 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -828,7 +828,7 @@ struct file_operations {
ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int);
int (*setlease)(struct file *, long arg, struct file_lock **, void **);
long (*fallocate)(struct 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);
};
Again, all methods are called without any locks being held, unless
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 186ce54..a3420e0 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2209,7 +2209,7 @@ static int tun_chr_close(struct inode *inode, struct file *file)
}
#ifdef CONFIG_PROC_FS
-static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
+static void tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
{
struct tun_struct *tun;
struct ifreq ifr;
@@ -2225,7 +2225,7 @@ static int tun_chr_show_fdinfo(struct seq_file *m, struct file *f)
if (tun)
tun_put(tun);
- return seq_printf(m, "iff:\t%s\n", ifr.ifr_name);
+ seq_printf(m, "iff:\t%s\n", ifr.ifr_name);
}
#endif
diff --git a/fs/eventfd.c b/fs/eventfd.c
index d6a88e7..abcb25d 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 7bcfff9..4e742b6 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_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 9d7e2b9..0bb10b7 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_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,71 +51,62 @@ 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 == FILEID_INVALID) || (ret < 0)) {
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
#ifdef CONFIG_INOTIFY_USER
-static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
+static void 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;
+ return;
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;
}
-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 */
#ifdef CONFIG_FANOTIFY
-static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
+static void 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;
+ return;
if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
@@ -125,25 +115,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;
+ ;
}
-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 +157,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 e11d7c5..4c3c253 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -53,7 +53,7 @@ static int seq_show(struct seq_file *m, void *v)
(long long)file->f_pos, f_flags,
real_mount(file->f_path.mnt)->mnt_id);
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/fs/timerfd.c b/fs/timerfd.c
index b46ffa9..b94fa6c 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -288,7 +288,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
}
#ifdef CONFIG_PROC_FS
-static int timerfd_show(struct seq_file *m, struct file *file)
+static void timerfd_show(struct seq_file *m, struct file *file)
{
struct timerfd_ctx *ctx = file->private_data;
struct itimerspec t;
@@ -298,18 +298,19 @@ static int timerfd_show(struct seq_file *m, struct file *file)
t.it_interval = ktime_to_timespec(ctx->tintv);
spin_unlock_irq(&ctx->wqh.lock);
- return seq_printf(m,
- "clockid: %d\n"
- "ticks: %llu\n"
- "settime flags: 0%o\n"
- "it_value: (%llu, %llu)\n"
- "it_interval: (%llu, %llu)\n",
- ctx->clockid, (unsigned long long)ctx->ticks,
- ctx->settime_flags,
- (unsigned long long)t.it_value.tv_sec,
- (unsigned long long)t.it_value.tv_nsec,
- (unsigned long long)t.it_interval.tv_sec,
- (unsigned long long)t.it_interval.tv_nsec);
+ seq_printf(m,
+ "clockid: %d\n"
+ "ticks: %llu\n"
+ "settime flags: 0%o\n"
+ "it_value: (%llu, %llu)\n"
+ "it_interval: (%llu, %llu)\n",
+ ctx->clockid,
+ (unsigned long long)ctx->ticks,
+ ctx->settime_flags,
+ (unsigned long long)t.it_value.tv_sec,
+ (unsigned long long)t.it_value.tv_nsec,
+ (unsigned long long)t.it_interval.tv_sec,
+ (unsigned long long)t.it_interval.tv_nsec);
}
#else
#define timerfd_show NULL
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a4ce5bae..e2f67f0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1494,7 +1494,7 @@ struct file_operations {
int (*setlease)(struct file *, long, struct file_lock **, void **);
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] 53+ messages in thread* Re: [PATCH 5/7] fs: Convert show_fdinfo functions to void
2014-09-29 23:08 ` [PATCH 5/7] fs: Convert show_fdinfo functions to void Joe Perches
@ 2014-10-28 14:11 ` Steven Rostedt
2014-10-28 14:31 ` Joe Perches
0 siblings, 1 reply; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 14:11 UTC (permalink / raw)
To: Joe Perches
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, Jiri Kosina,
Thomas Gleixner, Jeff Layton, J. Bruce Fields, linux-doc,
linux-kernel, netdev, linux-fsdevel
On Mon, 29 Sep 2014 16:08:25 -0700
Joe Perches <joe@perches.com> wrote:
> seq_printf functions shouldn't really check the return value.
> Checking seq_is_full occasionally is used instead.
>
> Update vfs documentation.
>
> Signed-off-by: Joe Perches <joe@perches.com>
>
> -#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
I wouldn't change logic on this. There's no reason to call this
function if it isn't doing anything.
I'll change this to just do the update and not change logic like this.
-- Steve
> .release = eventfd_release,
> .poll = eventfd_poll,
> .read = eventfd_read,
> diff --git a/fs/proc/fd.c b/fs/proc/fd.c
> index e11d7c5..4c3c253 100644
> --- a/fs/proc/fd.c
> +++ b/fs/proc/fd.c
> @@ -53,7 +53,7 @@ static int seq_show(struct seq_file *m, void *v)
> (long long)file->f_pos, f_flags,
> real_mount(file->f_path.mnt)->mnt_id);
> if (file->f_op->show_fdinfo)
> - ret = file->f_op->show_fdinfo(m, file);
> + file->f_op->show_fdinfo(m, file);
> fput(file);
> }
>
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 5/7] fs: Convert show_fdinfo functions to void
2014-10-28 14:11 ` Steven Rostedt
@ 2014-10-28 14:31 ` Joe Perches
2014-10-28 14:43 ` Steven Rostedt
0 siblings, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-10-28 14:31 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, Jiri Kosina,
Thomas Gleixner, Jeff Layton, J. Bruce Fields, linux-doc,
linux-kernel, netdev, linux-fsdevel
On Tue, 2014-10-28 at 10:11 -0400, Steven Rostedt wrote:
> On Mon, 29 Sep 2014 16:08:25 -0700
> Joe Perches <joe@perches.com> wrote:
>
> > seq_printf functions shouldn't really check the return value.
> > Checking seq_is_full occasionally is used instead.
> >
> > Update vfs documentation.
> >
> > Signed-off-by: Joe Perches <joe@perches.com>
>
>
> >
> > -#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
>
> I wouldn't change logic on this. There's no reason to call this
> function if it isn't doing anything.
>
> I'll change this to just do the update and not change logic like this.
Fewer #ifdefs
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 5/7] fs: Convert show_fdinfo functions to void
2014-10-28 14:31 ` Joe Perches
@ 2014-10-28 14:43 ` Steven Rostedt
0 siblings, 0 replies; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 14:43 UTC (permalink / raw)
To: Joe Perches
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, Jiri Kosina,
Thomas Gleixner, Jeff Layton, J. Bruce Fields, linux-doc,
linux-kernel, netdev, linux-fsdevel
On Tue, 28 Oct 2014 07:31:32 -0700
Joe Perches <joe@perches.com> wrote:
> > I wouldn't change logic on this. There's no reason to call this
> > function if it isn't doing anything.
> >
> > I'll change this to just do the update and not change logic like this.
>
> Fewer #ifdefs
>
And there's other ways to fix it (like using an #else), but that is
off-topic to the current change set. In other words, that change should
be separate, as I don't want discussions on what's the best use of
#ifdefs distracting from getting in the "void seq_printf()" changes.
-- Steve
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
` (4 preceding siblings ...)
2014-09-29 23:08 ` [PATCH 5/7] fs: Convert show_fdinfo functions to void Joe Perches
@ 2014-09-29 23:08 ` Joe Perches
2014-10-28 14:58 ` Steven Rostedt
2014-11-07 19:03 ` Greg Kroah-Hartman
2014-09-29 23:08 ` [PATCH 7/7] docg3: Fix miuse " Joe Perches
2014-10-28 15:32 ` [PATCH 0/7] seq_printf cleanups Steven Rostedt
7 siblings, 2 replies; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Greg Kroah-Hartman, linux-kernel
Adding repeated -1 to the return is not correct.
Use seq_is_full to test for unnecessary seq_printf uses
and always return 0.
Signed-off-by: Joe Perches <joe@perches.com>
---
fs/debugfs/file.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 76c08c2..c24e578 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -695,15 +695,17 @@ EXPORT_SYMBOL_GPL(debugfs_create_u32_array);
int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
int nregs, void __iomem *base, char *prefix)
{
- int i, ret = 0;
+ int i;
for (i = 0; i < nregs; i++, regs++) {
- if (prefix)
- ret += seq_printf(s, "%s", prefix);
- ret += seq_printf(s, "%s = 0x%08x\n", regs->name,
- readl(base + regs->offset));
+ seq_printf(s, "%s%s = 0x%08x\n",
+ prefix ? prefix : "",
+ regs->name, readl(base + regs->offset));
+ if (seq_is_full(s))
+ break;
}
- return ret;
+
+ return 0;
}
EXPORT_SYMBOL_GPL(debugfs_print_regs32);
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 53+ messages in thread* Re: [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
2014-09-29 23:08 ` [PATCH 6/7] debugfs: Fix misuse of seq_printf return value Joe Perches
@ 2014-10-28 14:58 ` Steven Rostedt
2014-10-28 15:25 ` Joe Perches
2014-11-07 19:03 ` Greg Kroah-Hartman
1 sibling, 1 reply; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 14:58 UTC (permalink / raw)
To: Joe Perches
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Greg Kroah-Hartman, linux-kernel
On Mon, 29 Sep 2014 16:08:26 -0700
Joe Perches <joe@perches.com> wrote:
> Adding repeated -1 to the return is not correct.
>
> Use seq_is_full to test for unnecessary seq_printf uses
> and always return 0.
Actually, debugfs_print_regs32() should return void as well.
I'll update that.
Thanks,
-- Steve
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> fs/debugfs/file.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
> index 76c08c2..c24e578 100644
> --- a/fs/debugfs/file.c
> +++ b/fs/debugfs/file.c
> @@ -695,15 +695,17 @@ EXPORT_SYMBOL_GPL(debugfs_create_u32_array);
> int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
> int nregs, void __iomem *base, char *prefix)
> {
> - int i, ret = 0;
> + int i;
>
> for (i = 0; i < nregs; i++, regs++) {
> - if (prefix)
> - ret += seq_printf(s, "%s", prefix);
> - ret += seq_printf(s, "%s = 0x%08x\n", regs->name,
> - readl(base + regs->offset));
> + seq_printf(s, "%s%s = 0x%08x\n",
> + prefix ? prefix : "",
> + regs->name, readl(base + regs->offset));
> + if (seq_is_full(s))
> + break;
> }
> - return ret;
> +
> + return 0;
> }
> EXPORT_SYMBOL_GPL(debugfs_print_regs32);
>
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
2014-10-28 14:58 ` Steven Rostedt
@ 2014-10-28 15:25 ` Joe Perches
2014-10-28 15:42 ` Steven Rostedt
0 siblings, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-10-28 15:25 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Greg Kroah-Hartman, linux-kernel
On Tue, 2014-10-28 at 10:58 -0400, Steven Rostedt wrote:
> On Mon, 29 Sep 2014 16:08:26 -0700
> Joe Perches <joe@perches.com> wrote:
> > Adding repeated -1 to the return is not correct.
> > Use seq_is_full to test for unnecessary seq_printf uses
> > and always return 0.
[]
> Actually, debugfs_print_regs32() should return void as well.
> I'll update that.
Great though this should possibly be another patch.
I didn't want to update the documentation.
Maybe remove the prototype and make it static too.
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
2014-10-28 15:25 ` Joe Perches
@ 2014-10-28 15:42 ` Steven Rostedt
2014-10-28 15:59 ` Joe Perches
0 siblings, 1 reply; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 15:42 UTC (permalink / raw)
To: Joe Perches
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Greg Kroah-Hartman, linux-kernel
On Tue, 28 Oct 2014 08:25:51 -0700
Joe Perches <joe@perches.com> wrote:
> On Tue, 2014-10-28 at 10:58 -0400, Steven Rostedt wrote:
> > On Mon, 29 Sep 2014 16:08:26 -0700
> > Joe Perches <joe@perches.com> wrote:
> > > Adding repeated -1 to the return is not correct.
> > > Use seq_is_full to test for unnecessary seq_printf uses
> > > and always return 0.
> []
> > Actually, debugfs_print_regs32() should return void as well.
> > I'll update that.
>
> Great though this should possibly be another patch.
Could have, but other patches that had functions returning the value of
seq_printf() also changed their output with the change. Don't worry
about being blamed, I update the change log to show that I modified it
too. ;-)
>
> I didn't want to update the documentation.
It was a one liner, that didn't really change the content.
>
> Maybe remove the prototype and make it static too.
>
Now that can be a separate patch set if you want. I'm not too worried
about that as it doesn't affect the updates I want to do with
seq_file.
-- Steve
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
2014-10-28 15:42 ` Steven Rostedt
@ 2014-10-28 15:59 ` Joe Perches
0 siblings, 0 replies; 53+ messages in thread
From: Joe Perches @ 2014-10-28 15:59 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
Greg Kroah-Hartman, linux-kernel
On Tue, 2014-10-28 at 11:42 -0400, Steven Rostedt wrote:
> On Tue, 28 Oct 2014 08:25:51 -0700 Joe Perches <joe@perches.com> wrote:
[]
> > Maybe remove the prototype and make it static too.
> Now that can be a separate patch set if you want.
No worries, it could happen later.
Thanks for taking this on btw.
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
2014-09-29 23:08 ` [PATCH 6/7] debugfs: Fix misuse of seq_printf return value Joe Perches
2014-10-28 14:58 ` Steven Rostedt
@ 2014-11-07 19:03 ` Greg Kroah-Hartman
1 sibling, 0 replies; 53+ messages in thread
From: Greg Kroah-Hartman @ 2014-11-07 19:03 UTC (permalink / raw)
To: Joe Perches
Cc: Steven Rostedt, Al Viro, Petr Mladek, Andrew Morton,
Linus Torvalds, linux-kernel
On Mon, Sep 29, 2014 at 04:08:26PM -0700, Joe Perches wrote:
> Adding repeated -1 to the return is not correct.
>
> Use seq_is_full to test for unnecessary seq_printf uses
> and always return 0.
>
> Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 53+ messages in thread
* [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
` (5 preceding siblings ...)
2014-09-29 23:08 ` [PATCH 6/7] debugfs: Fix misuse of seq_printf return value Joe Perches
@ 2014-09-29 23:08 ` Joe Perches
2014-10-22 8:29 ` Brian Norris
2014-10-28 15:32 ` [PATCH 0/7] seq_printf cleanups Steven Rostedt
7 siblings, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-09-29 23:08 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, Brian Norris, linux-mtd, linux-kernel
seq_printf doesn't return a useful value, so remove
these misuses.
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/mtd/devices/docg3.c | 112 ++++++++++++++++++++------------------------
1 file changed, 52 insertions(+), 60 deletions(-)
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index 21cc4b6..68ff83c 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -1655,22 +1655,21 @@ static int dbg_flashctrl_show(struct seq_file *s, void *p)
{
struct docg3 *docg3 = (struct docg3 *)s->private;
- int pos = 0;
u8 fctrl;
mutex_lock(&docg3->cascade->lock);
fctrl = doc_register_readb(docg3, DOC_FLASHCONTROL);
mutex_unlock(&docg3->cascade->lock);
- pos += seq_printf(s,
- "FlashControl : 0x%02x (%s,CE# %s,%s,%s,flash %s)\n",
- fctrl,
- fctrl & DOC_CTRL_VIOLATION ? "protocol violation" : "-",
- fctrl & DOC_CTRL_CE ? "active" : "inactive",
- fctrl & DOC_CTRL_PROTECTION_ERROR ? "protection error" : "-",
- fctrl & DOC_CTRL_SEQUENCE_ERROR ? "sequence error" : "-",
- fctrl & DOC_CTRL_FLASHREADY ? "ready" : "not ready");
- return pos;
+ seq_printf(s, "FlashControl : 0x%02x (%s,CE# %s,%s,%s,flash %s)\n",
+ fctrl,
+ fctrl & DOC_CTRL_VIOLATION ? "protocol violation" : "-",
+ fctrl & DOC_CTRL_CE ? "active" : "inactive",
+ fctrl & DOC_CTRL_PROTECTION_ERROR ? "protection error" : "-",
+ fctrl & DOC_CTRL_SEQUENCE_ERROR ? "sequence error" : "-",
+ fctrl & DOC_CTRL_FLASHREADY ? "ready" : "not ready");
+
+ return 0;
}
DEBUGFS_RO_ATTR(flashcontrol, dbg_flashctrl_show);
@@ -1678,58 +1677,56 @@ static int dbg_asicmode_show(struct seq_file *s, void *p)
{
struct docg3 *docg3 = (struct docg3 *)s->private;
- int pos = 0, pctrl, mode;
+ int pctrl, mode;
mutex_lock(&docg3->cascade->lock);
pctrl = doc_register_readb(docg3, DOC_ASICMODE);
mode = pctrl & 0x03;
mutex_unlock(&docg3->cascade->lock);
- pos += seq_printf(s,
- "%04x : RAM_WE=%d,RSTIN_RESET=%d,BDETCT_RESET=%d,WRITE_ENABLE=%d,POWERDOWN=%d,MODE=%d%d (",
- pctrl,
- pctrl & DOC_ASICMODE_RAM_WE ? 1 : 0,
- pctrl & DOC_ASICMODE_RSTIN_RESET ? 1 : 0,
- pctrl & DOC_ASICMODE_BDETCT_RESET ? 1 : 0,
- pctrl & DOC_ASICMODE_MDWREN ? 1 : 0,
- pctrl & DOC_ASICMODE_POWERDOWN ? 1 : 0,
- mode >> 1, mode & 0x1);
+ seq_printf(s,
+ "%04x : RAM_WE=%d,RSTIN_RESET=%d,BDETCT_RESET=%d,WRITE_ENABLE=%d,POWERDOWN=%d,MODE=%d%d (",
+ pctrl,
+ pctrl & DOC_ASICMODE_RAM_WE ? 1 : 0,
+ pctrl & DOC_ASICMODE_RSTIN_RESET ? 1 : 0,
+ pctrl & DOC_ASICMODE_BDETCT_RESET ? 1 : 0,
+ pctrl & DOC_ASICMODE_MDWREN ? 1 : 0,
+ pctrl & DOC_ASICMODE_POWERDOWN ? 1 : 0,
+ mode >> 1, mode & 0x1);
switch (mode) {
case DOC_ASICMODE_RESET:
- pos += seq_puts(s, "reset");
+ seq_puts(s, "reset");
break;
case DOC_ASICMODE_NORMAL:
- pos += seq_puts(s, "normal");
+ seq_puts(s, "normal");
break;
case DOC_ASICMODE_POWERDOWN:
- pos += seq_puts(s, "powerdown");
+ seq_puts(s, "powerdown");
break;
}
- pos += seq_puts(s, ")\n");
- return pos;
+ seq_puts(s, ")\n");
+ return 0;
}
DEBUGFS_RO_ATTR(asic_mode, dbg_asicmode_show);
static int dbg_device_id_show(struct seq_file *s, void *p)
{
struct docg3 *docg3 = (struct docg3 *)s->private;
- int pos = 0;
int id;
mutex_lock(&docg3->cascade->lock);
id = doc_register_readb(docg3, DOC_DEVICESELECT);
mutex_unlock(&docg3->cascade->lock);
- pos += seq_printf(s, "DeviceId = %d\n", id);
- return pos;
+ seq_printf(s, "DeviceId = %d\n", id);
+ return 0;
}
DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
static int dbg_protection_show(struct seq_file *s, void *p)
{
struct docg3 *docg3 = (struct docg3 *)s->private;
- int pos = 0;
int protect, dps0, dps0_low, dps0_high, dps1, dps1_low, dps1_high;
mutex_lock(&docg3->cascade->lock);
@@ -1742,45 +1739,40 @@ static int dbg_protection_show(struct seq_file *s, void *p)
dps1_high = doc_register_readw(docg3, DOC_DPS1_ADDRHIGH);
mutex_unlock(&docg3->cascade->lock);
- pos += seq_printf(s, "Protection = 0x%02x (",
- protect);
+ seq_printf(s, "Protection = 0x%02x (", protect);
if (protect & DOC_PROTECT_FOUNDRY_OTP_LOCK)
- pos += seq_puts(s, "FOUNDRY_OTP_LOCK,");
+ seq_puts(s, "FOUNDRY_OTP_LOCK,");
if (protect & DOC_PROTECT_CUSTOMER_OTP_LOCK)
- pos += seq_puts(s, "CUSTOMER_OTP_LOCK,");
+ seq_puts(s, "CUSTOMER_OTP_LOCK,");
if (protect & DOC_PROTECT_LOCK_INPUT)
- pos += seq_puts(s, "LOCK_INPUT,");
+ seq_puts(s, "LOCK_INPUT,");
if (protect & DOC_PROTECT_STICKY_LOCK)
- pos += seq_puts(s, "STICKY_LOCK,");
+ seq_puts(s, "STICKY_LOCK,");
if (protect & DOC_PROTECT_PROTECTION_ENABLED)
- pos += seq_puts(s, "PROTECTION ON,");
+ seq_puts(s, "PROTECTION ON,");
if (protect & DOC_PROTECT_IPL_DOWNLOAD_LOCK)
- pos += seq_puts(s, "IPL_DOWNLOAD_LOCK,");
+ seq_puts(s, "IPL_DOWNLOAD_LOCK,");
if (protect & DOC_PROTECT_PROTECTION_ERROR)
- pos += seq_puts(s, "PROTECT_ERR,");
+ seq_puts(s, "PROTECT_ERR,");
else
- pos += seq_puts(s, "NO_PROTECT_ERR");
- pos += seq_puts(s, ")\n");
-
- pos += seq_printf(s, "DPS0 = 0x%02x : "
- "Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, "
- "WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
- dps0, dps0_low, dps0_high,
- !!(dps0 & DOC_DPS_OTP_PROTECTED),
- !!(dps0 & DOC_DPS_READ_PROTECTED),
- !!(dps0 & DOC_DPS_WRITE_PROTECTED),
- !!(dps0 & DOC_DPS_HW_LOCK_ENABLED),
- !!(dps0 & DOC_DPS_KEY_OK));
- pos += seq_printf(s, "DPS1 = 0x%02x : "
- "Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, "
- "WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
- dps1, dps1_low, dps1_high,
- !!(dps1 & DOC_DPS_OTP_PROTECTED),
- !!(dps1 & DOC_DPS_READ_PROTECTED),
- !!(dps1 & DOC_DPS_WRITE_PROTECTED),
- !!(dps1 & DOC_DPS_HW_LOCK_ENABLED),
- !!(dps1 & DOC_DPS_KEY_OK));
- return pos;
+ seq_puts(s, "NO_PROTECT_ERR");
+ seq_puts(s, ")\n");
+
+ seq_printf(s, "DPS0 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
+ dps0, dps0_low, dps0_high,
+ !!(dps0 & DOC_DPS_OTP_PROTECTED),
+ !!(dps0 & DOC_DPS_READ_PROTECTED),
+ !!(dps0 & DOC_DPS_WRITE_PROTECTED),
+ !!(dps0 & DOC_DPS_HW_LOCK_ENABLED),
+ !!(dps0 & DOC_DPS_KEY_OK));
+ seq_printf(s, "DPS1 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
+ dps1, dps1_low, dps1_high,
+ !!(dps1 & DOC_DPS_OTP_PROTECTED),
+ !!(dps1 & DOC_DPS_READ_PROTECTED),
+ !!(dps1 & DOC_DPS_WRITE_PROTECTED),
+ !!(dps1 & DOC_DPS_HW_LOCK_ENABLED),
+ !!(dps1 & DOC_DPS_KEY_OK));
+ return 0;
}
DEBUGFS_RO_ATTR(protection, dbg_protection_show);
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 53+ messages in thread* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-09-29 23:08 ` [PATCH 7/7] docg3: Fix miuse " Joe Perches
@ 2014-10-22 8:29 ` Brian Norris
2014-10-28 15:13 ` Steven Rostedt
0 siblings, 1 reply; 53+ messages in thread
From: Brian Norris @ 2014-10-22 8:29 UTC (permalink / raw)
To: Joe Perches
Cc: Steven Rostedt, Al Viro, Petr Mladek, Andrew Morton,
Linus Torvalds, David Woodhouse, linux-mtd, linux-kernel
On Mon, Sep 29, 2014 at 04:08:27PM -0700, Joe Perches wrote:
> seq_printf doesn't return a useful value, so remove
> these misuses.
Good catch. So it looks like this driver always had some form of
wrongness (returning a character count) in its debugfs callbacks, but
nobody noticed.
Applied to l2-mtd.git. Thanks!
Brian
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/mtd/devices/docg3.c | 112 ++++++++++++++++++++------------------------
> 1 file changed, 52 insertions(+), 60 deletions(-)
>
> diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
> index 21cc4b6..68ff83c 100644
> --- a/drivers/mtd/devices/docg3.c
> +++ b/drivers/mtd/devices/docg3.c
> @@ -1655,22 +1655,21 @@ static int dbg_flashctrl_show(struct seq_file *s, void *p)
> {
> struct docg3 *docg3 = (struct docg3 *)s->private;
>
> - int pos = 0;
> u8 fctrl;
>
> mutex_lock(&docg3->cascade->lock);
> fctrl = doc_register_readb(docg3, DOC_FLASHCONTROL);
> mutex_unlock(&docg3->cascade->lock);
>
> - pos += seq_printf(s,
> - "FlashControl : 0x%02x (%s,CE# %s,%s,%s,flash %s)\n",
> - fctrl,
> - fctrl & DOC_CTRL_VIOLATION ? "protocol violation" : "-",
> - fctrl & DOC_CTRL_CE ? "active" : "inactive",
> - fctrl & DOC_CTRL_PROTECTION_ERROR ? "protection error" : "-",
> - fctrl & DOC_CTRL_SEQUENCE_ERROR ? "sequence error" : "-",
> - fctrl & DOC_CTRL_FLASHREADY ? "ready" : "not ready");
> - return pos;
> + seq_printf(s, "FlashControl : 0x%02x (%s,CE# %s,%s,%s,flash %s)\n",
> + fctrl,
> + fctrl & DOC_CTRL_VIOLATION ? "protocol violation" : "-",
> + fctrl & DOC_CTRL_CE ? "active" : "inactive",
> + fctrl & DOC_CTRL_PROTECTION_ERROR ? "protection error" : "-",
> + fctrl & DOC_CTRL_SEQUENCE_ERROR ? "sequence error" : "-",
> + fctrl & DOC_CTRL_FLASHREADY ? "ready" : "not ready");
> +
> + return 0;
> }
> DEBUGFS_RO_ATTR(flashcontrol, dbg_flashctrl_show);
>
> @@ -1678,58 +1677,56 @@ static int dbg_asicmode_show(struct seq_file *s, void *p)
> {
> struct docg3 *docg3 = (struct docg3 *)s->private;
>
> - int pos = 0, pctrl, mode;
> + int pctrl, mode;
>
> mutex_lock(&docg3->cascade->lock);
> pctrl = doc_register_readb(docg3, DOC_ASICMODE);
> mode = pctrl & 0x03;
> mutex_unlock(&docg3->cascade->lock);
>
> - pos += seq_printf(s,
> - "%04x : RAM_WE=%d,RSTIN_RESET=%d,BDETCT_RESET=%d,WRITE_ENABLE=%d,POWERDOWN=%d,MODE=%d%d (",
> - pctrl,
> - pctrl & DOC_ASICMODE_RAM_WE ? 1 : 0,
> - pctrl & DOC_ASICMODE_RSTIN_RESET ? 1 : 0,
> - pctrl & DOC_ASICMODE_BDETCT_RESET ? 1 : 0,
> - pctrl & DOC_ASICMODE_MDWREN ? 1 : 0,
> - pctrl & DOC_ASICMODE_POWERDOWN ? 1 : 0,
> - mode >> 1, mode & 0x1);
> + seq_printf(s,
> + "%04x : RAM_WE=%d,RSTIN_RESET=%d,BDETCT_RESET=%d,WRITE_ENABLE=%d,POWERDOWN=%d,MODE=%d%d (",
> + pctrl,
> + pctrl & DOC_ASICMODE_RAM_WE ? 1 : 0,
> + pctrl & DOC_ASICMODE_RSTIN_RESET ? 1 : 0,
> + pctrl & DOC_ASICMODE_BDETCT_RESET ? 1 : 0,
> + pctrl & DOC_ASICMODE_MDWREN ? 1 : 0,
> + pctrl & DOC_ASICMODE_POWERDOWN ? 1 : 0,
> + mode >> 1, mode & 0x1);
>
> switch (mode) {
> case DOC_ASICMODE_RESET:
> - pos += seq_puts(s, "reset");
> + seq_puts(s, "reset");
> break;
> case DOC_ASICMODE_NORMAL:
> - pos += seq_puts(s, "normal");
> + seq_puts(s, "normal");
> break;
> case DOC_ASICMODE_POWERDOWN:
> - pos += seq_puts(s, "powerdown");
> + seq_puts(s, "powerdown");
> break;
> }
> - pos += seq_puts(s, ")\n");
> - return pos;
> + seq_puts(s, ")\n");
> + return 0;
> }
> DEBUGFS_RO_ATTR(asic_mode, dbg_asicmode_show);
>
> static int dbg_device_id_show(struct seq_file *s, void *p)
> {
> struct docg3 *docg3 = (struct docg3 *)s->private;
> - int pos = 0;
> int id;
>
> mutex_lock(&docg3->cascade->lock);
> id = doc_register_readb(docg3, DOC_DEVICESELECT);
> mutex_unlock(&docg3->cascade->lock);
>
> - pos += seq_printf(s, "DeviceId = %d\n", id);
> - return pos;
> + seq_printf(s, "DeviceId = %d\n", id);
> + return 0;
> }
> DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
>
> static int dbg_protection_show(struct seq_file *s, void *p)
> {
> struct docg3 *docg3 = (struct docg3 *)s->private;
> - int pos = 0;
> int protect, dps0, dps0_low, dps0_high, dps1, dps1_low, dps1_high;
>
> mutex_lock(&docg3->cascade->lock);
> @@ -1742,45 +1739,40 @@ static int dbg_protection_show(struct seq_file *s, void *p)
> dps1_high = doc_register_readw(docg3, DOC_DPS1_ADDRHIGH);
> mutex_unlock(&docg3->cascade->lock);
>
> - pos += seq_printf(s, "Protection = 0x%02x (",
> - protect);
> + seq_printf(s, "Protection = 0x%02x (", protect);
> if (protect & DOC_PROTECT_FOUNDRY_OTP_LOCK)
> - pos += seq_puts(s, "FOUNDRY_OTP_LOCK,");
> + seq_puts(s, "FOUNDRY_OTP_LOCK,");
> if (protect & DOC_PROTECT_CUSTOMER_OTP_LOCK)
> - pos += seq_puts(s, "CUSTOMER_OTP_LOCK,");
> + seq_puts(s, "CUSTOMER_OTP_LOCK,");
> if (protect & DOC_PROTECT_LOCK_INPUT)
> - pos += seq_puts(s, "LOCK_INPUT,");
> + seq_puts(s, "LOCK_INPUT,");
> if (protect & DOC_PROTECT_STICKY_LOCK)
> - pos += seq_puts(s, "STICKY_LOCK,");
> + seq_puts(s, "STICKY_LOCK,");
> if (protect & DOC_PROTECT_PROTECTION_ENABLED)
> - pos += seq_puts(s, "PROTECTION ON,");
> + seq_puts(s, "PROTECTION ON,");
> if (protect & DOC_PROTECT_IPL_DOWNLOAD_LOCK)
> - pos += seq_puts(s, "IPL_DOWNLOAD_LOCK,");
> + seq_puts(s, "IPL_DOWNLOAD_LOCK,");
> if (protect & DOC_PROTECT_PROTECTION_ERROR)
> - pos += seq_puts(s, "PROTECT_ERR,");
> + seq_puts(s, "PROTECT_ERR,");
> else
> - pos += seq_puts(s, "NO_PROTECT_ERR");
> - pos += seq_puts(s, ")\n");
> -
> - pos += seq_printf(s, "DPS0 = 0x%02x : "
> - "Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, "
> - "WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
> - dps0, dps0_low, dps0_high,
> - !!(dps0 & DOC_DPS_OTP_PROTECTED),
> - !!(dps0 & DOC_DPS_READ_PROTECTED),
> - !!(dps0 & DOC_DPS_WRITE_PROTECTED),
> - !!(dps0 & DOC_DPS_HW_LOCK_ENABLED),
> - !!(dps0 & DOC_DPS_KEY_OK));
> - pos += seq_printf(s, "DPS1 = 0x%02x : "
> - "Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, "
> - "WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
> - dps1, dps1_low, dps1_high,
> - !!(dps1 & DOC_DPS_OTP_PROTECTED),
> - !!(dps1 & DOC_DPS_READ_PROTECTED),
> - !!(dps1 & DOC_DPS_WRITE_PROTECTED),
> - !!(dps1 & DOC_DPS_HW_LOCK_ENABLED),
> - !!(dps1 & DOC_DPS_KEY_OK));
> - return pos;
> + seq_puts(s, "NO_PROTECT_ERR");
> + seq_puts(s, ")\n");
> +
> + seq_printf(s, "DPS0 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
> + dps0, dps0_low, dps0_high,
> + !!(dps0 & DOC_DPS_OTP_PROTECTED),
> + !!(dps0 & DOC_DPS_READ_PROTECTED),
> + !!(dps0 & DOC_DPS_WRITE_PROTECTED),
> + !!(dps0 & DOC_DPS_HW_LOCK_ENABLED),
> + !!(dps0 & DOC_DPS_KEY_OK));
> + seq_printf(s, "DPS1 = 0x%02x : Protected area [0x%x - 0x%x] : OTP=%d, READ=%d, WRITE=%d, HW_LOCK=%d, KEY_OK=%d\n",
> + dps1, dps1_low, dps1_high,
> + !!(dps1 & DOC_DPS_OTP_PROTECTED),
> + !!(dps1 & DOC_DPS_READ_PROTECTED),
> + !!(dps1 & DOC_DPS_WRITE_PROTECTED),
> + !!(dps1 & DOC_DPS_HW_LOCK_ENABLED),
> + !!(dps1 & DOC_DPS_KEY_OK));
> + return 0;
> }
> DEBUGFS_RO_ATTR(protection, dbg_protection_show);
>
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-22 8:29 ` Brian Norris
@ 2014-10-28 15:13 ` Steven Rostedt
2014-10-28 15:57 ` Joe Perches
0 siblings, 1 reply; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 15:13 UTC (permalink / raw)
To: Brian Norris
Cc: Joe Perches, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Wed, 22 Oct 2014 01:29:16 -0700
Brian Norris <computersforpeace@gmail.com> wrote:
> On Mon, Sep 29, 2014 at 04:08:27PM -0700, Joe Perches wrote:
> > seq_printf doesn't return a useful value, so remove
> > these misuses.
>
> Good catch. So it looks like this driver always had some form of
> wrongness (returning a character count) in its debugfs callbacks, but
> nobody noticed.
>
> Applied to l2-mtd.git. Thanks!
>
Note, I'm going to be working on changes to remove the return value of
seq_printf() and friends. I need this change as well. If you
already applied it to your git tree, if you can still rebase, can you
make a separate branch off of Linus's tree that I can pull to do work
on?
Or I can take this patch as well, with your Acked-by.
Thanks!
-- Steve
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 15:13 ` Steven Rostedt
@ 2014-10-28 15:57 ` Joe Perches
2014-10-28 16:05 ` Steven Rostedt
0 siblings, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-10-28 15:57 UTC (permalink / raw)
To: Steven Rostedt
Cc: Brian Norris, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Tue, 2014-10-28 at 11:13 -0400, Steven Rostedt wrote:
> I'm going to be working on changes to remove the return value of
> seq_printf() and friends.
I'm sure you know all of this, but for anyone else:
This doesn't need to be done in a single pass.
The seq_<foo> functions themselves can wait until
all the uses are converted.
Here are files that likely need to change:
$ git grep --name-only -E "[\(=]\s*seq_(vprintf|printf|puts|putc|escape|write|put_decimal_\w+)\s*\("
arch/arm/plat-pxa/dma.c
arch/cris/arch-v10/kernel/fasttimer.c
arch/cris/arch-v32/kernel/fasttimer.c
arch/microblaze/kernel/cpu/mb.c
arch/x86/kernel/cpu/mtrr/if.c
drivers/base/power/wakeup.c
drivers/mfd/ab8500-debugfs.c
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
drivers/parisc/ccio-dma.c
drivers/parisc/sba_iommu.c
drivers/regulator/dbx500-prcmu.c
drivers/staging/lustre/lustre/fid/lproc_fid.c
drivers/staging/lustre/lustre/llite/lproc_llite.c
drivers/staging/lustre/lustre/mdc/lproc_mdc.c
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
drivers/staging/lustre/lustre/osc/lproc_osc.c
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
drivers/usb/gadget/udc/goku_udc.c
drivers/usb/gadget/udc/pxa27x_udc.c
drivers/watchdog/bcm_kona_wdt.c
fs/debugfs/file.c
fs/dlm/debug_fs.c
fs/eventfd.c
fs/eventpoll.c
fs/notify/fdinfo.c
fs/proc/base.c
fs/seq_file.c
kernel/trace/trace_seq.c
net/batman-adv/gateway_client.c
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
net/netfilter/nf_conntrack_standalone.c
net/netfilter/nf_log.c
net/netfilter/xt_hashlimit.c
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 15:57 ` Joe Perches
@ 2014-10-28 16:05 ` Steven Rostedt
2014-10-28 17:14 ` Brian Norris
2014-10-28 17:27 ` Joe Perches
0 siblings, 2 replies; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 16:05 UTC (permalink / raw)
To: Joe Perches
Cc: Brian Norris, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Tue, 28 Oct 2014 08:57:57 -0700
Joe Perches <joe@perches.com> wrote:
> On Tue, 2014-10-28 at 11:13 -0400, Steven Rostedt wrote:
> > I'm going to be working on changes to remove the return value of
> > seq_printf() and friends.
>
> I'm sure you know all of this, but for anyone else:
>
> This doesn't need to be done in a single pass.
Yeah, I took a look at all the places, and I've decided to take it off
in chunks. I'm starting with the ones you posted, and will try to get
acks for them. And then go after other chunks as I have time.
I would like to get this done before I do my merge of trace_seq and
seq_file, but I'm thinking I may have to do that in parallel.
-- Steve
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 16:05 ` Steven Rostedt
@ 2014-10-28 17:14 ` Brian Norris
2014-10-28 17:26 ` Steven Rostedt
2014-10-28 17:27 ` Joe Perches
1 sibling, 1 reply; 53+ messages in thread
From: Brian Norris @ 2014-10-28 17:14 UTC (permalink / raw)
To: Steven Rostedt
Cc: Joe Perches, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Tue, Oct 28, 2014 at 12:05:52PM -0400, Steven Rostedt wrote:
> On Tue, 28 Oct 2014 08:57:57 -0700
> Joe Perches <joe@perches.com> wrote:
>
> > On Tue, 2014-10-28 at 11:13 -0400, Steven Rostedt wrote:
> > > I'm going to be working on changes to remove the return value of
> > > seq_printf() and friends.
> >
> > I'm sure you know all of this, but for anyone else:
> >
> > This doesn't need to be done in a single pass.
>
> Yeah, I took a look at all the places, and I've decided to take it off
> in chunks. I'm starting with the ones you posted, and will try to get
> acks for them. And then go after other chunks as I have time.
I'll keep this in my tree as-is for now. Let me know if you still need
something changed. I can give my 'Ack' if you really want to pull this
into a separate branch.
BTW, I just noticed the $subject has a typo: s/miuse/misuse/
Brian
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 17:14 ` Brian Norris
@ 2014-10-28 17:26 ` Steven Rostedt
0 siblings, 0 replies; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 17:26 UTC (permalink / raw)
To: Brian Norris
Cc: Joe Perches, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Tue, 28 Oct 2014 10:14:09 -0700
Brian Norris <computersforpeace@gmail.com> wrote:
> On Tue, Oct 28, 2014 at 12:05:52PM -0400, Steven Rostedt wrote:
> > On Tue, 28 Oct 2014 08:57:57 -0700
> > Joe Perches <joe@perches.com> wrote:
> >
> > > On Tue, 2014-10-28 at 11:13 -0400, Steven Rostedt wrote:
> > > > I'm going to be working on changes to remove the return value of
> > > > seq_printf() and friends.
> > >
> > > I'm sure you know all of this, but for anyone else:
> > >
> > > This doesn't need to be done in a single pass.
> >
> > Yeah, I took a look at all the places, and I've decided to take it off
> > in chunks. I'm starting with the ones you posted, and will try to get
> > acks for them. And then go after other chunks as I have time.
>
> I'll keep this in my tree as-is for now. Let me know if you still need
> something changed. I can give my 'Ack' if you really want to pull this
> into a separate branch.
If I get to a point where I can change the seq_printf() to return void,
then I'll want it, otherwise without it, it will cause my branch to fail
to compile on that code.
That's why I would like it. If we keep it in your tree and have that for
the next release, it will matter which tree goes into Linus's tree
first. If mine goes in first, then it will break his build.
Now, that's assuming I get this ready for 3.19, as I'll need quite a
few Acked-by's for the changes that I'll be making. If I don't get it
by 3.19, then it wont be an issue if that change goes in with your tree.
-- Steve
>
> BTW, I just noticed the $subject has a typo: s/miuse/misuse/
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 16:05 ` Steven Rostedt
2014-10-28 17:14 ` Brian Norris
@ 2014-10-28 17:27 ` Joe Perches
2014-10-28 17:32 ` Steven Rostedt
1 sibling, 1 reply; 53+ messages in thread
From: Joe Perches @ 2014-10-28 17:27 UTC (permalink / raw)
To: Steven Rostedt
Cc: Brian Norris, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Tue, 2014-10-28 at 12:05 -0400, Steven Rostedt wrote:
> On Tue, 28 Oct 2014 08:57:57 -0700
> Joe Perches <joe@perches.com> wrote:
>
> > On Tue, 2014-10-28 at 11:13 -0400, Steven Rostedt wrote:
> > > I'm going to be working on changes to remove the return value of
> > > seq_printf() and friends.
> >
> > I'm sure you know all of this, but for anyone else:
> >
> > This doesn't need to be done in a single pass.
>
> Yeah, I took a look at all the places, and I've decided to take it off
> in chunks. I'm starting with the ones you posted, and will try to get
> acks for them. And then go after other chunks as I have time.
>
> I would like to get this done before I do my merge of trace_seq and
> seq_file, but I'm thinking I may have to do that in parallel.
I think the most important thing is to get the
seq_is_overflown (or seq_has_overflowed or whatever
other name is chosen) function added then the rest
of the patches can be applied whenever maintainers
(or Andrew or trivial or ...) pick them up.
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 17:27 ` Joe Perches
@ 2014-10-28 17:32 ` Steven Rostedt
2014-10-28 17:36 ` Brian Norris
2014-10-28 17:38 ` Joe Perches
0 siblings, 2 replies; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 17:32 UTC (permalink / raw)
To: Joe Perches
Cc: Brian Norris, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Tue, 28 Oct 2014 10:27:40 -0700
Joe Perches <joe@perches.com> wrote:
> On Tue, 2014-10-28 at 12:05 -0400, Steven Rostedt wrote:
> > On Tue, 28 Oct 2014 08:57:57 -0700
> > Joe Perches <joe@perches.com> wrote:
> >
> > > On Tue, 2014-10-28 at 11:13 -0400, Steven Rostedt wrote:
> > > > I'm going to be working on changes to remove the return value of
> > > > seq_printf() and friends.
> > >
> > > I'm sure you know all of this, but for anyone else:
> > >
> > > This doesn't need to be done in a single pass.
> >
> > Yeah, I took a look at all the places, and I've decided to take it off
> > in chunks. I'm starting with the ones you posted, and will try to get
> > acks for them. And then go after other chunks as I have time.
> >
> > I would like to get this done before I do my merge of trace_seq and
> > seq_file, but I'm thinking I may have to do that in parallel.
>
> I think the most important thing is to get the
> seq_is_overflown (or seq_has_overflowed or whatever
> other name is chosen) function added then the rest
> of the patches can be applied whenever maintainers
> (or Andrew or trivial or ...) pick them up.
I can get that in without much of an issue. But the merge of trace_seq
and seq_file would be easier if I didn't have to worry about return
values. Which is why I want to get this in quickly.
-- Steve
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 17:32 ` Steven Rostedt
@ 2014-10-28 17:36 ` Brian Norris
2014-10-28 17:38 ` Joe Perches
1 sibling, 0 replies; 53+ messages in thread
From: Brian Norris @ 2014-10-28 17:36 UTC (permalink / raw)
To: Steven Rostedt
Cc: Joe Perches, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd@lists.infradead.org, Linux Kernel
On Tue, Oct 28, 2014 at 10:32 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Tue, 28 Oct 2014 10:27:40 -0700
> Joe Perches <joe@perches.com> wrote:
>> On Tue, 2014-10-28 at 12:05 -0400, Steven Rostedt wrote:
>> > On Tue, 28 Oct 2014 08:57:57 -0700
>> > Joe Perches <joe@perches.com> wrote:
>> >
>> > > On Tue, 2014-10-28 at 11:13 -0400, Steven Rostedt wrote:
>> > > > I'm going to be working on changes to remove the return value of
>> > > > seq_printf() and friends.
>> > >
>> > > I'm sure you know all of this, but for anyone else:
>> > >
>> > > This doesn't need to be done in a single pass.
>> >
>> > Yeah, I took a look at all the places, and I've decided to take it off
>> > in chunks. I'm starting with the ones you posted, and will try to get
>> > acks for them. And then go after other chunks as I have time.
>> >
>> > I would like to get this done before I do my merge of trace_seq and
>> > seq_file, but I'm thinking I may have to do that in parallel.
>>
>> I think the most important thing is to get the
>> seq_is_overflown (or seq_has_overflowed or whatever
>> other name is chosen) function added then the rest
>> of the patches can be applied whenever maintainers
>> (or Andrew or trivial or ...) pick them up.
>
> I can get that in without much of an issue. But the merge of trace_seq
> and seq_file would be easier if I didn't have to worry about return
> values. Which is why I want to get this in quickly.
Whatever you'd like. Please, have my ack and keep the patch in your own branch!
Acked-by: Brian Norris <computersforpeace@gmail.com>
It's no problem if we both have the patch, is it? Or if I see it in
linux-next, then I may drop it from my tree.
Regards,
Brian
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 7/7] docg3: Fix miuse of seq_printf return value
2014-10-28 17:32 ` Steven Rostedt
2014-10-28 17:36 ` Brian Norris
@ 2014-10-28 17:38 ` Joe Perches
1 sibling, 0 replies; 53+ messages in thread
From: Joe Perches @ 2014-10-28 17:38 UTC (permalink / raw)
To: Steven Rostedt
Cc: Brian Norris, Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds,
David Woodhouse, linux-mtd, linux-kernel
On Tue, 2014-10-28 at 13:32 -0400, Steven Rostedt wrote:
> On Tue, 28 Oct 2014 10:27:40 -0700 Joe Perches <joe@perches.com> wrote:
> > On Tue, 2014-10-28 at 12:05 -0400, Steven Rostedt wrote:
> > > I would like to get this done before I do my merge of trace_seq and
> > > seq_file, but I'm thinking I may have to do that in parallel.
> >
> > I think the most important thing is to get the
> > seq_is_overflown (or seq_has_overflowed or whatever
> > other name is chosen) function added then the rest
> > of the patches can be applied whenever maintainers
> > (or Andrew or trivial or ...) pick them up.
>
> I can get that in without much of an issue. But the merge of trace_seq
> and seq_file would be easier if I didn't have to worry about return
> values. Which is why I want to get this in quickly.
What is the issue there?
^ permalink raw reply [flat|nested] 53+ messages in thread
* Re: [PATCH 0/7] seq_printf cleanups
2014-09-29 23:08 ` [PATCH 0/7] seq_printf cleanups Joe Perches
` (6 preceding siblings ...)
2014-09-29 23:08 ` [PATCH 7/7] docg3: Fix miuse " Joe Perches
@ 2014-10-28 15:32 ` Steven Rostedt
2014-10-28 15:51 ` Joe Perches
7 siblings, 1 reply; 53+ messages in thread
From: Steven Rostedt @ 2014-10-28 15:32 UTC (permalink / raw)
To: Joe Perches
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, linux-doc,
linux-kernel, linux-mtd, netdev, cluster-devel, linux-fsdevel,
netfilter-devel, coreteam
Joe,
If you haven't already done so, can you update checkpatch.pl to
complain if someone checks the return value of seq_printf(),
seq_puts(), or seq_putc().
It should state that those functions will soon be returning void.
Thanks!
-- Steve
^ permalink raw reply [flat|nested] 53+ messages in thread* Re: [PATCH 0/7] seq_printf cleanups
2014-10-28 15:32 ` [PATCH 0/7] seq_printf cleanups Steven Rostedt
@ 2014-10-28 15:51 ` Joe Perches
0 siblings, 0 replies; 53+ messages in thread
From: Joe Perches @ 2014-10-28 15:51 UTC (permalink / raw)
To: Steven Rostedt
Cc: Al Viro, Petr Mladek, Andrew Morton, Linus Torvalds, linux-doc,
linux-kernel, linux-mtd, netdev, cluster-devel, linux-fsdevel,
netfilter-devel, coreteam
On Tue, 2014-10-28 at 11:32 -0400, Steven Rostedt wrote:
> If you haven't already done so, can you update checkpatch.pl to
> complain if someone checks the return value of seq_printf(),
> seq_puts(), or seq_putc().
I'm not sure that matters much as a rule because I
hope soon the compiler will bleat when that happens.
There are several more too:
seq_vprintf
seq_escape
seq_write
seq_bitmap
seq_cpumask/seq_nodemask (and _list variants),
seq_put_decimal_xxx
^ permalink raw reply [flat|nested] 53+ messages in thread