[CRIU] [PATCH 2/3] files: Simplify get_mem_dev_ops

Radostin Stoyanov rstoyanov1 at gmail.com
Sat Nov 17 00:28:52 MSK 2018


Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
 criu/files.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 0f88912a..31f847ee 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -426,21 +426,14 @@ static const struct fdtype_ops *get_mem_dev_ops(struct fd_parms *p, int minor)
 {
 	const struct fdtype_ops *ops = NULL;
 
-	switch (minor) {
-	case 11:
-		/*
-		 * If /dev/kmsg is opened in write-only mode the file position
-		 * should not be set up upon restore, kernel doesn't allow that.
-		 */
-		if ((p->flags & O_ACCMODE) == O_WRONLY && p->pos == 0)
-			p->pos = -1ULL;
-		/*
-		 * Fallthrough.
-		 */
-	default:
-		ops = &regfile_dump_ops;
-		break;
-	};
+	/*
+	 * If /dev/kmsg is opened in write-only mode the file position
+	 * should not be set up upon restore, kernel doesn't allow that.
+	 */
+	if (minor == 11 && (p->flags & O_ACCMODE) == O_WRONLY && p->pos == 0)
+		p->pos = -1ULL;
+
+	ops = &regfile_dump_ops;
 
 	return ops;
 }
-- 
2.17.2



More information about the CRIU mailing list