mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
util: buffer: Use 'size_t' for buffer size variables
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> Reviewed-by: Laine Stump <laine@laine.org>
This commit is contained in:
parent
14f7030f95
commit
29ad523018
@ -339,7 +339,7 @@ virBufferCheckErrorInternal(const virBuffer *buf,
|
||||
*
|
||||
* Return the string usage in bytes
|
||||
*/
|
||||
unsigned int
|
||||
size_t
|
||||
virBufferUse(const virBuffer *buf)
|
||||
{
|
||||
if (buf == NULL)
|
||||
|
@ -38,8 +38,8 @@ typedef virBuffer *virBufferPtr;
|
||||
# define VIR_BUFFER_INITIALIZER { 0, 0, 0, 0, NULL }
|
||||
|
||||
struct _virBuffer {
|
||||
unsigned int size;
|
||||
unsigned int use;
|
||||
size_t size;
|
||||
size_t use;
|
||||
unsigned int error; /* errno value, or -1 for usage error */
|
||||
int indent;
|
||||
char *content;
|
||||
@ -69,7 +69,7 @@ VIR_DEFINE_AUTOCLEAN_FUNC(virBuffer, virBufferFreeAndReset);
|
||||
# define virBufferCheckError(buf) \
|
||||
virBufferCheckErrorInternal(buf, VIR_FROM_THIS, __FILE__, __FUNCTION__, \
|
||||
__LINE__)
|
||||
unsigned int virBufferUse(const virBuffer *buf);
|
||||
size_t virBufferUse(const virBuffer *buf);
|
||||
void virBufferAdd(virBufferPtr buf, const char *str, int len);
|
||||
void virBufferAddBuffer(virBufferPtr buf, virBufferPtr toadd);
|
||||
void virBufferAddChar(virBufferPtr buf, char c);
|
||||
|
@ -20,6 +20,7 @@ static int testBufInfiniteLoop(const void *data)
|
||||
char *addstr = NULL, *bufret = NULL;
|
||||
int ret = -1;
|
||||
const struct testInfo *info = data;
|
||||
int len;
|
||||
|
||||
virBufferAddChar(buf, 'a');
|
||||
|
||||
@ -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)
|
||||
goto out;
|
||||
|
||||
if (info->doEscape)
|
||||
|
Loading…
Reference in New Issue
Block a user