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

Pavel Emelyanov xemul at parallels.com
Tue Jul 31 22:39:05 EDT 2012


On 07/31/2012 07:00 PM, Kinsbursky Stanislav wrote:
> 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.

sprintf(cookie, " %d:", field->number); will fix it.

>>
>>> +	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.
> 




More information about the CRIU mailing list