[CRIU] Re: [PATCH 3/4] restorer: Do restore futex robust lists

Cyrill Gorcunov gorcunov at openvz.org
Fri Aug 10 04:03:40 EDT 2012


On Fri, Aug 10, 2012 at 11:52:33AM +0400, Pavel Emelyanov wrote:
> On 08/10/2012 10:23 AM, Cyrill Gorcunov wrote:
> > On Fri, Aug 10, 2012 at 06:43:04AM +0400, Pavel Emelyanov wrote:
> >> On 08/09/2012 09:36 PM, Cyrill Gorcunov wrote:
> >>> Updated version attached
> >>
> >> Looks OK. One question:
> >>
> >>> +	if (core->thread_info->has_futex_rla &&
> >>> +	    core->thread_info->has_futex_rla_len) {
> >>
> >> What guarantees, that the optional fields will be set
> >> to zero when absent?
> > 
> > This is done by pb library.
> 
> Even if you don't specify the default value?

Yes, it's a bit tricky :) Lets look at protobuf source code

static size_t
optional_field_get_packed_size (const ProtobufCFieldDescriptor *field,
                                const protobuf_c_boolean *has,
                                const void *member)
{
  if (field->type == PROTOBUF_C_TYPE_MESSAGE
   || field->type == PROTOBUF_C_TYPE_STRING)
    {
      const void *ptr = * (const void * const *) member;
      if (ptr == NULL
       || ptr == field->default_value)
        return 0;
    }
  else
    {
      if (!*has)
        return 0;
    }
  return required_field_get_packed_size (field, member);
}

IOW since these fields are not [string|message] the has_ flag
simply set to false if no value present.

	Cyrill


More information about the CRIU mailing list