]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: buffer: Remove struct member munging
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Mar 2019 15:54:28 +0000 (16:54 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Apr 2019 09:58:10 +0000 (11:58 +0200)
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>
src/util/virbuffer.c
src/util/virbuffer.h
tests/virbuftest.c

index 12bdd13d394e45d0af43f7f993437134fe3982a3..8bb9c8e1fae101a3b02a2fccbaa0fe4d89dbcd35 100644 (file)
 #include <stdarg.h>
 #include "c-ctype.h"
 
-#define __VIR_BUFFER_C__
-
 #include "virbuffer.h"
 #include "virerror.h"
 #include "virstring.h"
 
 #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
  * @buf: the buffer
index b399c9015477f2d1db2efdbb76127f3fba8102eb..16cd8515d6d7142f5c51335527e42157f94b5f20 100644 (file)
 typedef struct _virBuffer virBuffer;
 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 {
-    unsigned int a;
-    unsigned int b;
-    unsigned int c;
-    int d;
-    char *e;
+    unsigned int size;
+    unsigned int use;
+    unsigned int error; /* errno value, or -1 for usage error */
+    int indent;
+    char *content;
 };
-# endif
 
 const char *virBufferCurrentContent(virBufferPtr buf);
 char *virBufferContentAndReset(virBufferPtr buf);
index 34f02b128120abf95baf0ac324925d2f771f6579..b608da94d490fae30bb321a05aecc2a3efe4005f 100644 (file)
@@ -29,7 +29,7 @@ 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->a - buf->b - 1, "a") < 0)
+    if (virAsprintf(&addstr, "%*s", buf->size - buf->use - 1, "a") < 0)
         goto out;
 
     if (info->doEscape)