Message ID | 20230813015142.3095-1-kunyu@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp965673vqi; Fri, 11 Aug 2023 02:37:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFg1qISq+OSdKCTqexZJ1wUhA7UgraL67SzznnrzvNl0+87zSmJOqRCz+rOsJmqvud5ubok X-Received: by 2002:a05:6a20:3947:b0:135:293b:efaf with SMTP id r7-20020a056a20394700b00135293befafmr1766835pzg.10.1691746678372; Fri, 11 Aug 2023 02:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691746678; cv=none; d=google.com; s=arc-20160816; b=GfnEE/Ykj0IEMgZAnglWtQA2BfWXDxxbt7st4Swxw34Z02IODUMmJXfZ6rn1+PONQi n15tjrsAXBnVEiGR/t/NWLnbyst+cfPMRDKawF2/aMjdlx1SSWNJUXA1rMj64kBZ8SNb HOoS6hURAaRMp9FMe/g1vaK2zqAcCRcoZvN6H7/yUtHvmWvbdDkQbGwtiuZ05/C+ZU0H NL2ycF/BWPhdLSYMPrrFG/1SbhVkBdZaYeep7hUSRyCXRYghrMgUqaeff1yu2wLfzXwT Xd0+Q5zNdPayU6Ji5VVL3gcSumQBbehLSV4D1xcSAXrrHzbiv0Z0x4ltjORGxIlrB0HM L6NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=W+/idrs+eiiQMYOwW8rrPcR0lIT90JW+gKfgSauCAsY=; fh=3vtYlIUzX5mvgfEsHX1c04bXxEfZZPfgCfm1sZQSCmc=; b=L8DcQSxzrHG1NRHO7KEHwhuQCkAVVwt0AHKY1q4mxoCXWD/XHH6XD8WSzCKqsbUKvs 9rjmDDR5Xb9kZaSO5vnCw3iYHHDvpHnEx5ZwgAOOv7RX4C6FblFIc4EmZtcJqgx1Pjgz 5Zbi7PfL+o5G+WriJaNNQk6/2D25B94fnU6DSd/LAjixjdYSyJyTSuJmRLmSixRjr3Nu b5kiw4b1+uf2Q4v8uEQTvmuVowT7ElGCl/JgC9fz+WNV1dopgIIWyaykRAltwB27Cotb uPH5wZ8X/zJQOGMvnamL2F66MBbk0hv69Vh8FitjBf9zacFH+Ejj6xYK1rC3YMaofVTr w+9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a170903111100b001b89fd6bec4si3201802plh.144.2023.08.11.02.37.43; Fri, 11 Aug 2023 02:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234863AbjHKJUf (ORCPT <rfc822;shaohuahua6@gmail.com> + 99 others); Fri, 11 Aug 2023 05:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232956AbjHKJUc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Aug 2023 05:20:32 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id C385BC5; Fri, 11 Aug 2023 02:20:31 -0700 (PDT) Received: from localhost.localdomain (unknown [219.141.250.2]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id B570C605E83FB; Fri, 11 Aug 2023 17:20:29 +0800 (CST) X-MD-Sfrom: kunyu@nfschina.com X-MD-SrcIP: 219.141.250.2 From: Li kunyu <kunyu@nfschina.com> To: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Li kunyu <kunyu@nfschina.com> Subject: [PATCH] =?utf-8?q?cgroup=3A_cgroup=3A_Remove_unnecessary_=E2=80=98N?= =?utf-8?q?ULL=E2=80=99_values_from_res?= Date: Sun, 13 Aug 2023 09:51:42 +0800 Message-Id: <20230813015142.3095-1-kunyu@nfschina.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_24_48, RDNS_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773924965340214249 X-GMAIL-MSGID: 1773924965340214249 |
Series |
cgroup: cgroup: Remove unnecessary ‘NULL’ values from res
|
|
Commit Message
Li kunyu
Aug. 13, 2023, 1:51 a.m. UTC
res is assigned first, so it does not need to initialize the assignment.
Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
kernel/cgroup/cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Li,
kernel test robot noticed the following build warnings:
[auto build test WARNING on tj-cgroup/for-next]
[cannot apply to linus/master v6.5-rc5 next-20230809]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Li-kunyu/cgroup-cgroup-Remove-unnecessary-NULL-values-from-res/20230811-172322
base: https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-next
patch link: https://lore.kernel.org/r/20230813015142.3095-1-kunyu%40nfschina.com
patch subject: [PATCH] cgroup: cgroup: Remove unnecessary ‘NULL’ values from res
config: x86_64-randconfig-x002-20230812 (https://download.01.org/0day-ci/archive/20230812/202308121338.k2YdCXVR-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230812/202308121338.k2YdCXVR-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308121338.k2YdCXVR-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> kernel/cgroup/cgroup.c:1380:3: warning: variable 'res' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]
list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:578:7: note: expanded from macro 'list_for_each_entry'
&pos->member != (head); \
^~~~~~~~~~~~~~~~~~~~~~
kernel/cgroup/cgroup.c:1391:10: note: uninitialized use occurs here
BUG_ON(!res);
^~~
include/asm-generic/bug.h:62:45: note: expanded from macro 'BUG_ON'
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
^~~~~~~~~
include/linux/compiler.h:78:42: note: expanded from macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
^
kernel/cgroup/cgroup.c:1380:3: note: remove the condition if it is always true
list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
^
include/linux/list.h:578:7: note: expanded from macro 'list_for_each_entry'
&pos->member != (head); \
^
kernel/cgroup/cgroup.c:1367:20: note: initialize the variable 'res' to silence this warning
struct cgroup *res;
^
= NULL
1 warning generated.
vim +1380 kernel/cgroup/cgroup.c
f2e85d574e881f kernel/cgroup.c Tejun Heo 2014-02-11 1359
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1360 /*
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1361 * look up cgroup associated with current task's cgroup namespace on the
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1362 * specified hierarchy
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1363 */
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1364 static struct cgroup *
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1365 current_cgns_cgroup_from_root(struct cgroup_root *root)
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1366 {
aa6f66ec5ebc27 kernel/cgroup/cgroup.c Li kunyu 2023-08-13 1367 struct cgroup *res;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1368 struct css_set *cset;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1369
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1370 lockdep_assert_held(&css_set_lock);
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1371
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1372 rcu_read_lock();
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1373
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1374 cset = current->nsproxy->cgroup_ns->root_cset;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1375 if (cset == &init_css_set) {
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1376 res = &root->cgrp;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1377 } else {
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1378 struct cgrp_cset_link *link;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1379
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 @1380 list_for_each_entry(link, &cset->cgrp_links, cgrp_link) {
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1381 struct cgroup *c = link->cgrp;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1382
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1383 if (c->root == root) {
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1384 res = c;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1385 break;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1386 }
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1387 }
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1388 }
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1389 rcu_read_unlock();
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1390
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1391 BUG_ON(!res);
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1392 return res;
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1393 }
4f41fc59620fce kernel/cgroup.c Serge E. Hallyn 2016-05-09 1394
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index cdda2a147d6b..3a8802921bcb 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -1419,7 +1419,7 @@ static inline struct cgroup *__cset_cgroup_from_root(struct css_set *cset, static struct cgroup * current_cgns_cgroup_from_root(struct cgroup_root *root) { - struct cgroup *res = NULL; + struct cgroup *res; struct css_set *cset; lockdep_assert_held(&css_set_lock);