[CRIU] [PATCH 1/3] show: Sanitze repeated fields showing routine
Pavel Emelyanov
xemul at parallels.com
Thu Jul 10 06:08:34 PDT 2014
The existing code is quite strange -- it makes the first show outside
of the loop, and check for the return code. I see no reasons for such
loop breakage and the return code from show callbacks is always 0.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
protobuf.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/protobuf.c b/protobuf.c
index 96f19e9..e7a4e64 100644
--- a/protobuf.c
+++ b/protobuf.c
@@ -351,7 +351,6 @@ static void pb_show_repeated(const ProtobufCFieldDescriptor *fd, pb_pr_ctl_t *ct
{
pb_pr_field_t *field = &ctl->cur;
unsigned long counter;
- int done;
if (nr_fields == 0) {
pr_msg("<empty>");
@@ -362,29 +361,19 @@ static void pb_show_repeated(const ProtobufCFieldDescriptor *fd, pb_pr_ctl_t *ct
void *p = field->data;
field->count = nr_fields;
- field->data = (void *)(*(long *)p);
- done = show(field);
- if (done)
- return;
-
- for (p += fsize, counter = 0; counter < nr_fields - 1; counter++, p += fsize) {
- pr_msg(":");
+ for (counter = 0; counter < nr_fields; counter++) {
field->data = (void *)(*(long *)p);
show(field);
+ p += fsize;
}
+
return;
}
field->count = nr_fields;
- done = show(field);
- if (done)
- return;
-
- field->data += fsize;
-
- for (counter = 0; counter < nr_fields - 1; counter++, field->data += fsize) {
- pr_msg(":");
+ for (counter = 0; counter < nr_fields; counter++) {
show(field);
+ field->data += fsize;
}
}
--
1.8.4.2
More information about the CRIU
mailing list