Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08916C433EF for ; Thu, 25 Nov 2021 00:00:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344476AbhKYAD6 (ORCPT ); Wed, 24 Nov 2021 19:03:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244870AbhKYAD5 (ORCPT ); Wed, 24 Nov 2021 19:03:57 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2E41C061574 for ; Wed, 24 Nov 2021 16:00:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=N9H59bh7/GXkQevh/ImLSYPupHbGEmC2H8FOJaNSSS0=; b=rwnSfONc0LNW3VywsmOQ9cSyA4 1VnyVJ/TmEB+yaXtOs4FfH4wV2waVVDzG+3pIxik0sf6giKqmmsEAuD5LTFnKurJ2ZerG4B1Wlnpm l2n31bKzXnzBZeclw+8XBn/MCeIpjgv+N68PrIkyvL3VhltnXZb6npM5h13B5RHJks9JWQGfKI9mb nJFe6DiQmTqJo/W4ukdaaggCmrgu6NLIGcVfwjd3+eU1O+nKLZXfqpOek59pW4Sg/almtBbgHXNy6 2sOqu2Av+sz5XtbdbX79StoJYC4d55UKhEWkqj4C3FUQo++krpoq74LksG+ko5QrU2nD66zO7p22E y8tXn5/g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mq2Br-003vyo-7v; Thu, 25 Nov 2021 00:00:39 +0000 Date: Thu, 25 Nov 2021 00:00:39 +0000 From: Matthew Wilcox To: cgel.zte@gmail.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chiminghao , Zeal Robot , Julia Lawall , Michal Marek Subject: Re: [PATCH] mm: Use BUG_ON instead of if condition followed by BUG Message-ID: References: <20211124030849.34998-1-chi.minghao@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 24, 2021 at 01:23:42PM +0000, Matthew Wilcox wrote: > On Wed, Nov 24, 2021 at 03:08:49AM +0000, cgel.zte@gmail.com wrote: > > From: chiminghao > > > > Fix the following coccinelle report: > > ./mm/memory_hotplug.c:2210:2-5: > > WARNING Use BUG_ON instead of if condition followed by BUG. > > What coccinelle script is reporting this? Maybe I found it? scripts/coccinelle/misc/bugon.cocci:msg="WARNING: Use BUG_ON instead of if condition followed by BUG.\nPlease make sure the condition has no side effects (see conditional BUG_ON definition in include/asm-generic/bug.h)" Julia, Michal, can we delete this script, please? It's being abused. > > - if (try_remove_memory(start, size)) > > - BUG(); > > + BUG_ON(try_remove_memory(start, size)); > > I really, really, really do not like this. For functions with > side-effects, this is bad style. If it's a pure predicate, then > sure, but this is bad. >