Re: [PATCH 1/2] remove all uses of printf's %n

From: Kees Cook
Date: Mon Sep 16 2013 - 10:59:51 EST


On Mon, Sep 16, 2013 at 4:41 AM, Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
> Kees Cook wrote:
>> - seq_printf(m, "%s%d%n", con->name, con->index, &len);
>> - len = 21 - len;
>> + len = m->count;
>> + seq_printf(m, "%s%d", con->name, con->index);
>> + len = 21 - (m->count - len);
>
> Why not to create a new function which returns bytes written?
> The new function does not need to return negative value for indicating errors.

I think it's not worth it for two reasons:

- there are very few callers that need this logic
- it would require a new function for each type of function used
(right now both seq_printf and seq_puts are used).

Perhaps instead of seq->count, there should be an access function?
seq_get_count(seq) or something?

-Kees

--
Kees Cook
Chrome OS Security
--
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/