Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2026247pxa; Fri, 7 Aug 2020 00:47:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgCnzlda/OLmw4Rl9nXRJuwNm5voysHC/a1b2sV2ctqBSoOboTjTTaGmeur4sWQjaXk9CV X-Received: by 2002:a17:906:d050:: with SMTP id bo16mr8737620ejb.367.1596786476595; Fri, 07 Aug 2020 00:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596786476; cv=none; d=google.com; s=arc-20160816; b=WI5OXtwclMWY3JlEUf7/c74o8zLWV1PnAlj8zzrZiWWJHM0jF+dVDxPCUpXcpO6fH6 ZoTiin+ZVypsZas1cteuu3m+97B563NmVYkuNtSBgpoSmlJhTrM1jBrc4rGg5UTdb2rV CpB4sjsMoFV0fMyXL5bb4WuU1LxePVmlGB3/l6XMgnYOX0Wf2ut1hL5IPueIyeE6mTl5 Nu/lfx3CEqthpwdcosCYFg8Dk8EXh9LnfNfysEr9jmOLYmtxUSOo+mssBfzx/wbznv6e Q5wz7/Q/01LfxC4fSchbSkYwZMGJNMsUHDVnFoNNIIqUeRt4LZsTD+eWD74tbvldrt+y ZQAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t7AButfdzi6cMBNZ58j1heasr0CXQukxKuORdIsBaQw=; b=XBiY73UFHtaHkxxBl6Ygq7SlIm6zLzy/Mefqv+0/xNFaYNw2sHBMwOpbpiIexRZHtg tADSaFVQTyzZI6Z+Vu61oQN5ytUXiZ7F4PY9mOV99vU5itQSqXYNQY11GRQT4RjFW2Po e9VppMadx9sknlXVQPRrsSaTLufRX70YgtVB1rJ7Ph9AVvxC0WBE3GR2QJWyUcpyi5Wx JGBxZy1jY7ZnRZwynD114RQJvy7p0AwtW/EFwu/JpZJGFZlve6JuH544Q/mTeENddo8N SDBQXP7mp2tkrGCeHfnlCtglLYmkgE29EA/GHz7G0pNMtku9lopNzU3MpT+OPMc7SGzw flOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SQq1beFm; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p9si4497590edh.42.2020.08.07.00.47.33; Fri, 07 Aug 2020 00:47:56 -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=@gmail.com header.s=20161025 header.b=SQq1beFm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727001AbgHGHoc (ORCPT + 99 others); Fri, 7 Aug 2020 03:44:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgHGHob (ORCPT ); Fri, 7 Aug 2020 03:44:31 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BF71C061574; Fri, 7 Aug 2020 00:44:30 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id d14so919407qke.13; Fri, 07 Aug 2020 00:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t7AButfdzi6cMBNZ58j1heasr0CXQukxKuORdIsBaQw=; b=SQq1beFmd2ZJKm3fO7j1izIYCZH+ptiNMmUVDKWCqoVVmLpoEbFGUMYOQh9JFUgo3c GXUYEpYuLR/sG+ha1Bgunc4cvo/3zdoOlqxb1uOUubaqI+udnw1oW63QYVVbiB/xtu7K Cli/QLm9yKXrIWBmTiG+kd09MymI0gzmjNxcQndOAvJZ2d8HX/I8owkEsCA7RSCtR/c4 0edrvWNEfqlpWAMZqwcYM2S9XuEaGX86PJzSSay1cOjIQGsFBOtLY+NjiZgnfESKA3Se UzB/oee0IrOlLefeA4/MTpvR4cfxlDwIuor7wDsuYgISNEILVAbvx9qZv8eDX7ijbZZ2 3Y9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t7AButfdzi6cMBNZ58j1heasr0CXQukxKuORdIsBaQw=; b=DAm4RkK4FE4e5YBr7FzfZngDd23GKRMOGkVt8PpV9tErFGUMSFDoUTuKhowNCrkfWa xFfBIwm9LIYW0jZYYi2bDhQX6ZodC6s9GJLOsFpRxzJ3s9p+pWu53Q1XSIn6PxnQP3Z+ AxuMbtDhEYd718G9ReRwSKgycGwG7AeLmzFklEum1YVN1lFwSBqb/KmLsxZ2QiNWzPCN vaY/df/F8jqRFOX7t/L8ua6uxxeA1lZgLKi5+zbyv0cUBobXGsn+Ael3R8nG0gI/H/Kl oBVabeGfvsSKlKPTkjCKsCtAP6Ym+3X7PZd35bGXcSPKb9g69OGL3Kp1w2di+cDHSK2F Sv1w== X-Gm-Message-State: AOAM530MBS3VVV2Ag2RnGMca/CA5QwrL4qbkzjT/TL7q5qDt+fliJVFI KtG1TcH5kJQk0heOvwUIBEg= X-Received: by 2002:a37:8301:: with SMTP id f1mr12276566qkd.86.1596786269736; Fri, 07 Aug 2020 00:44:29 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id j61sm6778737qtd.52.2020.08.07.00.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2020 00:44:29 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id E3E8327C0054; Fri, 7 Aug 2020 03:44:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 07 Aug 2020 03:44:28 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrkedugdduvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecukfhppeduudegrdekhedrudektddrvdduheenucevlhhushhtvghrufhiiigvpe einecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhp vghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnpe epfhhigihmvgdrnhgrmhgvsehfihigmhgvrdhnrghmvg X-ME-Proxy: Received: from localhost (unknown [114.85.180.215]) by mail.messagingengine.com (Postfix) with ESMTPA id E1EA83280059; Fri, 7 Aug 2020 03:44:27 -0400 (EDT) From: Boqun Feng To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Jonathan Corbet , Waiman Long , Boqun Feng Subject: [RFC v7 08/19] lockdep: Make __bfs(.match) return bool Date: Fri, 7 Aug 2020 15:42:27 +0800 Message-Id: <20200807074238.1632519-9-boqun.feng@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200807074238.1632519-1-boqun.feng@gmail.com> References: <20200807074238.1632519-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The "match" parameter of __bfs() is used for checking whether we hit a match in the search, therefore it should return a boolean value rather than an integer for better readability. This patch then changes the return type of the function parameter and the match functions to bool. Suggested-by: Peter Zijlstra Signed-off-by: Boqun Feng --- kernel/locking/lockdep.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index bb8b7e42c154..62f7f88e3673 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1620,7 +1620,7 @@ static inline void bfs_init_rootb(struct lock_list *lock, */ static enum bfs_result __bfs(struct lock_list *source_entry, void *data, - int (*match)(struct lock_list *entry, void *data), + bool (*match)(struct lock_list *entry, void *data), struct lock_list **target_entry, int offset) { @@ -1711,7 +1711,7 @@ static enum bfs_result __bfs(struct lock_list *source_entry, static inline enum bfs_result __bfs_forwards(struct lock_list *src_entry, void *data, - int (*match)(struct lock_list *entry, void *data), + bool (*match)(struct lock_list *entry, void *data), struct lock_list **target_entry) { return __bfs(src_entry, data, match, target_entry, @@ -1722,7 +1722,7 @@ __bfs_forwards(struct lock_list *src_entry, static inline enum bfs_result __bfs_backwards(struct lock_list *src_entry, void *data, - int (*match)(struct lock_list *entry, void *data), + bool (*match)(struct lock_list *entry, void *data), struct lock_list **target_entry) { return __bfs(src_entry, data, match, target_entry, @@ -1833,7 +1833,7 @@ print_circular_bug_header(struct lock_list *entry, unsigned int depth, print_circular_bug_entry(entry, depth); } -static inline int class_equal(struct lock_list *entry, void *data) +static inline bool class_equal(struct lock_list *entry, void *data) { return entry->class == data; } @@ -1888,10 +1888,10 @@ static noinline void print_bfs_bug(int ret) WARN(1, "lockdep bfs error:%d\n", ret); } -static int noop_count(struct lock_list *entry, void *data) +static bool noop_count(struct lock_list *entry, void *data) { (*(unsigned long *)data)++; - return 0; + return false; } static unsigned long __lockdep_count_forward_deps(struct lock_list *this) @@ -2032,11 +2032,11 @@ check_redundant(struct held_lock *src, struct held_lock *target) #ifdef CONFIG_TRACE_IRQFLAGS -static inline int usage_accumulate(struct lock_list *entry, void *mask) +static inline bool usage_accumulate(struct lock_list *entry, void *mask) { *(unsigned long *)mask |= entry->class->usage_mask; - return 0; + return false; } /* @@ -2045,9 +2045,9 @@ static inline int usage_accumulate(struct lock_list *entry, void *mask) * without creating any illegal irq-safe -> irq-unsafe lock dependency. */ -static inline int usage_match(struct lock_list *entry, void *mask) +static inline bool usage_match(struct lock_list *entry, void *mask) { - return entry->class->usage_mask & *(unsigned long *)mask; + return !!(entry->class->usage_mask & *(unsigned long *)mask); } /* -- 2.28.0