kernel_optimize_test/drivers
Coly Li d1c3cc34f5 bcache: fix incorrect data type usage in btree_flush_write()
Dan Carpenter points out that from commit 2aa8c52938 ("bcache: avoid
unnecessary btree nodes flushing in btree_flush_write()"), there is a
incorrect data type usage which leads to the following static checker
warning:
	drivers/md/bcache/journal.c:444 btree_flush_write()
	warn: 'ref_nr' unsigned <= 0

drivers/md/bcache/journal.c
   422  static void btree_flush_write(struct cache_set *c)
   423  {
   424          struct btree *b, *t, *btree_nodes[BTREE_FLUSH_NR];
   425          unsigned int i, nr, ref_nr;
                                    ^^^^^^

   426          atomic_t *fifo_front_p, *now_fifo_front_p;
   427          size_t mask;
   428
   429          if (c->journal.btree_flushing)
   430                  return;
   431
   432          spin_lock(&c->journal.flush_write_lock);
   433          if (c->journal.btree_flushing) {
   434                  spin_unlock(&c->journal.flush_write_lock);
   435                  return;
   436          }
   437          c->journal.btree_flushing = true;
   438          spin_unlock(&c->journal.flush_write_lock);
   439
   440          /* get the oldest journal entry and check its refcount */
   441          spin_lock(&c->journal.lock);
   442          fifo_front_p = &fifo_front(&c->journal.pin);
   443          ref_nr = atomic_read(fifo_front_p);
   444          if (ref_nr <= 0) {
                    ^^^^^^^^^^^
Unsigned can't be less than zero.

   445                  /*
   446                   * do nothing if no btree node references
   447                   * the oldest journal entry
   448                   */
   449                  spin_unlock(&c->journal.lock);
   450                  goto out;
   451          }
   452          spin_unlock(&c->journal.lock);

As the warning information indicates, local varaible ref_nr in unsigned
int type is wrong, which does not matche atomic_read() and the "<= 0"
checking.

This patch fixes the above error by defining local variable ref_nr as
int type.

Fixes: 2aa8c52938 ("bcache: avoid unnecessary btree nodes flushing in btree_flush_write()")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2020-02-01 07:55:39 -07:00
..
accessibility
acpi Merge branch 'core-headers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 08:20:54 -08:00
amba
android binder: fix log spam for existing debugfs file creation. 2020-01-22 15:14:24 +01:00
ata ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
atm Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
auxdisplay
base linux-kselftest-5.6-rc1-kunit 2020-01-29 15:25:34 -08:00
bcma Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
block xen/blkfront: limit allocated memory size to actual use case 2020-01-29 21:13:18 -07:00
bluetooth Bluetooth: btrtl: Use kvmalloc for FW allocations 2020-01-24 19:57:53 +01:00
bus Char/Misc driver changes for 5.6-rc1 2020-01-29 10:35:54 -08:00
cdrom
char Char/Misc driver changes for 5.6-rc1 2020-01-29 10:35:54 -08:00
clk ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
clocksource The timekeeping and timers departement provides: 2020-01-27 16:47:05 -08:00
connector
counter
cpufreq ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
cpuidle Merge branch 'intel_idle+acpi' 2020-01-23 00:35:50 +01:00
crypto Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
dax
dca
devfreq PM / devfreq: Add debugfs support with devfreq_summary file 2020-01-16 19:14:49 +09:00
dio
dma ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
dma-buf - A fix for a memory leak in the dma-buf support 2019-12-09 17:13:19 +10:00
edac ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
eisa
extcon extcon: sm5502: Remove unneeded semicolon 2019-12-16 10:23:19 +09:00
firewire remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
firmware Char/Misc driver changes for 5.6-rc1 2020-01-29 10:35:54 -08:00
fpga fpga: xilinx-pr-decoupler: Remove clk_get error message for probe defer 2020-01-10 12:51:56 -08:00
fsi
gnss
gpio This is the bulk of pin control changes for the v5.6 kernel cycle: 2020-01-29 09:51:36 -08:00
gpu y2038: core, driver and file system changes 2020-01-29 14:55:47 -08:00
greybus
hid Merge branch 'for-5.6/logitech' into for-linus 2020-01-27 15:49:49 +01:00
hsi
hv clocksource/drivers/hyper-v: Untangle stimers and timesync from clocksources 2020-01-16 19:09:02 +01:00
hwmon ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
hwspinlock
hwtracing coresight: etm4x: Fix unused function warning 2020-01-14 15:38:28 +01:00
i2c ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
i3c i3c: master: dw: reattach device on first available location of address table 2020-01-13 10:00:05 +01:00
ide
idle Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 12:46:42 -08:00
iio Merge 5.5-rc7 into staging-next 2020-01-22 09:05:34 +01:00
infiniband Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
input ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
interconnect interconnect: qcom: Add MSM8916 interconnect provider driver 2020-01-07 09:30:09 +02:00
iommu ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
ipack remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
irqchip The interrupt departement provides: 2020-01-27 17:22:21 -08:00
isdn isdn: don't mark kcapi_proc_exit as __exit 2019-12-17 08:59:57 +01:00
leds leds: lm3532: add pointer to documentation and fix typo 2020-01-22 21:08:24 +01:00
lightnvm
macintosh
mailbox
mcb
md bcache: fix incorrect data type usage in btree_flush_write() 2020-02-01 07:55:39 -07:00
media Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2020-01-28 09:03:40 -08:00
memory memory: tegra: Fixes for v5.5-rc1 2019-12-06 08:28:51 -08:00
memstick
message Merge ra.kernel.org:/pub/scm/linux/kernel/git/netdev/net 2020-01-19 22:10:04 +01:00
mfd
misc Char/Misc driver changes for 5.6-rc1 2020-01-29 10:35:54 -08:00
mmc ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
mtd ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
mux
net USB/Thunderbolt/PHY driver updates for 5.6-rc1 2020-01-29 10:09:44 -08:00
nfc Merge ra.kernel.org:/pub/scm/linux/kernel/git/netdev/net 2020-01-19 22:10:04 +01:00
ntb Add Hygon Device ID to the AMD NTB device driver 2019-12-07 18:38:17 -08:00
nubus
nvdimm
nvme for-5.6/block-2020-01-27 2020-01-27 12:38:25 -08:00
nvmem nvmem: add QTI SDAM driver 2020-01-16 20:56:49 +01:00
of net: mdio: of: Register discovered MII time stampers. 2019-12-25 19:51:33 -08:00
opp ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
oprofile
parisc remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
parport
pci ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
pcmcia
perf perf/imx_ddr: Fix cpu hotplug state cleanup 2020-01-15 12:48:40 +00:00
phy USB/Thunderbolt/PHY driver updates for 5.6-rc1 2020-01-29 10:09:44 -08:00
pinctrl This is the bulk of pin control changes for the v5.6 kernel cycle: 2020-01-29 09:51:36 -08:00
platform ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
pnp PNP: isapnp: remove defined but not used function 'isapnp_checksum' 2020-01-23 00:26:13 +01:00
power power: avs: qcom-cpr: remove duplicated include from qcom-cpr.c 2020-01-08 23:25:22 +01:00
powercap Merge back power capping changes for v5.6. 2020-01-13 10:32:19 +01:00
pps
ps3
ptp Merge ra.kernel.org:/pub/scm/linux/kernel/git/netdev/net 2020-01-19 22:10:04 +01:00
pwm
rapidio
ras
regulator ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
remoteproc
reset reset: Do not register resource data for missing resets 2019-12-10 11:43:37 +01:00
rpmsg
rtc ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
s390 s390/qeth: remove HARDSETUP state 2020-01-26 15:20:32 +01:00
sbus
scsi ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
sfi
sh remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
siox siox: Use the correct style for SPDX License Identifier 2020-01-14 21:46:53 +01:00
slimbus slimbus: qcom: add missed clk_disable_unprepare in remove 2020-01-14 21:46:48 +01:00
soc ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
soundwire soundwire: cadence: fix kernel-doc parameter descriptions 2020-01-16 17:34:38 +05:30
spi ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
spmi
ssb remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
staging Staging/IIO patches for 5.6-rc1 2020-01-29 10:15:11 -08:00
target SCSI fixes on 20200126 2020-01-26 10:39:09 -08:00
tc remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
tee Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2020-01-28 15:38:56 -08:00
thermal - Depromote debug print on the db8500 platform (Linus Walleij) 2020-01-28 16:31:08 -08:00
thunderbolt thunderbolt: fix memory leak of object sw 2020-01-14 15:37:41 +01:00
tty TTY/Serial driver updates for 5.6-rc1 2020-01-29 10:13:27 -08:00
uio uio: uio_pdrv_genirq: Do not log an error when deferring probe routine. 2020-01-14 15:27:51 +01:00
usb USB/Thunderbolt/PHY driver updates for 5.6-rc1 2020-01-29 10:09:44 -08:00
vfio remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
vhost Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2019-12-08 13:28:11 -08:00
video TTY/Serial driver updates for 5.6-rc1 2020-01-29 10:13:27 -08:00
virt virt: vbox: Explicitly include linux/io.h to pick up various defs 2019-12-10 10:15:48 +01:00
virtio virtio_balloon: divide/multiply instead of shifts 2019-12-11 08:14:07 -05:00
visorbus visorbus: fix uninitialized variable access 2020-01-14 15:30:35 +01:00
vlynq
vme Char/Misc driver changes for 5.6-rc1 2020-01-29 10:35:54 -08:00
w1 Char/Misc driver changes for 5.6-rc1 2020-01-29 10:35:54 -08:00
watchdog ioremap changes for 5.6 2020-01-27 13:03:00 -08:00
xen Linux 5.5-rc3 2019-12-25 10:41:37 +01:00
zorro
Kconfig
Makefile thunderbolt: Update Kconfig entries to USB4 2019-12-18 15:39:18 +01:00