Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp2198529pxu; Fri, 9 Oct 2020 10:14:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpjxEiTrgDpI30v+//1Pq1GcqaGu37L1IrYEEX8i8GmH47qcofyl24Y23mousa0gBZXfr5 X-Received: by 2002:a50:9fa8:: with SMTP id c37mr152227edf.233.1602263674613; Fri, 09 Oct 2020 10:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602263674; cv=none; d=google.com; s=arc-20160816; b=h2onOma9iDmA1EhFlXIPJimI/edLYuf1DZNy2QLih52k/bqzzeNWdv2uqTywGAR80P 8FQTPiOI1e9rjCf6CrsDTfoiT/nOAIHgzwPb4m7+q9awWWJcPiwfAvGz+S3pRdo0sdjD L4ILCd/+aGVrebOakRQW1xOgVff3ANs36JV1NcWwn2uo2Q2FVKgmwUp6tCneARR4OWvu rIjl47Rn/gdoVKrfVKebsYjU6KG9l8PVgQ1Y3LsMQLQDotSgnnXW6L8hy7FBQDzK/qeq GxDMZ9N6X6JNQuCl5nd/8OiHPg/EtJbCMOM7Jfq362ghtoexgk0EDknuo7fc2qmMwLI6 SiaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=3iuqdh/gZBH0jmac8iE7v9wwrapsnV7PVNcBBUxwwyY=; b=tQ5Rt76uF0RQ54gsYGXtr6xK4v5B+A6+AakHJy7Hff8JctouPUXRkWkaGuEBAiyVaC G1wM6bMKLhQ9MXveZoqAU0ToC1e1eI/9aJfSlXgbCWszpbciTJ7b4eMnblRyxTmrX7/e a/oWsOJVfEG/UwsWR7QiBxWPANvj4uHjW8rUO/J9C0UEMM18pTL8yR2N5noUSOqGdhjG jOHuN0nvbLDr7i3MKR0Bcbqk+Mo+NCd1va+qQBD9wADSnvcivrkYEcwutdW9j6P1zgYl S/0mCUCrsNJRrR5KKrRX6yJBu8qaRMwG56W3bjl8HfuhCEYA3x7jxHgS9Pfay2EGaSQG UkRQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e8si6624026ejj.575.2020.10.09.10.14.10; Fri, 09 Oct 2020 10:14:34 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733087AbgJIJYj (ORCPT + 99 others); Fri, 9 Oct 2020 05:24:39 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:59963 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731262AbgJIJYi (ORCPT ); Fri, 9 Oct 2020 05:24:38 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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