[2/3] files: Simplify get_mem_dev_ops

Submitted by Radostin Stoyanov on Nov. 16, 2018, 9:28 p.m.

Details

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

Commit Message

Radostin Stoyanov Nov. 16, 2018, 9:28 p.m.
Signed-off-by: Radostin Stoyanov <rstoyanov1@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;
 }

Comments

Cyrill Gorcunov Nov. 16, 2018, 9:56 p.m.
On Fri, Nov 16, 2018 at 09:28:52PM +0000, Radostin Stoyanov wrote:
> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
> ---

You know the former 'case' statement has been used for one purpose
only -- to be able to extend this code in future, so if there more
minors number appear you won't need to modify much code but add
a new 'case'. Still I don't expect its extension in near future, so

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>