
On 4/1/19 2:59 AM, Peter Krempa wrote:
On Sat, Mar 30, 2019 at 12:21:51 -0400, Laine Stump wrote:
On 3/29/19 9:33 AM, Peter Krempa wrote:
Use size_t for all sizes. The '*' modifier unfortunately does require an int so a temporary variable is necessary in the tests.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virbuffer.c | 2 +- src/util/virbuffer.h | 6 +++--- tests/virbuftest.c | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) [...]
@@ -29,7 +30,8 @@ static int testBufInfiniteLoop(const void *data) * which was the case after the above addchar at the time of the bug. * This test is a bit fragile, since it relies on virBuffer internals. */ - if (virAsprintf(&addstr, "%*s", buf->size - buf->use - 1, "a") < 0) + len = buf->size - buf->use - 1; + if (virAsprintf(&addstr, "%*s", len, "a") < 0)
If you really wanted to avoid the temporary int (which you've implied you don't like in the commit message), you could just do a typecast in the arg list. That looke worse.
Agreed. It just sounded like maybe you regretted putting in the int, so I was offering you an out :-)