[PATCH] kprobes: replace magic numbers with enum

Replace the magic numbers with an enum, and gets rid of a warning on the
specific architectures (ex. powerpc) on which the compiler considers
'char' as 'unsigned char'.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Masami Hiramatsu and committed by Linus Torvalds ab40c5c6 46bae1a9

+13 -7
+13 -7
kernel/kprobes.c
··· 87 int ngarbage; 88 }; 89 90 static struct hlist_head kprobe_insn_pages; 91 static int kprobe_garbage_slots; 92 static int collect_garbage_slots(void); ··· 136 if (kip->nused < INSNS_PER_PAGE) { 137 int i; 138 for (i = 0; i < INSNS_PER_PAGE; i++) { 139 - if (!kip->slot_used[i]) { 140 - kip->slot_used[i] = 1; 141 kip->nused++; 142 return kip->insns + (i * MAX_INSN_SIZE); 143 } ··· 169 } 170 INIT_HLIST_NODE(&kip->hlist); 171 hlist_add_head(&kip->hlist, &kprobe_insn_pages); 172 - memset(kip->slot_used, 0, INSNS_PER_PAGE); 173 - kip->slot_used[0] = 1; 174 kip->nused = 1; 175 kip->ngarbage = 0; 176 return kip->insns; ··· 179 /* Return 1 if all garbages are collected, otherwise 0. */ 180 static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx) 181 { 182 - kip->slot_used[idx] = 0; 183 kip->nused--; 184 if (kip->nused == 0) { 185 /* ··· 218 continue; 219 kip->ngarbage = 0; /* we will collect all garbages */ 220 for (i = 0; i < INSNS_PER_PAGE; i++) { 221 - if (kip->slot_used[i] == -1 && 222 collect_one_slot(kip, i)) 223 break; 224 } ··· 238 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) { 239 int i = (slot - kip->insns) / MAX_INSN_SIZE; 240 if (dirty) { 241 - kip->slot_used[i] = -1; 242 kip->ngarbage++; 243 } else { 244 collect_one_slot(kip, i);
··· 87 int ngarbage; 88 }; 89 90 + enum kprobe_slot_state { 91 + SLOT_CLEAN = 0, 92 + SLOT_DIRTY = 1, 93 + SLOT_USED = 2, 94 + }; 95 + 96 static struct hlist_head kprobe_insn_pages; 97 static int kprobe_garbage_slots; 98 static int collect_garbage_slots(void); ··· 130 if (kip->nused < INSNS_PER_PAGE) { 131 int i; 132 for (i = 0; i < INSNS_PER_PAGE; i++) { 133 + if (kip->slot_used[i] == SLOT_CLEAN) { 134 + kip->slot_used[i] = SLOT_USED; 135 kip->nused++; 136 return kip->insns + (i * MAX_INSN_SIZE); 137 } ··· 163 } 164 INIT_HLIST_NODE(&kip->hlist); 165 hlist_add_head(&kip->hlist, &kprobe_insn_pages); 166 + memset(kip->slot_used, SLOT_CLEAN, INSNS_PER_PAGE); 167 + kip->slot_used[0] = SLOT_USED; 168 kip->nused = 1; 169 kip->ngarbage = 0; 170 return kip->insns; ··· 173 /* Return 1 if all garbages are collected, otherwise 0. */ 174 static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx) 175 { 176 + kip->slot_used[idx] = SLOT_CLEAN; 177 kip->nused--; 178 if (kip->nused == 0) { 179 /* ··· 212 continue; 213 kip->ngarbage = 0; /* we will collect all garbages */ 214 for (i = 0; i < INSNS_PER_PAGE; i++) { 215 + if (kip->slot_used[i] == SLOT_DIRTY && 216 collect_one_slot(kip, i)) 217 break; 218 } ··· 232 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) { 233 int i = (slot - kip->insns) / MAX_INSN_SIZE; 234 if (dirty) { 235 + kip->slot_used[i] = SLOT_DIRTY; 236 kip->ngarbage++; 237 } else { 238 collect_one_slot(kip, i);