Skip to content

Commit 29e8077

Browse files
mhiramatrostedt
authored andcommitted
kprobes: Use bool type for functions which returns boolean value
Use the 'bool' type instead of 'int' for the functions which returns a boolean value, because this makes clear that those functions don't return any error code. Link: https://lkml.kernel.org/r/163163041649.489837.17311187321419747536.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent c42421e commit 29e8077

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎include/linux/kprobes.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,25 @@ struct kprobe {
104104
#define KPROBE_FLAG_FTRACE 8 /* probe is using ftrace */
105105

106106
/* Has this kprobe gone ? */
107-
static inline int kprobe_gone(struct kprobe *p)
107+
static inline bool kprobe_gone(struct kprobe *p)
108108
{
109109
return p->flags & KPROBE_FLAG_GONE;
110110
}
111111

112112
/* Is this kprobe disabled ? */
113-
static inline int kprobe_disabled(struct kprobe *p)
113+
static inline bool kprobe_disabled(struct kprobe *p)
114114
{
115115
return p->flags & (KPROBE_FLAG_DISABLED | KPROBE_FLAG_GONE);
116116
}
117117

118118
/* Is this kprobe really running optimized path ? */
119-
static inline int kprobe_optimized(struct kprobe *p)
119+
static inline bool kprobe_optimized(struct kprobe *p)
120120
{
121121
return p->flags & KPROBE_FLAG_OPTIMIZED;
122122
}
123123

124124
/* Is this kprobe uses ftrace ? */
125-
static inline int kprobe_ftrace(struct kprobe *p)
125+
static inline bool kprobe_ftrace(struct kprobe *p)
126126
{
127127
return p->flags & KPROBE_FLAG_FTRACE;
128128
}

‎kernel/kprobes.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ kprobe_opcode_t *__get_insn_slot(struct kprobe_insn_cache *c)
198198
return slot;
199199
}
200200

201-
/* Return 1 if all garbages are collected, otherwise 0. */
202-
static int collect_one_slot(struct kprobe_insn_page *kip, int idx)
201+
/* Return true if all garbages are collected, otherwise false. */
202+
static bool collect_one_slot(struct kprobe_insn_page *kip, int idx)
203203
{
204204
kip->slot_used[idx] = SLOT_CLEAN;
205205
kip->nused--;
@@ -223,9 +223,9 @@ static int collect_one_slot(struct kprobe_insn_page *kip, int idx)
223223
kip->cache->free(kip->insns);
224224
kfree(kip);
225225
}
226-
return 1;
226+
return true;
227227
}
228-
return 0;
228+
return false;
229229
}
230230

231231
static int collect_garbage_slots(struct kprobe_insn_cache *c)
@@ -389,13 +389,13 @@ NOKPROBE_SYMBOL(get_kprobe);
389389
static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs);
390390

391391
/* Return true if 'p' is an aggregator */
392-
static inline int kprobe_aggrprobe(struct kprobe *p)
392+
static inline bool kprobe_aggrprobe(struct kprobe *p)
393393
{
394394
return p->pre_handler == aggr_pre_handler;
395395
}
396396

397397
/* Return true if 'p' is unused */
398-
static inline int kprobe_unused(struct kprobe *p)
398+
static inline bool kprobe_unused(struct kprobe *p)
399399
{
400400
return kprobe_aggrprobe(p) && kprobe_disabled(p) &&
401401
list_empty(&p->list);
@@ -455,7 +455,7 @@ static inline int kprobe_optready(struct kprobe *p)
455455
}
456456

457457
/* Return true if the kprobe is disarmed. Note: p must be on hash list */
458-
static inline int kprobe_disarmed(struct kprobe *p)
458+
static inline bool kprobe_disarmed(struct kprobe *p)
459459
{
460460
struct optimized_kprobe *op;
461461

@@ -469,16 +469,16 @@ static inline int kprobe_disarmed(struct kprobe *p)
469469
}
470470

471471
/* Return true if the probe is queued on (un)optimizing lists */
472-
static int kprobe_queued(struct kprobe *p)
472+
static bool kprobe_queued(struct kprobe *p)
473473
{
474474
struct optimized_kprobe *op;
475475

476476
if (kprobe_aggrprobe(p)) {
477477
op = container_of(p, struct optimized_kprobe, kp);
478478
if (!list_empty(&op->list))
479-
return 1;
479+
return true;
480480
}
481-
return 0;
481+
return false;
482482
}
483483

484484
/*
@@ -1678,7 +1678,7 @@ int register_kprobe(struct kprobe *p)
16781678
EXPORT_SYMBOL_GPL(register_kprobe);
16791679

16801680
/* Check if all probes on the 'ap' are disabled. */
1681-
static int aggr_kprobe_disabled(struct kprobe *ap)
1681+
static bool aggr_kprobe_disabled(struct kprobe *ap)
16821682
{
16831683
struct kprobe *kp;
16841684

@@ -1690,9 +1690,9 @@ static int aggr_kprobe_disabled(struct kprobe *ap)
16901690
* Since there is an active probe on the list,
16911691
* we can't disable this 'ap'.
16921692
*/
1693-
return 0;
1693+
return false;
16941694

1695-
return 1;
1695+
return true;
16961696
}
16971697

16981698
static struct kprobe *__disable_kprobe(struct kprobe *p)

‎kernel/trace/trace_kprobe.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static nokprobe_inline unsigned long trace_kprobe_offset(struct trace_kprobe *tk
9797

9898
static nokprobe_inline bool trace_kprobe_has_gone(struct trace_kprobe *tk)
9999
{
100-
return !!(kprobe_gone(&tk->rp.kp));
100+
return kprobe_gone(&tk->rp.kp);
101101
}
102102

103103
static nokprobe_inline bool trace_kprobe_within_module(struct trace_kprobe *tk,

0 commit comments

Comments
 (0)