All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [block:for-5.13/drivers 46/61] drivers/md/bcache/nvm-pages.c:156:34: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive]
Date: Tue, 20 Apr 2021 11:10:19 +0300	[thread overview]
Message-ID: <20210420081019.GB1959@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 3245 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git  for-5.13/drivers
head:   b09729cbbbf28ecdc61f00335684f7566eb740ec
commit: 97c62b647fcabd86fe703f9869be7dd91e685f50 [46/61] bcache: initialization of the buddy
compiler: microblaze-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> drivers/md/bcache/nvm-pages.c:156:34: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive]
      for (i = BCH_MAX_ORDER - 1; i >= 0 ; i--) {
                                    ^

vim +156 drivers/md/bcache/nvm-pages.c

97c62b647fcabd Jianpeng Ma 2021-04-14  144  static void init_nvm_free_space(struct bch_nvm_namespace *ns)
97c62b647fcabd Jianpeng Ma 2021-04-14  145  {
97c62b647fcabd Jianpeng Ma 2021-04-14  146  	unsigned int start, end, i;
                                                ^^^^^^^^^^^^             ^

97c62b647fcabd Jianpeng Ma 2021-04-14  147  	struct page *page;
97c62b647fcabd Jianpeng Ma 2021-04-14  148  	long long pages;
97c62b647fcabd Jianpeng Ma 2021-04-14  149  	pgoff_t pgoff_start;
97c62b647fcabd Jianpeng Ma 2021-04-14  150  
97c62b647fcabd Jianpeng Ma 2021-04-14  151  	bitmap_for_each_clear_region(ns->pages_bitmap, start, end, 0, ns->pages_total) {
97c62b647fcabd Jianpeng Ma 2021-04-14  152  		pgoff_start = start;
97c62b647fcabd Jianpeng Ma 2021-04-14  153  		pages = end - start;
97c62b647fcabd Jianpeng Ma 2021-04-14  154  
97c62b647fcabd Jianpeng Ma 2021-04-14  155  		while (pages) {
97c62b647fcabd Jianpeng Ma 2021-04-14 @156  			for (i = BCH_MAX_ORDER - 1; i >= 0 ; i--) {
                                                                                            ^^^^^^
This needs to be "int i;" for the loop to work correctly.

97c62b647fcabd Jianpeng Ma 2021-04-14  157  				if ((pgoff_start % (1 << i) == 0) && (pages >= (1 << i)))
97c62b647fcabd Jianpeng Ma 2021-04-14  158  					break;
97c62b647fcabd Jianpeng Ma 2021-04-14  159  			}
97c62b647fcabd Jianpeng Ma 2021-04-14  160  
97c62b647fcabd Jianpeng Ma 2021-04-14  161  			page = nvm_vaddr_to_page(ns, nvm_pgoff_to_vaddr(ns, pgoff_start));
97c62b647fcabd Jianpeng Ma 2021-04-14  162  			page->index = pgoff_start;
97c62b647fcabd Jianpeng Ma 2021-04-14  163  			set_page_private(page, i);
97c62b647fcabd Jianpeng Ma 2021-04-14  164  			__SetPageBuddy(page);
97c62b647fcabd Jianpeng Ma 2021-04-14  165  			list_add((struct list_head *)&page->zone_device_data, &ns->free_area[i]);
97c62b647fcabd Jianpeng Ma 2021-04-14  166  
97c62b647fcabd Jianpeng Ma 2021-04-14  167  			pgoff_start += 1 << i;
97c62b647fcabd Jianpeng Ma 2021-04-14  168  			pages -= 1 << i;
97c62b647fcabd Jianpeng Ma 2021-04-14  169  		}
97c62b647fcabd Jianpeng Ma 2021-04-14  170  	}
688330711e9ae3 Jianpeng Ma 2021-04-14  171  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org 
_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [kbuild] [block:for-5.13/drivers 46/61] drivers/md/bcache/nvm-pages.c:156:34: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive]
Date: Tue, 20 Apr 2021 11:10:19 +0300	[thread overview]
Message-ID: <20210420081019.GB1959@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 3245 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git  for-5.13/drivers
head:   b09729cbbbf28ecdc61f00335684f7566eb740ec
commit: 97c62b647fcabd86fe703f9869be7dd91e685f50 [46/61] bcache: initialization of the buddy
compiler: microblaze-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> drivers/md/bcache/nvm-pages.c:156:34: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive]
      for (i = BCH_MAX_ORDER - 1; i >= 0 ; i--) {
                                    ^

vim +156 drivers/md/bcache/nvm-pages.c

97c62b647fcabd Jianpeng Ma 2021-04-14  144  static void init_nvm_free_space(struct bch_nvm_namespace *ns)
97c62b647fcabd Jianpeng Ma 2021-04-14  145  {
97c62b647fcabd Jianpeng Ma 2021-04-14  146  	unsigned int start, end, i;
                                                ^^^^^^^^^^^^             ^

97c62b647fcabd Jianpeng Ma 2021-04-14  147  	struct page *page;
97c62b647fcabd Jianpeng Ma 2021-04-14  148  	long long pages;
97c62b647fcabd Jianpeng Ma 2021-04-14  149  	pgoff_t pgoff_start;
97c62b647fcabd Jianpeng Ma 2021-04-14  150  
97c62b647fcabd Jianpeng Ma 2021-04-14  151  	bitmap_for_each_clear_region(ns->pages_bitmap, start, end, 0, ns->pages_total) {
97c62b647fcabd Jianpeng Ma 2021-04-14  152  		pgoff_start = start;
97c62b647fcabd Jianpeng Ma 2021-04-14  153  		pages = end - start;
97c62b647fcabd Jianpeng Ma 2021-04-14  154  
97c62b647fcabd Jianpeng Ma 2021-04-14  155  		while (pages) {
97c62b647fcabd Jianpeng Ma 2021-04-14 @156  			for (i = BCH_MAX_ORDER - 1; i >= 0 ; i--) {
                                                                                            ^^^^^^
This needs to be "int i;" for the loop to work correctly.

97c62b647fcabd Jianpeng Ma 2021-04-14  157  				if ((pgoff_start % (1 << i) == 0) && (pages >= (1 << i)))
97c62b647fcabd Jianpeng Ma 2021-04-14  158  					break;
97c62b647fcabd Jianpeng Ma 2021-04-14  159  			}
97c62b647fcabd Jianpeng Ma 2021-04-14  160  
97c62b647fcabd Jianpeng Ma 2021-04-14  161  			page = nvm_vaddr_to_page(ns, nvm_pgoff_to_vaddr(ns, pgoff_start));
97c62b647fcabd Jianpeng Ma 2021-04-14  162  			page->index = pgoff_start;
97c62b647fcabd Jianpeng Ma 2021-04-14  163  			set_page_private(page, i);
97c62b647fcabd Jianpeng Ma 2021-04-14  164  			__SetPageBuddy(page);
97c62b647fcabd Jianpeng Ma 2021-04-14  165  			list_add((struct list_head *)&page->zone_device_data, &ns->free_area[i]);
97c62b647fcabd Jianpeng Ma 2021-04-14  166  
97c62b647fcabd Jianpeng Ma 2021-04-14  167  			pgoff_start += 1 << i;
97c62b647fcabd Jianpeng Ma 2021-04-14  168  			pages -= 1 << i;
97c62b647fcabd Jianpeng Ma 2021-04-14  169  		}
97c62b647fcabd Jianpeng Ma 2021-04-14  170  	}
688330711e9ae3 Jianpeng Ma 2021-04-14  171  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org 
_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

             reply	other threads:[~2021-04-20  8:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20  8:10 Dan Carpenter [this message]
2021-04-20  8:10 ` [kbuild] [block:for-5.13/drivers 46/61] drivers/md/bcache/nvm-pages.c:156:34: warning: Unsigned variable 'i' can't be negative so it is unnecessary to test it. [unsignedPositive] Dan Carpenter
2021-04-20 13:40 ` Jens Axboe
2021-04-20 14:59   ` Coly Li
2021-04-20 15:01     ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2021-04-16 16:58 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210420081019.GB1959@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.