Merge branch 'vmstate' into 'master'

Fix vmstate regression

See merge request slirp/libslirp!127
diff --git a/src/state.c b/src/state.c
index d5689ba..f10edf0 100644
--- a/src/state.c
+++ b/src/state.c
@@ -26,8 +26,6 @@
 #include "vmstate.h"
 #include "stream.h"
 
-#ifdef HAVE_VMSTATE
-
 static int slirp_tcp_post_load(void *opaque, int version)
 {
     tcp_template((struct tcpcb *)opaque);
@@ -377,19 +375,6 @@
     return slirp_vmstate_load_state(&f, &vmstate_slirp, slirp, version_id);
 }
 
-#else /* HAVE_VMSTATE */
-int slirp_state_save(Slirp *slirp, SlirpWriteCb write_cb, void *opaque)
-{
-    return -ENOSYS;
-}
-
-int slirp_state_load(Slirp *slirp, int version_id, SlirpReadCb read_cb,
-                     void *opaque)
-{
-    return -ENOSYS;
-}
-#endif /* HAVE_VMSTATE */
-
 int slirp_state_version(void)
 {
     return 4;
diff --git a/src/vmstate.c b/src/vmstate.c
index c7fc5a3..2c3a727 100644
--- a/src/vmstate.c
+++ b/src/vmstate.c
@@ -45,8 +45,6 @@
 #include "stream.h"
 #include "vmstate.h"
 
-#ifdef HAVE_VMSTATE
-
 static int get_nullptr(SlirpIStream *f, void *pv, size_t size,
                        const VMStateField *field)
 {
@@ -259,7 +257,7 @@
     .put = put_buffer,
 };
 
-static int vmstate_n_elems(void *opaque, const VMStateField *field)
+static int vmstate_n_elems(char *opaque, const VMStateField *field)
 {
     int n_elems = 1;
 
@@ -282,7 +280,7 @@
     return n_elems;
 }
 
-static int vmstate_size(void *opaque, const VMStateField *field)
+static int vmstate_size(char *opaque, const VMStateField *field)
 {
     int size = field->size;
 
@@ -297,7 +295,7 @@
 }
 
 static int vmstate_save_state_v(SlirpOStream *f, const VMStateDescription *vmsd,
-                                void *opaque, int version_id)
+                                char *opaque, int version_id)
 {
     int ret = 0;
     const VMStateField *field = vmsd->fields;
@@ -313,7 +311,7 @@
     while (field->name) {
         if ((field->field_exists && field->field_exists(opaque, version_id)) ||
             (!field->field_exists && field->version_id <= version_id)) {
-            void *first_elem = opaque + field->offset;
+            char *first_elem = opaque + field->offset;
             int i, n_elems = vmstate_n_elems(opaque, field);
             int size = vmstate_size(opaque, field);
 
@@ -378,10 +376,11 @@
 }
 
 int slirp_vmstate_load_state(SlirpIStream *f, const VMStateDescription *vmsd,
-                             void *opaque, int version_id)
+                             void *opaque_, int version_id)
 {
     VMStateField *field = vmsd->fields;
     int ret = 0;
+    char *opaque = opaque_;
 
     if (version_id > vmsd->version_id) {
         g_warning("%s: incoming version_id %d is too new "
@@ -398,7 +397,7 @@
     while (field->name) {
         if ((field->field_exists && field->field_exists(opaque, version_id)) ||
             (!field->field_exists && field->version_id <= version_id)) {
-            void *first_elem = opaque + field->offset;
+            char *first_elem = opaque + field->offset;
             int i, n_elems = vmstate_n_elems(opaque, field);
             int size = vmstate_size(opaque, field);
 
@@ -444,5 +443,3 @@
     }
     return ret;
 }
-
-#endif /* HAVE_VMSTATE */