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=-14.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable 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 AEBCEC43457 for ; Fri, 9 Oct 2020 09:24:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 239532227F for ; Fri, 9 Oct 2020 09:24:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 239532227F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4618E6B0068; Fri, 9 Oct 2020 05:24:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 411C96B006C; Fri, 9 Oct 2020 05:24:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30E166B006E; Fri, 9 Oct 2020 05:24:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id F403B6B0068 for ; Fri, 9 Oct 2020 05:24:41 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7E2C0181AE867 for ; Fri, 9 Oct 2020 09:24:41 +0000 (UTC) X-FDA: 77351851962.20.kick98_4908853271df Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 5C821180BFBAB for ; Fri, 9 Oct 2020 09:24:41 +0000 (UTC) X-HE-Tag: kick98_4908853271df X-Filterd-Recvd-Size: 4009 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Fri, 9 Oct 2020 09:24:38 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R941e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0UBQ5Qni_1602235473; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0UBQ5Qni_1602235473) by smtp.aliyun-inc.com(127.0.0.1); Fri, 09 Oct 2020 17:24:34 +0800 Date: Fri, 9 Oct 2020 17:24:33 +0800 From: Wei Yang To: Nathan Chancellor Cc: david@redhat.com, akpm@linux-foundation.org, ardb@kernel.org, bhe@redhat.com, dan.j.williams@intel.com, jgg@ziepe.ca, keescook@chromium.org, linux-acpi@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-s390@vger.kernel.org, mhocko@suse.com, pankaj.gupta.linux@gmail.com, richardw.yang@linux.intel.com, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH] kernel/resource: Fix use of ternary condition in release_mem_region_adjustable Message-ID: <20201009092433.GA56924@L-31X9LVDL-1304.local> Reply-To: Wei Yang References: <20200911103459.10306-2-david@redhat.com> <20200922060748.2452056-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922060748.2452056-1-natechancellor@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000917, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Sep 21, 2020 at 11:07:48PM -0700, Nathan Chancellor wrote: >Clang warns: > >kernel/resource.c:1281:53: warning: operator '?:' has lower precedence >than '|'; '|' will be evaluated first >[-Wbitwise-conditional-parentheses] > new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); > ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ >kernel/resource.c:1281:53: note: place parentheses around the '|' >expression to silence this warning > new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); > ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ >kernel/resource.c:1281:53: note: place parentheses around the '?:' >expression to evaluate it first > new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); > ^ > ( ) >1 warning generated. > >Add the parentheses as it was clearly intended for the ternary condition >to be evaluated first. > >Fixes: 5fd23bd0d739 ("kernel/resource: make release_mem_region_adjustable() never fail") >Link: https://github.com/ClangBuiltLinux/linux/issues/1159 >Signed-off-by: Nathan Chancellor Reviewed-by: Wei Yang >--- > >Presumably, this will be squashed but I included a fixes tag >nonetheless. Apologies if this has already been noticed and fixed >already, I did not find anything on LKML. > > kernel/resource.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/kernel/resource.c b/kernel/resource.c >index ca2a666e4317..3ae2f56cc79d 100644 >--- a/kernel/resource.c >+++ b/kernel/resource.c >@@ -1278,7 +1278,7 @@ void release_mem_region_adjustable(resource_size_t start, resource_size_t size) > * similarly). > */ > retry: >- new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); >+ new_res = alloc_resource(GFP_KERNEL | (alloc_nofail ? __GFP_NOFAIL : 0)); > > p = &parent->child; > write_lock(&resource_lock); > >base-commit: 40ee82f47bf297e31d0c47547cd8f24ede52415a >-- >2.28.0 -- Wei Yang Help you, Help me