[CRIU] [PATCH 3/7] files.c cleanup: use const where possible

Kir Kolyshkin kir at openvz.org
Fri Feb 10 18:30:06 EST 2012


Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 files.c |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/files.c b/files.c
index 9e5decc..23a8f3e 100644
--- a/files.c
+++ b/files.c
@@ -59,7 +59,7 @@ static int nr_fdinfo_list;
 
 static struct fmap_fd *fmap_fds;
 
-static struct fdinfo_desc *find_fd(char *id)
+static struct fdinfo_desc *find_fd(const char *id)
 {
 	struct fdinfo_desc *fi;
 	int i;
@@ -73,7 +73,7 @@ static struct fdinfo_desc *find_fd(char *id)
 	return NULL;
 }
 
-static int get_file_path(char *path, struct fdinfo_entry *fe, int fd)
+static int get_file_path(char *path, const struct fdinfo_entry *fe, int fd)
 {
 	if (read(fd, path, fe->len) != fe->len) {
 		pr_perror("Error reading path");
@@ -103,7 +103,7 @@ int prepare_fdinfo_global()
 	return 0;
 }
 
-static int collect_fd(int pid, struct fdinfo_entry *e)
+static int collect_fd(int pid, const struct fdinfo_entry *e)
 {
 	int i;
 	struct fdinfo_list_entry *le = &fdinfo_list[nr_fdinfo_list];
@@ -123,7 +123,7 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
 
 	for (i = 0; i < nr_fdinfo_descs; i++) {
 		desc = &fdinfo_descs[i];
-		if (strncmp(desc->id, (char *) e->id, FD_ID_SIZE))
+		if (strncmp(desc->id, (char *)e->id, FD_ID_SIZE))
 			continue;
 
 		fdinfo_descs[i].users++;
@@ -192,7 +192,7 @@ int prepare_fd_pid(int pid)
 	return ret;
 }
 
-static int open_fe_fd(struct fdinfo_entry *fe, int fd)
+static int open_fe_fd(const struct fdinfo_entry *fe, int fd)
 {
 	char path[PATH_MAX];
 	int tmp;
@@ -211,7 +211,7 @@ static int open_fe_fd(struct fdinfo_entry *fe, int fd)
 	return tmp;
 }
 
-static int restore_cwd(struct fdinfo_entry *fe, int fd)
+static int restore_cwd(const struct fdinfo_entry *fe, int fd)
 {
 	char path[PATH_MAX];
 	int ret;
@@ -229,7 +229,7 @@ static int restore_cwd(struct fdinfo_entry *fe, int fd)
 	return 0;
 }
 
-static int restore_exe_early(struct fdinfo_entry *fe, int fd)
+static int restore_exe_early(const struct fdinfo_entry *fe, int fd)
 {
 	/*
 	 * We restore the EXE symlink at very late stage
@@ -241,7 +241,7 @@ static int restore_exe_early(struct fdinfo_entry *fe, int fd)
 }
 
 struct fdinfo_list_entry *find_fdinfo_list_entry(int pid, int fd,
-		struct fdinfo_desc *fi)
+		const struct fdinfo_desc *fi)
 {
 	struct fdinfo_list_entry *fle;
 	int found = 0;
@@ -257,8 +257,8 @@ struct fdinfo_list_entry *find_fdinfo_list_entry(int pid, int fd,
 	return fle;
 }
 
-static int open_transport_fd(int pid, struct fdinfo_entry *fe,
-				struct fdinfo_desc *fi)
+static int open_transport_fd(int pid, const struct fdinfo_entry *fe,
+				const struct fdinfo_desc *fi)
 {
 	struct fdinfo_list_entry *fle;
 	struct sockaddr_un saddr;
@@ -303,8 +303,8 @@ static int open_transport_fd(int pid, struct fdinfo_entry *fe,
 	return 0;
 }
 
-static int open_fd(int pid, struct fdinfo_entry *fe,
-				struct fdinfo_desc *fi, int fdinfo_fd)
+static int open_fd(int pid, const struct fdinfo_entry *fe,
+		struct fdinfo_desc *fi, int fdinfo_fd)
 {
 	int tmp;
 	int serv, sock;
@@ -367,7 +367,8 @@ out:
 	return 0;
 }
 
-static int receive_fd(int pid, struct fdinfo_entry *fe, struct fdinfo_desc *fi)
+static int receive_fd(int pid, const struct fdinfo_entry *fe,
+		const struct fdinfo_desc *fi)
 {
 	int tmp;
 
@@ -397,7 +398,7 @@ static int receive_fd(int pid, struct fdinfo_entry *fe, struct fdinfo_desc *fi)
 	return reopen_fd_as((int)fe->addr, tmp);
 }
 
-static int open_fmap(int pid, struct fdinfo_entry *fe, int fd)
+static int open_fmap(int pid, const struct fdinfo_entry *fe, int fd)
 {
 	struct fmap_fd *new;
 	int tmp;
@@ -425,7 +426,7 @@ static int open_fmap(int pid, struct fdinfo_entry *fe, int fd)
 	return 0;
 }
 
-static int open_fdinfo(int pid, struct fdinfo_entry *fe, int *fdinfo_fd,
+static int open_fdinfo(int pid, const struct fdinfo_entry *fe, int *fdinfo_fd,
 		int state)
 {
 	u32 mag;
@@ -457,7 +458,7 @@ static int open_fdinfo(int pid, struct fdinfo_entry *fe, int *fdinfo_fd,
 	return ret;
 }
 
-static int open_special_fdinfo(int pid, struct fdinfo_entry *fe,
+static int open_special_fdinfo(int pid, const struct fdinfo_entry *fe,
 		int fdinfo_fd, int state)
 {
 	if (state != FD_STATE_RECV) {
-- 
1.7.7.6



More information about the CRIU mailing list