[libvirt] [PATCH 2/7] util: buffer: Use 'size_t' for buffer size variables
Peter Krempa
pkrempa at redhat.com
Mon Apr 1 06:59:55 UTC 2019
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 at 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190401/0af67bf9/attachment-0001.sig>
More information about the libvir-list
mailing list