diff options
author | Pekka Enberg <penberg@cs.helsinki.fi> | 2009-02-26 03:47:50 -0500 |
---|---|---|
committer | Vegard Nossum <vegard.nossum@gmail.com> | 2009-06-15 06:39:47 -0400 |
commit | 6a19638719b4272ac86589c4bb660fc92db03dae (patch) | |
tree | 4d61a47edfffa87c15b394e227a28f8fc278e231 | |
parent | 60e383931d41b0bccefdf318ffde8b49e343e9bc (diff) |
kmemcheck: remove forward declarations from error.c
This patch reorders code in error.c so that we can get rid of the forward
declarations.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
-rw-r--r-- | arch/x86/mm/kmemcheck/error.c | 137 |
1 files changed, 68 insertions, 69 deletions
diff --git a/arch/x86/mm/kmemcheck/error.c b/arch/x86/mm/kmemcheck/error.c index 5ec9f5a93f47..4901d0dafda6 100644 --- a/arch/x86/mm/kmemcheck/error.c +++ b/arch/x86/mm/kmemcheck/error.c | |||
@@ -81,7 +81,74 @@ static struct kmemcheck_error *error_next_rd(void) | |||
81 | return e; | 81 | return e; |
82 | } | 82 | } |
83 | 83 | ||
84 | static void do_wakeup(unsigned long); | 84 | void kmemcheck_error_recall(void) |
85 | { | ||
86 | static const char *desc[] = { | ||
87 | [KMEMCHECK_SHADOW_UNALLOCATED] = "unallocated", | ||
88 | [KMEMCHECK_SHADOW_UNINITIALIZED] = "uninitialized", | ||
89 | [KMEMCHECK_SHADOW_INITIALIZED] = "initialized", | ||
90 | [KMEMCHECK_SHADOW_FREED] = "freed", | ||
91 | }; | ||
92 | |||
93 | static const char short_desc[] = { | ||
94 | [KMEMCHECK_SHADOW_UNALLOCATED] = 'a', | ||
95 | [KMEMCHECK_SHADOW_UNINITIALIZED] = 'u', | ||
96 | [KMEMCHECK_SHADOW_INITIALIZED] = 'i', | ||
97 | [KMEMCHECK_SHADOW_FREED] = 'f', | ||
98 | }; | ||
99 | |||
100 | struct kmemcheck_error *e; | ||
101 | unsigned int i; | ||
102 | |||
103 | e = error_next_rd(); | ||
104 | if (!e) | ||
105 | return; | ||
106 | |||
107 | switch (e->type) { | ||
108 | case KMEMCHECK_ERROR_INVALID_ACCESS: | ||
109 | printk(KERN_ERR "WARNING: kmemcheck: Caught %d-bit read " | ||
110 | "from %s memory (%p)\n", | ||
111 | 8 * e->size, e->state < ARRAY_SIZE(desc) ? | ||
112 | desc[e->state] : "(invalid shadow state)", | ||
113 | (void *) e->address); | ||
114 | |||
115 | printk(KERN_INFO); | ||
116 | for (i = 0; i < SHADOW_COPY_SIZE; ++i) | ||
117 | printk("%02x", e->memory_copy[i]); | ||
118 | printk("\n"); | ||
119 | |||
120 | printk(KERN_INFO); | ||
121 | for (i = 0; i < SHADOW_COPY_SIZE; ++i) { | ||
122 | if (e->shadow_copy[i] < ARRAY_SIZE(short_desc)) | ||
123 | printk(" %c", short_desc[e->shadow_copy[i]]); | ||
124 | else | ||
125 | printk(" ?"); | ||
126 | } | ||
127 | printk("\n"); | ||
128 | printk(KERN_INFO "%*c\n", 2 + 2 | ||
129 | * (int) (e->address & (SHADOW_COPY_SIZE - 1)), '^'); | ||
130 | break; | ||
131 | case KMEMCHECK_ERROR_BUG: | ||
132 | printk(KERN_EMERG "ERROR: kmemcheck: Fatal error\n"); | ||
133 | break; | ||
134 | } | ||
135 | |||
136 | __show_regs(&e->regs, 1); | ||
137 | print_stack_trace(&e->trace, 0); | ||
138 | } | ||
139 | |||
140 | static void do_wakeup(unsigned long data) | ||
141 | { | ||
142 | while (error_count > 0) | ||
143 | kmemcheck_error_recall(); | ||
144 | |||
145 | if (error_missed_count > 0) { | ||
146 | printk(KERN_WARNING "kmemcheck: Lost %d error reports because " | ||
147 | "the queue was too small\n", error_missed_count); | ||
148 | error_missed_count = 0; | ||
149 | } | ||
150 | } | ||
151 | |||
85 | static DECLARE_TASKLET(kmemcheck_tasklet, &do_wakeup, 0); | 152 | static DECLARE_TASKLET(kmemcheck_tasklet, &do_wakeup, 0); |
86 | 153 | ||
87 | /* | 154 | /* |
@@ -159,71 +226,3 @@ void kmemcheck_error_save_bug(struct pt_regs *regs) | |||
159 | 226 | ||
160 | tasklet_hi_schedule_first(&kmemcheck_tasklet); | 227 | tasklet_hi_schedule_first(&kmemcheck_tasklet); |
161 | } | 228 | } |
162 | |||
163 | void kmemcheck_error_recall(void) | ||
164 | { | ||
165 | static const char *desc[] = { | ||
166 | [KMEMCHECK_SHADOW_UNALLOCATED] = "unallocated", | ||
167 | [KMEMCHECK_SHADOW_UNINITIALIZED] = "uninitialized", | ||
168 | [KMEMCHECK_SHADOW_INITIALIZED] = "initialized", | ||
169 | [KMEMCHECK_SHADOW_FREED] = "freed", | ||
170 | }; | ||
171 | |||
172 | static const char short_desc[] = { | ||
173 | [KMEMCHECK_SHADOW_UNALLOCATED] = 'a', | ||
174 | [KMEMCHECK_SHADOW_UNINITIALIZED] = 'u', | ||
175 | [KMEMCHECK_SHADOW_INITIALIZED] = 'i', | ||
176 | [KMEMCHECK_SHADOW_FREED] = 'f', | ||
177 | }; | ||
178 | |||
179 | struct kmemcheck_error *e; | ||
180 | unsigned int i; | ||
181 | |||
182 | e = error_next_rd(); | ||
183 | if (!e) | ||
184 | return; | ||
185 | |||
186 | switch (e->type) { | ||
187 | case KMEMCHECK_ERROR_INVALID_ACCESS: | ||
188 | printk(KERN_ERR "WARNING: kmemcheck: Caught %d-bit read " | ||
189 | "from %s memory (%p)\n", | ||
190 | 8 * e->size, e->state < ARRAY_SIZE(desc) ? | ||
191 | desc[e->state] : "(invalid shadow state)", | ||
192 | (void *) e->address); | ||
193 | |||
194 | printk(KERN_INFO); | ||
195 | for (i = 0; i < SHADOW_COPY_SIZE; ++i) | ||
196 | printk("%02x", e->memory_copy[i]); | ||
197 | printk("\n"); | ||
198 | |||
199 | printk(KERN_INFO); | ||
200 | for (i = 0; i < SHADOW_COPY_SIZE; ++i) { | ||
201 | if (e->shadow_copy[i] < ARRAY_SIZE(short_desc)) | ||
202 | printk(" %c", short_desc[e->shadow_copy[i]]); | ||
203 | else | ||
204 | printk(" ?"); | ||
205 | } | ||
206 | printk("\n"); | ||
207 | printk(KERN_INFO "%*c\n", 2 + 2 | ||
208 | * (int) (e->address & (SHADOW_COPY_SIZE - 1)), '^'); | ||
209 | break; | ||
210 | case KMEMCHECK_ERROR_BUG: | ||
211 | printk(KERN_EMERG "ERROR: kmemcheck: Fatal error\n"); | ||
212 | break; | ||
213 | } | ||
214 | |||
215 | __show_regs(&e->regs, 1); | ||
216 | print_stack_trace(&e->trace, 0); | ||
217 | } | ||
218 | |||
219 | static void do_wakeup(unsigned long data) | ||
220 | { | ||
221 | while (error_count > 0) | ||
222 | kmemcheck_error_recall(); | ||
223 | |||
224 | if (error_missed_count > 0) { | ||
225 | printk(KERN_WARNING "kmemcheck: Lost %d error reports because " | ||
226 | "the queue was too small\n", error_missed_count); | ||
227 | error_missed_count = 0; | ||
228 | } | ||
229 | } | ||