[CRIU] [PATCHv2 2/3] files: Simplify get_mem_dev_ops
Radostin Stoyanov
rstoyanov1 at gmail.com
Sat Nov 17 14:53:28 MSK 2018
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 at gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov 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 = ®file_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 = ®file_dump_ops;
return ops;
}
--
2.17.2
More information about the CRIU
mailing list