Re: [PATCH 6/7] debugfs: Fix misuse of seq_printf return value
From: Steven Rostedt
Date: Tue Oct 28 2014 - 10:58:50 EST
On Mon, 29 Sep 2014 16:08:26 -0700
Joe Perches <joe@xxxxxxxxxxx> 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@xxxxxxxxxxx>
> ---
> 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);
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/