Patchwork [2/2] vmstate: add VMSTATE_ARRAY_UNSAFE

login
register
mail settings
Submitter Juan Quintela
Date Oct. 19, 2009, 7:07 p.m.
Message ID <298287ae20c9cbd3f30f4997ac874a7cb28a7a54.1255979118.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/36420/
State New
Headers show

Comments

Juan Quintela - Oct. 19, 2009, 7:07 p.m.
Use offset given as an array of type given, without doing typechecking.

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/hw.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
Glauber Costa - Oct. 20, 2009, 2:46 a.m.
On Mon, Oct 19, 2009 at 5:07 PM, Juan Quintela <quintela@redhat.com> wrote:
> Use offset given as an array of type given, without doing typechecking.
>
> +#define VMSTATE_ARRAY_UNSAFE(_field, _state, _num, _version, _info, _type) {\
> +    .name       = (stringify(_field)),                               \
> +    .version_id = (_version),                                        \
> +    .num        = (_num),                                            \
> +    .info       = &(_info),                                          \
> +    .size       = sizeof(_type),                                     \
> +    .flags      = VMS_ARRAY,                                         \
> +    .offset     = offsetof(_state, _field)                           \
> +}
> +
Since we are already being unsafe, can't we pass the size directly,
instead of a type?

Patch

diff --git a/hw/hw.h b/hw/hw.h
index 422cf18..9218905 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -382,6 +382,16 @@  extern const VMStateInfo vmstate_info_buffer;
         + type_check_array(_type,typeof_field(_state, _field),_num)  \
 }

+#define VMSTATE_ARRAY_UNSAFE(_field, _state, _num, _version, _info, _type) {\
+    .name       = (stringify(_field)),                               \
+    .version_id = (_version),                                        \
+    .num        = (_num),                                            \
+    .info       = &(_info),                                          \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_ARRAY,                                         \
+    .offset     = offsetof(_state, _field)                           \
+}
+
 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
     .name         = (stringify(_field)),                              \
     .field_exists = (_test),                                          \