]> git.baikalelectronics.ru Git - kernel.git/commit
perf tools: Fix strbuf_addf() when the buffer needs to grow
authorNamhyung Kim <namhyung@kernel.org>
Tue, 23 Oct 2012 13:44:50 +0000 (22:44 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 30 Oct 2012 12:32:56 +0000 (10:32 -0200)
commitf9a7ece824b8d6e863343b5733544aafa8241348
tree844cabbae20e511912261ca2ad3ece33852e5bd3
parent8553de7182e80457a7163720f2e453cac1d57ac1
perf tools: Fix strbuf_addf() when the buffer needs to grow

This was found during chasing down the header output regression.  The
strbuf_addf() was checking buffer length with a result of vscnprintf()
which cannot be greater than that of strbuf_avail().

Since numa topology and pmu mapping info in header were converted to use
strbuf, it sometimes caused uninteresting behaviors with the broken
strbuf.

Fix it by using vsnprintf() which returns desired output string length
regardless of the available buffer size and grow the buffer if needed.

Reported-by: Andrew Jones <drjones@redhat.com>
Tested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andrew Jones <drjones@redhat.com>
Link: http://lkml.kernel.org/r/1350999890-6920-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/strbuf.c