[CRIU] Re: [PATCH 10/11] protobuf: "pretty" engine
Pavel Emelyanov
xemul at parallels.com
Tue Jul 31 10:48:42 EDT 2012
> +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.
> + if (!ptr)
> + return 0;
> + found = sscanf(ptr, "%*[1-9:]%s", field->fmt);
Why sscanf? Why field->fmt = strchr(ptr, :) + 1 is not good?
> + 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".
> pb_show_field(&fd, nr_fields, ctl);
> }
> @@ -269,9 +305,9 @@ static inline void pb_no_payload(int fd, void *obj, int flags) { }
More information about the CRIU
mailing list