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

From: George Spelvin
Date: Mon Sep 16 2013 - 13:21:49 EST


> My thought was to add a seq_last_len()

In addition to adding per-call overhead to support a rarely-used feature
(while ->pos comes for free), this has the downside that it matters how
many separate calls are used to generate the string.

The advantage of the "read ->pos before and after" technique is that
you can have an arbitrary number of output calls in between.
Including things like seq_path(), seq_bitmap(), etc.

If you have the printing done in a subroutine (as in the net/ipv4
directory), it would be annoyingly subtle if seq_puts("foobar")
were not equivalent to seq_puts("foo"); seq_puts("bar").


I agree that exposing the internals via ->pos is a bit ugly, but too
many levels of abstraction makes code hard to read, too, and it's very
straightforward to find and fix the dozen or so places where it's accessed
in the unlikely case that the internals of seq_file change significantly.

My take on it is "not worth fixing".
--
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/