[PATCHv2,2/3] files: Simplify get_mem_dev_ops

Submitted by Radostin Stoyanov on Nov. 17, 2018, 11:53 a.m.

Details

Message ID 20181117115329.16424-2-rstoyanov1@gmail.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Radostin Stoyanov Nov. 17, 2018, 11:53 a.m.
The former 'case' statement was used to allow the code to be easily
extended in the future (e.g. if there are more minor numbers to
be added we would not have to modify much code but simply add a new
'case'). However, we don't expect such extension in the near future.

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

Patch hide | download patch | download mbox

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;
 }