lkml.org 
[lkml]   [2014]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
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);
>



\
 
 \ /
  Last update: 2014-10-28 16:41    [W:0.397 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site