[CRIU] [PATCH 6/7] timerfd: Rework parse_fdinfo not to use callback

Pavel Emelyanov xemul at virtuozzo.com
Thu Jun 22 20:40:19 MSK 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/include/fdinfo.h |  1 -
 criu/proc_parse.c     |  9 ++-------
 criu/timerfd.c        | 25 ++++++++++---------------
 3 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/criu/include/fdinfo.h b/criu/include/fdinfo.h
index ef7c3f6..ab1f122 100644
--- a/criu/include/fdinfo.h
+++ b/criu/include/fdinfo.h
@@ -10,7 +10,6 @@
 #include "images/timerfd.pb-c.h"
 
 union fdinfo_entries {
-	TimerfdEntry tfy;
 };
 
 struct fdinfo_common {
diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index f4de451..b745cde 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -1685,8 +1685,6 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
 		return -1;
 
 	while (1) {
-		union fdinfo_entries entry;
-
 		str = breadline(&f);
 		if (!str)
 			break;
@@ -1768,16 +1766,13 @@ static int parse_fdinfo_pid_s(int pid, int fd, int type,
 			continue;
 		}
 		if (fdinfo_field(str, "clockid")) {
-			timerfd_entry__init(&entry.tfy);
+			TimerfdEntry *tfe = arg;
 
 			if (type != FD_TYPES__TIMERFD)
 				goto parse_err;
-			ret = parse_timerfd(&f, str, &entry.tfy);
+			ret = parse_timerfd(&f, str, tfe);
 			if (ret)
 				goto parse_err;
-			ret = cb(&entry, arg);
-			if (ret)
-				goto out;
 
 			entry_met = true;
 			continue;
diff --git a/criu/timerfd.c b/criu/timerfd.c
index 476bf60..60f77fc 100644
--- a/criu/timerfd.c
+++ b/criu/timerfd.c
@@ -64,26 +64,21 @@ int is_timerfd_link(char *link)
 	return is_anon_link_type(link, "[timerfd]");
 }
 
-static int dump_timerfd_entry(union fdinfo_entries *e, void *arg)
+static int dump_one_timerfd(int lfd, u32 id, const struct fd_parms *p)
 {
-	struct timerfd_dump_arg *da = arg;
-	TimerfdEntry *tfy = &e->tfy;
+	TimerfdEntry tfe = TIMERFD_ENTRY__INIT;
 
-	tfy->id		= da->id;
-	tfy->flags	= da->p->flags;
-	tfy->fown	= (FownEntry *)&da->p->fown;
+	if (parse_fdinfo(lfd, FD_TYPES__TIMERFD, NULL, &tfe))
+		return -1;
 
+	tfe.id = id;
+	tfe.flags = p->flags;
+	tfe.fown = (FownEntry *)&p->fown;
 	pr_info("Dumping id %#x clockid %d it_value(%llu, %llu) it_interval(%llu, %llu)\n",
-		tfy->id, tfy->clockid, (unsigned long long)tfy->vsec, (unsigned long long)tfy->vnsec,
-		(unsigned long long)tfy->isec, (unsigned long long)tfy->insec);
-
-	return pb_write_one(img_from_set(glob_imgset, CR_FD_TIMERFD), &e->tfy, PB_TIMERFD);
-}
+		tfe.id, tfe.clockid, (unsigned long long)tfe.vsec, (unsigned long long)tfe.vnsec,
+		(unsigned long long)tfe.isec, (unsigned long long)tfe.insec);
 
-static int dump_one_timerfd(int lfd, u32 id, const struct fd_parms *p)
-{
-	struct timerfd_dump_arg da = { .id = id, .p = p, };
-	return parse_fdinfo(lfd, FD_TYPES__TIMERFD, dump_timerfd_entry, &da);
+	return pb_write_one(img_from_set(glob_imgset, CR_FD_TIMERFD), &tfe, PB_TIMERFD);
 }
 
 const struct fdtype_ops timerfd_dump_ops = {
-- 
2.1.4



More information about the CRIU mailing list