]> err.no Git - linux-2.6/commit
PNP: fix formatting of dbg_pnp_show_resources() output
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Thu, 31 Jul 2008 07:07:27 +0000 (00:07 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 1 Aug 2008 19:46:41 +0000 (12:46 -0700)
commitea44c1d60df3640bd956a67c392865c44fe9bc45
treea419febccc84cf70c36704f1a444c2c34bda05d7
parent61a2d07d3fb1ac34d142b9b62d4cd60a0f8c229e
PNP: fix formatting of dbg_pnp_show_resources() output

Each resource should be printed on its own line, so start snprintf'ing
at the beginning of the buffer every time through the loop.

Also, use scnprintf() rather than snprintf() when building up the
buffer to print.  scnprintf() returns the number of characters actually
written into the buffer (not including the trailing NULL).

snprintf() returns the number of characters that *would be* written,
assuming everything would fit in the buffer.  That's nice if we want to
resize the buffer to make sure everything fits, but in this case, I
just want to keep from overflowing the buffer, and it's OK if the
output is truncated.

Using snprintf() meant that my "len" could grow to be more than the
the buffer size, which makes "sizeof(buf) - len" negative, which causes
this alarming WARN_ON:
    http://marc.info/?l=linux-kernel&m=121736480005656&w=2

More useful snprintf/scnprintf discussion:
    http://lwn.net/Articles/69419/

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Reported-by: Pete Clements <clem@clem.clem-digital.net>
Cc: Rene Herman <rene.herman@keyaccess.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/pnp/support.c