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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3A15C6FA82 for ; Sun, 18 Sep 2022 21:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229529AbiIRV5i (ORCPT ); Sun, 18 Sep 2022 17:57:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbiIRV5g (ORCPT ); Sun, 18 Sep 2022 17:57:36 -0400 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9708713E9C; Sun, 18 Sep 2022 14:57:35 -0700 (PDT) Received: from in01.mta.xmission.com ([166.70.13.51]:46946) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1oa2I7-00H6nJ-LN; Sun, 18 Sep 2022 15:57:31 -0600 Received: from ip68-110-29-46.om.om.cox.net ([68.110.29.46]:37784 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1oa2I6-000NTr-Dr; Sun, 18 Sep 2022 15:57:31 -0600 From: "Eric W. Biederman" To: cgel.zte@gmail.com Cc: richard.henderson@linaro.org, ink@jurassic.park.msu.ru, mattst88@gmail.com, akpm@linux-foundation.org, zhengqi.arch@bytedance.com, hannes@cmpxchg.org, catalin.marinas@arm.com, peterx@redhat.com, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, Xu Panda , Zeal Robot References: <20220918152912.210112-1-xu.panda@zte.com.cn> Date: Sun, 18 Sep 2022 16:57:23 -0500 In-Reply-To: <20220918152912.210112-1-xu.panda@zte.com.cn> (cgel zte's message of "Sun, 18 Sep 2022 15:29:12 +0000") Message-ID: <87o7vc73cs.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1oa2I6-000NTr-Dr;;;mid=<87o7vc73cs.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=68.110.29.46;;;frm=ebiederm@xmission.com;;;spf=softfail X-XM-AID: U2FsdGVkX1/VZT8JqQYpxHjHa1CUgrbhpMzcpaRkL8g= X-SA-Exim-Connect-IP: 68.110.29.46 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH linu-next V2] mm/fault: fix comparing pointer to 0 X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cgel.zte@gmail.com writes: > From: Xu Panda > > Do not use assignment in if condition, > and comparing pointer whith NULL instead of comparing pointer to 0. Then sensible thing to do if fixup is a pointer value is to just say: "if (fixup) {" That will be clearer and not match the pattern you are trying to avoid. Eric > > Reported-by: Zeal Robot > Signed-off-by: Xu Panda > --- > arch/alpha/mm/fault.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c > index ef427a6bdd1a..bb3fe2949313 100644 > --- a/arch/alpha/mm/fault.c > +++ b/arch/alpha/mm/fault.c > @@ -194,7 +194,8 @@ do_page_fault(unsigned long address, unsigned long > mmcsr, > > no_context: > /* Are we prepared to handle this fault as an exception? */ > - if ((fixup = search_exception_tables(regs->pc)) != 0) { > + fixup = search_exception_tables(regs->pc); > + if (fixup != NULL) { > unsigned long newpc; > newpc = fixup_exception(dpf_reg, fixup, regs->pc); > regs->pc = newpc;