[7/8] tty: Merge tty post actions

Submitted by Pavel Emelianov on May 18, 2017, 9:36 a.m.

Details

Message ID 0c1879e5-4329-5744-d653-5b71c6d10314@virtuozzo.com
State Accepted
Series "Sanitize initialization bits"
Headers show

Commit Message

Pavel Emelianov May 18, 2017, 9:36 a.m.
No need to schedule both post-actions, we can merge them. This
also sanitizes the "void *unised" arguments for both.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/tty.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/tty.c b/criu/tty.c
index eb6c7e4..7888444 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -372,7 +372,7 @@  static int tty_get_index(u32 id)
 }
 
 /* Make sure the active pairs do exist */
-static int tty_verify_active_pairs(void * unused)
+static int tty_verify_active_pairs(void)
 {
 	unsigned long i, unpaired_slaves = 0;
 
@@ -1360,7 +1360,7 @@  static int tty_setup_orphan_slavery(void)
 	return 0;
 }
 
-static int tty_setup_slavery(void * unused)
+static int tty_setup_slavery(void)
 {
 	struct tty_info *info, *peer, *m;
 
@@ -1556,6 +1556,15 @@  struct collect_image_info tty_info_cinfo = {
 	.collect	= collect_one_tty_info_entry,
 };
 
+static int prep_tty_restore(void *unused)
+{
+	if (tty_verify_active_pairs())
+		return -1;
+	if (tty_setup_slavery())
+		return -1;
+	return 0;
+}
+
 static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 {
 	struct tty_info *info = obj;
@@ -1626,8 +1635,7 @@  static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 
 	pr_info("Collected tty ID %#x (%s)\n", info->tfe->id, info->driver->name);
 
-	if (add_post_prepare_cb_once(tty_verify_active_pairs, NULL) ||
-	    add_post_prepare_cb_once(tty_setup_slavery, NULL))
+	if (add_post_prepare_cb_once(prep_tty_restore, NULL))
 		return -1;
 
 	info->fdstore_id = -1;
@@ -2152,7 +2160,7 @@  int tty_post_actions(void)
 {
 	if (tty_verify_ctty())
 		return -1;
-	if (tty_verify_active_pairs(NULL))
+	if (tty_verify_active_pairs())
 		return -1;
 	else if (tty_dump_queued_data())
 		return -1;