[CRIU] [PATCH 3/4] piegen: opts variable is global

Laurent Dufour ldufour at linux.vnet.ibm.com
Wed Jun 10 06:00:41 PDT 2015


Since opts is defined as extern in piegen.h, there is no need to pass it as
argument.

Signed-off-by: Laurent Dufour <ldufour at linux.vnet.ibm.com>
---
 pie/piegen/elf.c    | 12 ++++++------
 pie/piegen/main.c   | 10 +++++-----
 pie/piegen/piegen.h |  8 ++++----
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/pie/piegen/elf.c b/pie/piegen/elf.c
index 33bc000011b9..6c5099d4bdab 100644
--- a/pie/piegen/elf.c
+++ b/pie/piegen/elf.c
@@ -62,7 +62,7 @@ static int do_relative_toc(long value, uint16_t *location,
 }
 #endif
 
-int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
+int handle_elf(void *mem, size_t size)
 {
 	const char *symstrings = NULL;
 	Shdr_t *symtab_hdr = NULL;
@@ -154,7 +154,7 @@ int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
 		goto err;
 	}
 
-	pr_out("/* Autogenerated from %s */\n", opts->input_filename);
+	pr_out("/* Autogenerated from %s */\n", opts.input_filename);
 	pr_out("#include \"piegen/uapi/types.h\"\n");
 
 	for (i = 0; i < symtab_hdr->sh_size / symtab_hdr->sh_entsize; i++) {
@@ -190,13 +190,13 @@ int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
 				    ELF_ST_TYPE(sym->st_info) == STT_OBJECT)
 #endif
 					pr_out("#define %s%s 0x%lx\n",
-					       opts->prefix_name, name,
+					       opts.prefix_name, name,
 					       (unsigned long)(sym->st_value + sh_src->sh_addr));
 			}
 		}
 	}
 
-	pr_out("static __maybe_unused elf_reloc_t %s[] = {\n", opts->var_name);
+	pr_out("static __maybe_unused elf_reloc_t %s[] = {\n", opts.var_name);
 
 	pr_debug("Relocations\n------------\n");
 	for (i = 0; i < hdr->e_shnum; i++) {
@@ -457,9 +457,9 @@ int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
 		}
 	}
 	pr_out("};\n");
-	pr_out("static __maybe_unused size_t %s = %zd;\n", opts->nrgotpcrel_name, nr_gotpcrel);
+	pr_out("static __maybe_unused size_t %s = %zd;\n", opts.nrgotpcrel_name, nr_gotpcrel);
 
-	pr_out("static __maybe_unused const char %s[] = {\n\t", opts->stream_name);
+	pr_out("static __maybe_unused const char %s[] = {\n\t", opts.stream_name);
 
 	for (i=0, k=0; i < hdr->e_shnum; i++) {
 		size_t j;
diff --git a/pie/piegen/main.c b/pie/piegen/main.c
index d1e90f6192fc..d3ad823339bb 100644
--- a/pie/piegen/main.c
+++ b/pie/piegen/main.c
@@ -27,7 +27,7 @@ piegen_opt_t opts = {
 
 FILE *fout;
 
-static int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
+static int handle_elf(void *mem, size_t size)
 {
 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
 	unsigned char elf_ident_x86_32[EI_NIDENT] = {
@@ -41,9 +41,9 @@ static int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
 	};
 
 	if (memcmp(mem, elf_ident_x86_32, sizeof(elf_ident_x86_32)) == 0)
-		return handle_elf_x86_32(opts, mem, size);
+		return handle_elf_x86_32(mem, size);
 	else if (memcmp(mem, elf_ident_x86_64, sizeof(elf_ident_x86_64)) == 0)
-		return handle_elf_x86_64(opts, mem, size);
+		return handle_elf_x86_64(mem, size);
 #endif
 
 #if defined(CONFIG_PPC64)
@@ -58,7 +58,7 @@ static int handle_elf(const piegen_opt_t *opts, void *mem, size_t size)
 	};
 
 	if (memcmp(mem, elf_ident, sizeof(elf_ident)) == 0)
-		return handle_elf_ppc64(opts, mem, size);
+		return handle_elf_ppc64(mem, size);
 #endif /* CONFIG_PPC64 */
 
 	pr_err("Unsupported Elf format detected\n");
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
 		goto err;
 	}
 
-	if (handle_elf(&opts, mem, st.st_size)) {
+	if (handle_elf(mem, st.st_size)) {
 		fclose(fout);
 		unlink(opts.output_filename);
 		goto err;
diff --git a/pie/piegen/piegen.h b/pie/piegen/piegen.h
index 02d431a93913..0f64cbd8fe77 100644
--- a/pie/piegen/piegen.h
+++ b/pie/piegen/piegen.h
@@ -17,17 +17,17 @@ extern piegen_opt_t opts;
 extern FILE *fout;
 
 #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64)
-extern int handle_elf_x86_32(const piegen_opt_t *opts, void *mem, size_t size);
-extern int handle_elf_x86_64(const piegen_opt_t *opts, void *mem, size_t size);
+extern int handle_elf_x86_32(void *mem, size_t size);
+extern int handle_elf_x86_64(void *mem, size_t size);
 #endif
 
 #if defined(CONFIG_PPC64)
-extern int handle_elf_ppc64(const piegen_opt_t *opts, void *mem, size_t size);
+extern int handle_elf_ppc64(void *mem, size_t size);
 #endif
 
 #define pr_out(fmt, ...)	fprintf(fout, fmt, ##__VA_ARGS__)
 
-#define pr_debug(fmt, ...)	fprintf(stdout, fmt, ##__VA_ARGS__)
+#define pr_debug(fmt, ...)	printf(fmt, ##__VA_ARGS__)
 
 #define pr_err(fmt, ...)	fprintf(stderr, "Error (%s:%d): "fmt, __FILE__, __LINE__, ##__VA_ARGS__)
 #define pr_perror(fmt, ...)	fprintf(stderr, "Error (%s:%d): "fmt "%m\n", __FILE__, __LINE__, ##__VA_ARGS__)
-- 
1.9.1



More information about the CRIU mailing list