Package: kexec-tools / 1:2.0.7-5

const_string_warning.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
--- a/kexec/arch/i386/kexec-elf-x86.c
+++ b/kexec/arch/i386/kexec-elf-x86.c
@@ -91,7 +91,7 @@ int elf_x86_load(int argc, char **argv,
 	char *command_line = NULL, *modified_cmdline = NULL;
 	const char *append = NULL;
 	char *tmp_cmdline = NULL;
-	char *error_msg = NULL;
+	int error_code = 0;
 	int result;
 	int command_line_len;
 	int modified_cmdline_len;
@@ -221,7 +221,7 @@ int elf_x86_load(int argc, char **argv,
 		elf_rel_set_symbol(&info->rhdr, "entry32_regs", &regs, sizeof(regs));
 
 		if (ramdisk) {
-			error_msg = "Ramdisks not supported with generic elf arguments";
+			error_code = 1;
 			goto out;
 		}
 	}
@@ -292,13 +292,20 @@ int elf_x86_load(int argc, char **argv,
 		elf_rel_set_symbol(&info->rhdr, "entry32_regs", &regs, sizeof(regs));
 	}
 	else {
-		error_msg = "Unknown argument style\n";
+		error_code = 2;
 	}
 
 out:
 	free(command_line);
 	free(modified_cmdline);
-	if (error_msg)
-		die(error_msg);
+	switch (error_code) {
+		case 1:
+			die("Ramdisks not supported with generic elf arguments");
+		case 2:
+			die("Unknown argument style\n");
+
+		default:
+			break;
+	}
 	return result;
 }
--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
+++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
@@ -99,7 +99,7 @@ int elf_x86_64_load(int argc, char **arg
 #define ARG_STYLE_NONE  2
 	int opt;
 	int result = 0;
-	char *error_msg = NULL;
+	int error_code = 0;
 
 	/* See options.h and add any new options there too! */
 	static const struct option options[] = {
@@ -207,7 +207,7 @@ int elf_x86_64_load(int argc, char **arg
 		elf_rel_set_symbol(&info->rhdr, "entry64_regs", &regs, sizeof(regs));
 
 		if (ramdisk) {
-			error_msg = "Ramdisks not supported with generic elf arguments";
+			error_code = 1;
 			goto out;
 		}
 	}
@@ -269,13 +269,21 @@ int elf_x86_64_load(int argc, char **arg
 		elf_rel_set_symbol(&info->rhdr, "entry64_regs", &regs, sizeof(regs));
 	}
 	else {
-		error_msg = "Unknown argument style\n";
+		error_code = 2;
 	}
 
 out:
 	free(command_line);
 	free(modified_cmdline);
-	if (error_msg)
-		die(error_msg);
+	switch (error_code) {
+		case 1:
+			die("Ramdisks not supported with generic elf arguments");
+
+		case 2:
+			die("Unknown argument style\n");
+
+		default:
+			break;
+	}
 	return result;
 }
--- a/kexec/arch/ppc/kexec-elf-ppc.c
+++ b/kexec/arch/ppc/kexec-elf-ppc.c
@@ -160,7 +160,7 @@ int elf_ppc_load(int argc, char **argv,
 	int command_line_len, crash_cmdline_len;
 	char *dtb;
 	int result;
-	char *error_msg;
+	int error_code = 0;
 	unsigned long max_addr, hole_addr;
 	struct mem_phdr *phdr;
 	size_t size;
@@ -199,7 +199,6 @@ int elf_ppc_load(int argc, char **argv,
 	kernel_addr = 0;
 	ramdisk = 0;
 	result = 0;
-	error_msg = NULL;
 
 	while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
 		switch (opt) {
@@ -360,7 +359,7 @@ int elf_ppc_load(int argc, char **argv,
 				(unsigned long *)&blob_size, cmdline_buf);
 	}
 	if (!blob_buf || !blob_size) {
-		error_msg = "Device tree seems to be an empty file.\n";
+		error_code = 1;
 		goto out2;
 	}
 
@@ -397,7 +396,7 @@ int elf_ppc_load(int argc, char **argv,
 	dtb_addr_actual = add_buffer(info, blob_buf, blob_size, blob_size, 0, dtb_addr,
 			kernel_addr + KERNEL_ACCESS_TOP, 1);
 	if (dtb_addr_actual != dtb_addr) {
-		error_msg = "Error device tree not loadded to address it was expecting to be loaded too!\n";
+		error_code = 2;
 		goto out2;
 	}
 
@@ -452,8 +451,14 @@ out:
 	free(crash_cmdline);
 	if (!tmp_cmdline)
 		free(command_line);
-	if (error_msg)
-		die(error_msg);
+	switch (error_code) {
+	case 1:
+		die("Device tree seems to be an empty file.\n");
+	case 2:
+		die("Error device tree not loadded to address it was expecting to be loaded too!\n");
+	default:
+		break;
+	}
 
 	return result;
 }
--- a/kexec/arch/ppc/kexec-uImage-ppc.c
+++ b/kexec/arch/ppc/kexec-uImage-ppc.c
@@ -103,7 +103,7 @@ static int ppc_load_bare_bits(int argc,
 	unsigned long max_addr;
 	char *blob_buf = NULL;
 	off_t blob_size = 0;
-	char *error_msg = NULL;
+	int error_code = 0;
 
 	cmdline_buf = NULL;
 	command_line = NULL;
@@ -223,7 +223,7 @@ static int ppc_load_bare_bits(int argc,
 				(unsigned long *)&blob_size, cmdline_buf);
 	}
 	if (!blob_buf || !blob_size) {
-		error_msg = "Device tree seems to be an empty file.\n";
+		error_code = 1;
 		goto out2;
 	}
 
@@ -261,7 +261,7 @@ static int ppc_load_bare_bits(int argc,
 			load_addr + KERNEL_ACCESS_TOP, 1);
 	if (dtb_addr_actual != dtb_addr) {
 		printf("dtb_addr_actual: %lx, dtb_addr: %lx\n", dtb_addr_actual, dtb_addr);
-		error_msg = "Error device tree not loadded to address it was expecting to be loaded too!\n";
+		error_code = 2;
 		goto out2;
 	}
 
@@ -305,8 +305,15 @@ out:
 	free(crash_cmdline);
 	if (!tmp_cmdline)
 		free(command_line);
-	if (error_msg)
-		die(error_msg);
+	switch (error_code) {
+	case 1:
+		die("Device tree seems to be an empty file.\n");
+	case 2:
+		die("Error device tree not loadded to address it was expecting to be loaded too!\n");
+	default:
+		break;
+	}
+
 	return ret;
 }