diff mbox

[96/97] vmstate: Rename VMS_VBUFFER to VMST_VBUFFER_INT32 for consintency

Message ID 1396840915-10384-97-git-send-email-quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela April 7, 2014, 3:21 a.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 include/migration/vmstate.h | 6 +++---
 vmstate.c                   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

Comments

Dr. David Alan Gilbert April 7, 2014, 8:45 a.m. UTC | #1
* Juan Quintela (quintela@redhat.com) wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  include/migration/vmstate.h | 6 +++---
>  vmstate.c                   | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 976d83e..145c198 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -96,7 +96,7 @@ enum VMStateFlags {
>      VMS_BUFFER           = 0x020,  /* static sized buffer */
>      VMS_ARRAY_OF_POINTER = 0x040,
>      VMS_VARRAY_UINT16    = 0x080,  /* Array with size in uint16_t field */
> -    VMS_VBUFFER          = 0x100,  /* Buffer with size in int32_t field */
> +    VMS_VBUFFER_INT32    = 0x100,  /* Buffer with size in int32_t field */
>      VMS_VBUFFER_UINT32   = 0x200,  /* Buffer with size in uint32_t field */
>      VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
>      VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
> @@ -436,7 +436,7 @@ extern const VMStateInfo vmstate_info_bitmap;
>      .name         = (stringify(_field)),                             \
>      .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
>      .info         = &vmstate_info_buffer,                            \
> -    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
> +    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \

Are there any real users of the code where it's really an INT32 value - can
we just not kill off the silly idea of signed buffer sizes altogether?

(The only case I can follow through is onenand.c that has a PARTIAL_VBUFFER
based on an 'int' called 'blocks', that's derived during init from an unsigned
value and passed to things like mallocs and memsets, so it's never going to be
negative).

Dave

>      .offset       = offsetof(_state, _field),                        \
>  }
> 
> @@ -480,7 +480,7 @@ extern const VMStateInfo vmstate_info_bitmap;
>      .name         = (stringify(_field)),                             \
>      .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
>      .info         = &vmstate_info_bitmap,                            \
> -    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
> +    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
>      .offset       = offsetof(_state, _field),                        \
>  }
> 
> diff --git a/vmstate.c b/vmstate.c
> index da5c49d..b1ff280 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -33,7 +33,7 @@ static int vmstate_size(void *opaque, VMStateField *field)
>  {
>      int size = field->size;
> 
> -    if (field->flags & VMS_VBUFFER) {
> +    if (field->flags & VMS_VBUFFER_INT32) {
>          size = *(int32_t *)(opaque+field->size_offset);
>      } else if (field->flags & VMS_VBUFFER_UINT32) {
>          size = *(uint32_t *)(opaque+field->size_offset);
> -- 
> 1.9.0
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Juan Quintela April 7, 2014, 9:54 a.m. UTC | #2
"Dr. David Alan Gilbert" <dgilbert@redhat.com> wrote:
> * Juan Quintela (quintela@redhat.com) wrote:
>> Signed-off-by: Juan Quintela <quintela@redhat.com>
>> ---
>>  include/migration/vmstate.h | 6 +++---
>>  vmstate.c                   | 2 +-
>>  2 files changed, 4 insertions(+), 4 deletions(-)
>> 
>> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
>> index 976d83e..145c198 100644
>> --- a/include/migration/vmstate.h
>> +++ b/include/migration/vmstate.h
>> @@ -96,7 +96,7 @@ enum VMStateFlags {
>>      VMS_BUFFER           = 0x020,  /* static sized buffer */
>>      VMS_ARRAY_OF_POINTER = 0x040,
>>      VMS_VARRAY_UINT16    = 0x080,  /* Array with size in uint16_t field */
>> -    VMS_VBUFFER          = 0x100,  /* Buffer with size in int32_t field */
>> +    VMS_VBUFFER_INT32    = 0x100,  /* Buffer with size in int32_t field */
>>      VMS_VBUFFER_UINT32   = 0x200,  /* Buffer with size in uint32_t field */
>>      VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
>>      VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
>> @@ -436,7 +436,7 @@ extern const VMStateInfo vmstate_info_bitmap;
>>      .name         = (stringify(_field)),                             \
>>      .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
>>      .info         = &vmstate_info_buffer,                            \
>> -    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
>> +    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
>
> Are there any real users of the code where it's really an INT32 value - can
> we just not kill off the silly idea of signed buffer sizes altogether?
>
> (The only case I can follow through is onenand.c that has a PARTIAL_VBUFFER
> based on an 'int' called 'blocks', that's derived during init from an unsigned
> value and passed to things like mallocs and memsets, so it's never going to be
> negative).

There is one user :-(

Note the VARRAY thing, where there are more.  And normally it depends on
the target device if it is signed or not

Later, Juan.
diff mbox

Patch

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 976d83e..145c198 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -96,7 +96,7 @@  enum VMStateFlags {
     VMS_BUFFER           = 0x020,  /* static sized buffer */
     VMS_ARRAY_OF_POINTER = 0x040,
     VMS_VARRAY_UINT16    = 0x080,  /* Array with size in uint16_t field */
-    VMS_VBUFFER          = 0x100,  /* Buffer with size in int32_t field */
+    VMS_VBUFFER_INT32    = 0x100,  /* Buffer with size in int32_t field */
     VMS_VBUFFER_UINT32   = 0x200,  /* Buffer with size in uint32_t field */
     VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
     VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
@@ -436,7 +436,7 @@  extern const VMStateInfo vmstate_info_bitmap;
     .name         = (stringify(_field)),                             \
     .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
     .info         = &vmstate_info_buffer,                            \
-    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
+    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
     .offset       = offsetof(_state, _field),                        \
 }

@@ -480,7 +480,7 @@  extern const VMStateInfo vmstate_info_bitmap;
     .name         = (stringify(_field)),                             \
     .size_offset  = vmstate_offset_value(_state, _field_size, int32_t),\
     .info         = &vmstate_info_bitmap,                            \
-    .flags        = VMS_VBUFFER|VMS_POINTER,                         \
+    .flags        = VMS_VBUFFER_INT32|VMS_POINTER,                   \
     .offset       = offsetof(_state, _field),                        \
 }

diff --git a/vmstate.c b/vmstate.c
index da5c49d..b1ff280 100644
--- a/vmstate.c
+++ b/vmstate.c
@@ -33,7 +33,7 @@  static int vmstate_size(void *opaque, VMStateField *field)
 {
     int size = field->size;

-    if (field->flags & VMS_VBUFFER) {
+    if (field->flags & VMS_VBUFFER_INT32) {
         size = *(int32_t *)(opaque+field->size_offset);
     } else if (field->flags & VMS_VBUFFER_UINT32) {
         size = *(uint32_t *)(opaque+field->size_offset);