[CRIU] Re: [PATCH 10/11] protobuf: "pretty" engine

Kinsbursky Stanislav skinsbursky at openvz.org
Tue Jul 31 11:00:33 EDT 2012


31.07.2012 18:48, Pavel Emelyanov пишет:
>> +static int pb_field_show_pretty(pb_pr_ctl_t *ctl)
>> +{
>> +	pb_pr_field_t *field = &ctl->cur;
>> +	int found;
>> +	char cookie[32];
>> +	char *ptr;
>> +
>> +	if (!ctl->pretty_fmt)
>> +		return 0;
>> +
>> +	sprintf(cookie, "%d:", field->number);
>> +	ptr = strstr(ctl->pretty_fmt, cookie);
> The "11:%x 1:%d" format will be interpreted with an error I suppose.

Yes.

>
>> +	if (!ptr)
>> +		return 0;
>> +	found = sscanf(ptr, "%*[1-9:]%s", field->fmt);
> Why sscanf? Why field->fmt = strchr(ptr, :) + 1 is not good?

It was just done that way. I can change ssacnf to strchr.

>
>> +	BUG_ON(found > 1);
>> +	return found;
>> +}
>> @@ -259,6 +294,7 @@ static void pb_show_msg(const void *msg, pb_pr_ctl_t *ctl)
>>   		}
>>   
>>   		ctl->cur.data = data;
>> +		ctl->cur.number = i + 1;
> It should be not "the number of field in a structure" but "the number of field in proto file".

And it is.

-- 
Best regards,
Stanislav Kinsbursky




More information about the CRIU mailing list