aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Mullis <dwm@meer.net>2006-12-08 05:39:51 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:29:03 -0500
commit08b3df2d16cbebf7d72c09dcbc071696c14d07e3 (patch)
tree2cc0baeda87e24d9839845c0d34cd068453b1518
parent5d0ffa2b84e6f0fdc5bf96c0de6178f3d2779544 (diff)
[PATCH] fault-injection: Use bool-true-false throughout
Use bool-true-false throughout. Signed-off-by: Don Mullis <dwm@meer.net> Cc: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/fault-inject.h2
-rw-r--r--lib/fault-inject.c40
2 files changed, 20 insertions, 22 deletions
diff --git a/include/linux/fault-inject.h b/include/linux/fault-inject.h
index 9bb584e89399..c77067916b7e 100644
--- a/include/linux/fault-inject.h
+++ b/include/linux/fault-inject.h
@@ -57,7 +57,7 @@ struct fault_attr {
57#define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER 57#define DECLARE_FAULT_ATTR(name) struct fault_attr name = FAULT_ATTR_INITIALIZER
58int setup_fault_attr(struct fault_attr *attr, char *str); 58int setup_fault_attr(struct fault_attr *attr, char *str);
59void should_fail_srandom(unsigned long entropy); 59void should_fail_srandom(unsigned long entropy);
60int should_fail(struct fault_attr *attr, ssize_t size); 60bool should_fail(struct fault_attr *attr, ssize_t size);
61 61
62#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 62#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
63 63
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 361c6e9cd77f..244782940349 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -48,7 +48,7 @@ static void fail_dump(struct fault_attr *attr)
48 48
49#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) 49#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
50 50
51static int fail_task(struct fault_attr *attr, struct task_struct *task) 51static bool fail_task(struct fault_attr *attr, struct task_struct *task)
52{ 52{
53 return !in_interrupt() && task->make_it_fail; 53 return !in_interrupt() && task->make_it_fail;
54} 54}
@@ -68,15 +68,15 @@ static asmlinkage int fail_stacktrace_callback(struct unwind_frame_info *info,
68 break; 68 break;
69 if (attr->reject_start <= UNW_PC(info) && 69 if (attr->reject_start <= UNW_PC(info) &&
70 UNW_PC(info) < attr->reject_end) 70 UNW_PC(info) < attr->reject_end)
71 return 0; 71 return false;
72 if (attr->require_start <= UNW_PC(info) && 72 if (attr->require_start <= UNW_PC(info) &&
73 UNW_PC(info) < attr->require_end) 73 UNW_PC(info) < attr->require_end)
74 found = 1; 74 found = true;
75 } 75 }
76 return found; 76 return found;
77} 77}
78 78
79static int fail_stacktrace(struct fault_attr *attr) 79static bool fail_stacktrace(struct fault_attr *attr)
80{ 80{
81 struct unwind_frame_info info; 81 struct unwind_frame_info info;
82 82
@@ -85,9 +85,7 @@ static int fail_stacktrace(struct fault_attr *attr)
85 85
86#elif defined(CONFIG_STACKTRACE) 86#elif defined(CONFIG_STACKTRACE)
87 87
88#define MAX_STACK_TRACE_DEPTH 32 88static bool fail_stacktrace(struct fault_attr *attr)
89
90static int fail_stacktrace(struct fault_attr *attr)
91{ 89{
92 struct stack_trace trace; 90 struct stack_trace trace;
93 int depth = attr->stacktrace_depth; 91 int depth = attr->stacktrace_depth;
@@ -109,26 +107,26 @@ static int fail_stacktrace(struct fault_attr *attr)
109 for (n = 0; n < trace.nr_entries; n++) { 107 for (n = 0; n < trace.nr_entries; n++) {
110 if (attr->reject_start <= entries[n] && 108 if (attr->reject_start <= entries[n] &&
111 entries[n] < attr->reject_end) 109 entries[n] < attr->reject_end)
112 return 0; 110 return false;
113 if (attr->require_start <= entries[n] && 111 if (attr->require_start <= entries[n] &&
114 entries[n] < attr->require_end) 112 entries[n] < attr->require_end)
115 found = 1; 113 found = true;
116 } 114 }
117 return found; 115 return found;
118} 116}
119 117
120#else 118#else
121 119
122static inline int fail_stacktrace(struct fault_attr *attr) 120static inline bool fail_stacktrace(struct fault_attr *attr)
123{ 121{
124 static int firsttime = 1; 122 static bool firsttime = true;
125 123
126 if (firsttime) { 124 if (firsttime) {
127 printk(KERN_WARNING 125 printk(KERN_WARNING
128 "This architecture does not implement save_stack_trace()\n"); 126 "This architecture does not implement save_stack_trace()\n");
129 firsttime = 0; 127 firsttime = false;
130 } 128 }
131 return 0; 129 return false;
132} 130}
133 131
134#endif 132#endif
@@ -138,32 +136,32 @@ static inline int fail_stacktrace(struct fault_attr *attr)
138 * http://www.nongnu.org/failmalloc/ 136 * http://www.nongnu.org/failmalloc/
139 */ 137 */
140 138
141int should_fail(struct fault_attr *attr, ssize_t size) 139bool should_fail(struct fault_attr *attr, ssize_t size)
142{ 140{
143 if (attr->task_filter && !fail_task(attr, current)) 141 if (attr->task_filter && !fail_task(attr, current))
144 return 0; 142 return false;
145 143
146 if (!fail_stacktrace(attr)) 144 if (!fail_stacktrace(attr))
147 return 0; 145 return false;
148 146
149 if (atomic_read(&attr->times) == 0) 147 if (atomic_read(&attr->times) == 0)
150 return 0; 148 return false;
151 149
152 if (atomic_read(&attr->space) > size) { 150 if (atomic_read(&attr->space) > size) {
153 atomic_sub(size, &attr->space); 151 atomic_sub(size, &attr->space);
154 return 0; 152 return false;
155 } 153 }
156 154
157 if (attr->interval > 1) { 155 if (attr->interval > 1) {
158 attr->count++; 156 attr->count++;
159 if (attr->count % attr->interval) 157 if (attr->count % attr->interval)
160 return 0; 158 return false;
161 } 159 }
162 160
163 if (attr->probability > random32() % 100) 161 if (attr->probability > random32() % 100)
164 goto fail; 162 goto fail;
165 163
166 return 0; 164 return false;
167 165
168fail: 166fail:
169 fail_dump(attr); 167 fail_dump(attr);
@@ -171,7 +169,7 @@ fail:
171 if (atomic_read(&attr->times) != -1) 169 if (atomic_read(&attr->times) != -1)
172 atomic_dec_not_zero(&attr->times); 170 atomic_dec_not_zero(&attr->times);
173 171
174 return 1; 172 return true;
175} 173}
176 174
177#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 175#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS