diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-07-31 00:07:27 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-01 12:46:41 -0700 |
commit | ea44c1d60df3640bd956a67c392865c44fe9bc45 (patch) | |
tree | a419febccc84cf70c36704f1a444c2c34bda05d7 /scripts/unifdef.c | |
parent | 61a2d07d3fb1ac34d142b9b62d4cd60a0f8c229e (diff) | |
download | op-kernel-dev-ea44c1d60df3640bd956a67c392865c44fe9bc45.zip op-kernel-dev-ea44c1d60df3640bd956a67c392865c44fe9bc45.tar.gz |
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>
Diffstat (limited to 'scripts/unifdef.c')
0 files changed, 0 insertions, 0 deletions