mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
util: buffer: Remove struct member munging
This was meant to stop abusing the members directly, but we don't do this for other internal structs. Additionally this did not stop the test from touching the members. Remove the header obscurization. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Laine Stump <laine@laine.org> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
fb59497484
commit
14f7030f95
@ -23,24 +23,12 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include "c-ctype.h"
|
#include "c-ctype.h"
|
||||||
|
|
||||||
#define __VIR_BUFFER_C__
|
|
||||||
|
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
/* If adding more fields, ensure to edit buf.h to match
|
|
||||||
the number of fields */
|
|
||||||
struct _virBuffer {
|
|
||||||
unsigned int size;
|
|
||||||
unsigned int use;
|
|
||||||
unsigned int error; /* errno value, or -1 for usage error */
|
|
||||||
int indent;
|
|
||||||
char *content;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virBufferFail
|
* virBufferFail
|
||||||
* @buf: the buffer
|
* @buf: the buffer
|
||||||
|
@ -35,19 +35,15 @@
|
|||||||
typedef struct _virBuffer virBuffer;
|
typedef struct _virBuffer virBuffer;
|
||||||
typedef virBuffer *virBufferPtr;
|
typedef virBuffer *virBufferPtr;
|
||||||
|
|
||||||
# ifndef __VIR_BUFFER_C__
|
# define VIR_BUFFER_INITIALIZER { 0, 0, 0, 0, NULL }
|
||||||
# define VIR_BUFFER_INITIALIZER { 0, 0, 0, 0, NULL }
|
|
||||||
|
|
||||||
/* This struct must be kept in sync with the real struct
|
|
||||||
in the buf.c impl file */
|
|
||||||
struct _virBuffer {
|
struct _virBuffer {
|
||||||
unsigned int a;
|
unsigned int size;
|
||||||
unsigned int b;
|
unsigned int use;
|
||||||
unsigned int c;
|
unsigned int error; /* errno value, or -1 for usage error */
|
||||||
int d;
|
int indent;
|
||||||
char *e;
|
char *content;
|
||||||
};
|
};
|
||||||
# endif
|
|
||||||
|
|
||||||
const char *virBufferCurrentContent(virBufferPtr buf);
|
const char *virBufferCurrentContent(virBufferPtr buf);
|
||||||
char *virBufferContentAndReset(virBufferPtr buf);
|
char *virBufferContentAndReset(virBufferPtr buf);
|
||||||
|
@ -29,7 +29,7 @@ static int testBufInfiniteLoop(const void *data)
|
|||||||
* which was the case after the above addchar at the time of the bug.
|
* 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.
|
* This test is a bit fragile, since it relies on virBuffer internals.
|
||||||
*/
|
*/
|
||||||
if (virAsprintf(&addstr, "%*s", buf->a - buf->b - 1, "a") < 0)
|
if (virAsprintf(&addstr, "%*s", buf->size - buf->use - 1, "a") < 0)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (info->doEscape)
|
if (info->doEscape)
|
||||||
|
Loading…
Reference in New Issue
Block a user