Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp737951pxb; Tue, 14 Sep 2021 07:43:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi7W+R6i7QmCOYmdprNlB7oZqAAQ/ZSIi2bcp1o1e4rvicb1mUNtXLz/oaoaLZZjlL4r85 X-Received: by 2002:a2e:b0e2:: with SMTP id h2mr15680307ljl.23.1631630632467; Tue, 14 Sep 2021 07:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631630632; cv=none; d=google.com; s=arc-20160816; b=Zq+9gKT6r1RPL6CQaMUU7gl51LzN8sKMFyltYxKzN99Tm52Zx4gvrGzuUqpsjtU/cH RguQd5rrYw3ZY8TF599cEtghj4FQwXHZyQoUBivWQEZB83USGhRxw6O8gcf2nsctygeZ ogtzpe6VOdSOtBTNdESsC9uA1WRI24CW40H3KtSS250k1jFoMjpaNGtWOqbcaXt7DS1Q CJELUSm2tFARLMsMR2fCBDVIKapr5zEb0PLkk/w6dXQ9J7rB+xfiPEoxJsGKkL4nNzsq YsCqVfAfAWOK/l41qMvGjmm76sUoW1n66pKNzkrcTMsKfv5WGr477y0MHb4QB8KKR3FC UYyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dFAJaQ3y0jeIyCMpI1OuP00qzWjrbzmTIrUdUlbc15o=; b=EelS6AdYuVIIt12R+4fywqTEvIL6R63jhhwEDpo5hiHQtbduhlQHnMYkH8g9kxTHZF SW8h8FfTkGbFw4SsEKuii2J0YYkJbhIzg7iXozk3XsysNBiTWZVEog/X1BwGuqWlGBdO m6q7SdH5/wr9EiDnnuDowuJtzgyrd5utNfyCAREB1sEAT7m7W9iSekCiJNHXhIeI6oIp +KBwP9qsCowzmzFGTL8J/brISYRsM4/dj1YKHpVwwLPzpmPImgYZDa++wh0Hxr7gqH3u pGCuWr45MPgZoLeNMrF/g0NS9Jx9gpQOSkDsqH1LyZ9y18uZF5Vc/MnYQp/GK4RYYTcI XcMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KtaI3UOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q66si11788329ljq.42.2021.09.14.07.43.24; Tue, 14 Sep 2021 07:43:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KtaI3UOG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234350AbhINOnA (ORCPT + 99 others); Tue, 14 Sep 2021 10:43:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:35842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233968AbhINOlj (ORCPT ); Tue, 14 Sep 2021 10:41:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14D4B610D1; Tue, 14 Sep 2021 14:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631630421; bh=PMfLP00PTvIAVFwzl7khtgbFp1PkY8LekgAvH6msKko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KtaI3UOGXWgILa66TCUiSY3P/yZBY8yKkrhys9UWvGIIqVAgiTlbWa2sVhGn2Cq4k quUvWaE32N1/lL/4CssQRPTyev988dwIwRsRt0akP3gKu0UQfGmrrEOByA1OkAAzOo whEAQEhSPldoHtC5kHXHxY1ehAplGDGt0cBUsl7BSTSHPBtJttz5Z8eA1EX1oLlylY gO+EXlh7e8F908g0P8kuH4wIFHOcKvZPvZ6X071M8qaGNH8bHAyQqiCn7JCiKY1JZB 9fjtHB/Dks5HNVG9Xdo/joHqwCrdd143LBrQikaaBkakcLkROtnxWJo4VaQ+U8fss1 Lx9sJ4z0Rc/XQ== From: Masami Hiramatsu To: Steven Rostedt , Josh Poimboeuf , Ingo Molnar Cc: X86 ML , Masami Hiramatsu , Daniel Xu , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kuba@kernel.org, mingo@redhat.com, ast@kernel.org, Thomas Gleixner , Borislav Petkov , Peter Zijlstra , kernel-team@fb.com, yhs@fb.com, linux-ia64@vger.kernel.org, Abhishek Sagar , Andrii Nakryiko , Paul McKenney Subject: [PATCH -tip v11 11/27] kprobes: Use bool type for functions which returns boolean value Date: Tue, 14 Sep 2021 23:40:16 +0900 Message-Id: <163163041649.489837.17311187321419747536.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163163030719.489837.2236069935502195491.stgit@devnote2> References: <163163030719.489837.2236069935502195491.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Masami Hiramatsu --- Changes in v2: - Fix trace_kprobe's kprobe_gone() too. --- include/linux/kprobes.h | 8 ++++---- kernel/kprobes.c | 26 +++++++++++++------------- kernel/trace/trace_kprobe.c | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index 6a5995f334a0..0ba3f9e316d4 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h @@ -104,25 +104,25 @@ struct kprobe { #define KPROBE_FLAG_FTRACE 8 /* probe is using ftrace */ /* Has this kprobe gone ? */ -static inline int kprobe_gone(struct kprobe *p) +static inline bool kprobe_gone(struct kprobe *p) { return p->flags & KPROBE_FLAG_GONE; } /* Is this kprobe disabled ? */ -static inline int kprobe_disabled(struct kprobe *p) +static inline bool kprobe_disabled(struct kprobe *p) { return p->flags & (KPROBE_FLAG_DISABLED | KPROBE_FLAG_GONE); } /* Is this kprobe really running optimized path ? */ -static inline int kprobe_optimized(struct kprobe *p) +static inline bool kprobe_optimized(struct kprobe *p) { return p->flags & KPROBE_FLAG_OPTIMIZED; } /* Is this kprobe uses ftrace ? */ -static inline int kprobe_ftrace(struct kprobe *p) +static inline bool kprobe_ftrace(struct kprobe *p) { return p->flags & KPROBE_FLAG_FTRACE; } diff --git a/kernel/kprobes.c b/kernel/kprobes.c index b6f1dcf4bff3..8021bccb7770 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -198,8 +198,8 @@ kprobe_opcode_t *__get_insn_slot(struct kprobe_insn_cache *c) return slot; } -/* Return 1 if all garbages are collected, otherwise 0. */ -static int collect_one_slot(struct kprobe_insn_page *kip, int idx) +/* Return true if all garbages are collected, otherwise false. */ +static bool collect_one_slot(struct kprobe_insn_page *kip, int idx) { kip->slot_used[idx] = SLOT_CLEAN; kip->nused--; @@ -223,9 +223,9 @@ static int collect_one_slot(struct kprobe_insn_page *kip, int idx) kip->cache->free(kip->insns); kfree(kip); } - return 1; + return true; } - return 0; + return false; } static int collect_garbage_slots(struct kprobe_insn_cache *c) @@ -389,13 +389,13 @@ NOKPROBE_SYMBOL(get_kprobe); static int aggr_pre_handler(struct kprobe *p, struct pt_regs *regs); /* Return true if 'p' is an aggregator */ -static inline int kprobe_aggrprobe(struct kprobe *p) +static inline bool kprobe_aggrprobe(struct kprobe *p) { return p->pre_handler == aggr_pre_handler; } /* Return true if 'p' is unused */ -static inline int kprobe_unused(struct kprobe *p) +static inline bool kprobe_unused(struct kprobe *p) { return kprobe_aggrprobe(p) && kprobe_disabled(p) && list_empty(&p->list); @@ -455,7 +455,7 @@ static inline int kprobe_optready(struct kprobe *p) } /* Return true if the kprobe is disarmed. Note: p must be on hash list */ -static inline int kprobe_disarmed(struct kprobe *p) +static inline bool kprobe_disarmed(struct kprobe *p) { struct optimized_kprobe *op; @@ -469,16 +469,16 @@ static inline int kprobe_disarmed(struct kprobe *p) } /* Return true if the probe is queued on (un)optimizing lists */ -static int kprobe_queued(struct kprobe *p) +static bool kprobe_queued(struct kprobe *p) { struct optimized_kprobe *op; if (kprobe_aggrprobe(p)) { op = container_of(p, struct optimized_kprobe, kp); if (!list_empty(&op->list)) - return 1; + return true; } - return 0; + return false; } /* @@ -1678,7 +1678,7 @@ int register_kprobe(struct kprobe *p) EXPORT_SYMBOL_GPL(register_kprobe); /* Check if all probes on the 'ap' are disabled. */ -static int aggr_kprobe_disabled(struct kprobe *ap) +static bool aggr_kprobe_disabled(struct kprobe *ap) { struct kprobe *kp; @@ -1690,9 +1690,9 @@ static int aggr_kprobe_disabled(struct kprobe *ap) * Since there is an active probe on the list, * we can't disable this 'ap'. */ - return 0; + return false; - return 1; + return true; } static struct kprobe *__disable_kprobe(struct kprobe *p) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 3a64ba4bbad6..0e1e7ce5f7ed 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -97,7 +97,7 @@ static nokprobe_inline unsigned long trace_kprobe_offset(struct trace_kprobe *tk static nokprobe_inline bool trace_kprobe_has_gone(struct trace_kprobe *tk) { - return !!(kprobe_gone(&tk->rp.kp)); + return kprobe_gone(&tk->rp.kp); } static nokprobe_inline bool trace_kprobe_within_module(struct trace_kprobe *tk,