[CRIU] [PATCH 4/9] pie/vdso: convert (char *mem) to (uintptr_t mem)

Dmitry Safonov dsafonov at virtuozzo.com
Wed Mar 30 08:12:25 PDT 2016


Impact: drop additional casts all around. Cleanup.

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/include/parasite-vdso.h |  1 -
 criu/include/util-vdso.h     |  2 +-
 criu/pie/parasite-vdso.c     |  3 ++-
 criu/pie/parasite.c          |  2 +-
 criu/pie/util-vdso.c         | 15 +++++++--------
 criu/vdso.c                  |  2 +-
 6 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/criu/include/parasite-vdso.h b/criu/include/parasite-vdso.h
index 295430f6195a..530cc01cb5e4 100644
--- a/criu/include/parasite-vdso.h
+++ b/criu/include/parasite-vdso.h
@@ -80,7 +80,6 @@ static inline bool is_vdso_mark(void *addr)
 }
 
 extern int vdso_do_park(struct vdso_symtable *sym_rt, unsigned long park_at, unsigned long park_size);
-extern int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t);
 extern int vdso_proxify(char *who, struct vdso_symtable *sym_rt,
 			unsigned long vdso_rt_parked_at, size_t index,
 			VmaEntry *vmas, size_t nr_vmas);
diff --git a/criu/include/util-vdso.h b/criu/include/util-vdso.h
index d3903572a97c..43f7549c822e 100644
--- a/criu/include/util-vdso.h
+++ b/criu/include/util-vdso.h
@@ -88,6 +88,6 @@ static inline unsigned long vvar_vma_size(struct vdso_symtable *t)
 	return t->vvar_end - t->vvar_start;
 }
 
-extern int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t);
+extern int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t);
 
 #endif /* __CR_UTIL_VDSO_H__ */
diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c
index 9ee42e52875a..c8cb34f8708c 100644
--- a/criu/pie/parasite-vdso.c
+++ b/criu/pie/parasite-vdso.c
@@ -105,7 +105,8 @@ int vdso_proxify(char *who, struct vdso_symtable *sym_rt,
 	/*
 	 * Find symbols in vDSO zone read from image.
 	 */
-	if (vdso_fill_symtable((void *)vma_vdso->start, vma_entry_len(vma_vdso), &s))
+	if (vdso_fill_symtable((uintptr_t)vma_vdso->start,
+				vma_entry_len(vma_vdso), &s))
 		return -1;
 
 	/*
diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c
index 5b45048b91f5..8fb7d21667f3 100644
--- a/criu/pie/parasite.c
+++ b/criu/pie/parasite.c
@@ -508,7 +508,7 @@ static int parasite_check_vdso_mark(struct parasite_vdso_vma_entry *args)
 		if (args->try_fill_symtable) {
 			struct vdso_symtable t;
 
-			if (vdso_fill_symtable((void *)args->start, args->len, &t))
+			if (vdso_fill_symtable(args->start, args->len, &t))
 				args->is_vdso = false;
 			else
 				args->is_vdso = true;
diff --git a/criu/pie/util-vdso.c b/criu/pie/util-vdso.c
index b388916fbc2f..1c3f7ec38f3a 100644
--- a/criu/pie/util-vdso.c
+++ b/criu/pie/util-vdso.c
@@ -25,9 +25,8 @@
 #define LOG_PREFIX "vdso: "
 
 /* Check if pointer is out-of-bound */
-static bool __ptr_oob(uintptr_t ptr, void *mem, size_t size)
+static bool __ptr_oob(uintptr_t ptr, uintptr_t start, size_t size)
 {
-	uintptr_t start = (uintptr_t)mem;
 	uintptr_t end = start + size;
 
 	return ptr > end || ptr < start;
@@ -77,7 +76,7 @@ static int has_elf_identity(Ehdr_t *ehdr)
 	return true;
 }
 
-int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
+int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t)
 {
 	const char *vdso_symbols[VDSO_SYMBOL_MAX] = {
 		ARCH_VDSO_SYMBOLS
@@ -113,7 +112,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
 	/*
 	 * We need PT_LOAD and PT_DYNAMIC here. Each once.
 	 */
-	addr = (uintptr_t)mem + ehdr->e_phoff;
+	addr = mem + ehdr->e_phoff;
 	for (i = 0; i < ehdr->e_phnum; i++, addr += sizeof(Phdr_t)) {
 		if (__ptr_oob(addr, mem, size))
 			goto err_oob;
@@ -147,7 +146,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
 	 * Dynamic section tags should provide us the rest of information
 	 * needed. Note that we're interested in a small set of tags.
 	 */
-	addr = (uintptr_t)mem + dynamic->p_offset;
+	addr = mem + dynamic->p_offset;
 	for (i = 0; i < dynamic->p_filesz / sizeof(*d);
 			i++, addr += sizeof(Dyn_t)) {
 		if (__ptr_oob(addr, mem, size))
@@ -179,12 +178,12 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
 		return -EINVAL;
 	}
 
-	addr = (uintptr_t)mem + dyn_strtab->d_un.d_val - load->p_vaddr;
+	addr = mem + dyn_strtab->d_un.d_val - load->p_vaddr;
 	if (__ptr_oob(addr, mem, size))
 		goto err_oob;
 	dynsymbol_names = (void *)addr;
 
-	addr = (uintptr_t)mem + dyn_hash->d_un.d_ptr - load->p_vaddr;
+	addr = mem + dyn_hash->d_un.d_ptr - load->p_vaddr;
 	if (__ptr_oob(addr, mem, size))
 		goto err_oob;
 	hash = (void *)addr;
@@ -202,7 +201,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
 		k = elf_hash((const unsigned char *)symbol);
 
 		for (j = bucket[k % nbucket]; j < nchain && chain[j] != STN_UNDEF; j = chain[j]) {
-			addr = (uintptr_t)mem + dyn_symtab->d_un.d_ptr - load->p_vaddr;
+			addr = mem + dyn_symtab->d_un.d_ptr - load->p_vaddr;
 			Sym_t *sym;
 			char *name;
 
diff --git a/criu/vdso.c b/criu/vdso.c
index bccf11cc11f8..517755513555 100644
--- a/criu/vdso.c
+++ b/criu/vdso.c
@@ -257,7 +257,7 @@ static int vdso_fill_self_symtable(struct vdso_symtable *s)
 			s->vma_start = start;
 			s->vma_end = end;
 
-			ret = vdso_fill_symtable((void *)start, end - start, s);
+			ret = vdso_fill_symtable(start, end - start, s);
 			if (ret)
 				goto err;
 		} else {
-- 
2.7.4



More information about the CRIU mailing list