> 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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/