From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30172C4338F for ; Mon, 23 Aug 2021 19:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DC88613D0 for ; Mon, 23 Aug 2021 19:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232094AbhHWTcX (ORCPT ); Mon, 23 Aug 2021 15:32:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:48822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbhHWTcW (ORCPT ); Mon, 23 Aug 2021 15:32:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C4E461040; Mon, 23 Aug 2021 19:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1629747099; bh=xWVdb08TAxTvVeKVZ1u+P+w0yrUcdC0QFXlFHnzyBtk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LqBZeCXJAOYw9lM3D/zuojqPXzYvDFUzYhXlzsyJHl+hY+UwwNMX8OTqJKH/sKQKt tkiZs+51EP2HGdL0aVyJYhU0DI4xZHeiNldDcqVpuywEQpgEh75rzd61NAHbhQ+Drm uuDjnKMaS51yQ+ZKEeEJ5/h/uAIXIOr8eUsmFjYU= Date: Mon, 23 Aug 2021 12:31:38 -0700 From: Andrew Morton To: CGEL Cc: "Gustavo A . R . Silva" , Sergei Trofimovich , linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, Jing Yangyang , Zeal Robot Subject: Re: [PATCH linux-next] arch/ia64/kernel/module.c: fix bugon.cocci warnings Message-Id: <20210823123138.7ce66561a0d108bbdffb25ff@linux-foundation.org> In-Reply-To: <20210823015110.44069-1-jing.yangyang@zte.com.cn> References: <20210823015110.44069-1-jing.yangyang@zte.com.cn> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 22 Aug 2021 18:51:10 -0700 CGEL wrote: > From: Jing Yangyang > > Use BUG_ON instead of a if condition followed by BUG. > > Generated by: scripts/coccinelle/misc/bugon.cocci > > ... > > --- a/arch/ia64/kernel/module.c > +++ b/arch/ia64/kernel/module.c > @@ -560,8 +560,7 @@ struct plt_entry { > while (plt->bundle[0][0]) { > if (plt_target(plt) == target_ip) > goto found; > - if (++plt >= plt_end) > - BUG(); > + BUG_ON(++plt >= plt_end); There are concerns that there might be a config combination in which BUG_ON() expands to a no-op. It this situation, `plt' won't get incremented and we have a bug. Now, we have taken care to prevent this from happening, via the implementations of BUG_ON(). But still, mistakes happen and out of an abundance of caution people avoid statements of the form assert(expression-with-side-effects)