WSL2-Linux-Kernel/drivers/acpi
Arnd Bergmann 287980e49f remove lots of IS_ERR_VALUE abuses
Most users of IS_ERR_VALUE() in the kernel are wrong, as they
pass an 'int' into a function that takes an 'unsigned long'
argument. This happens to work because the type is sign-extended
on 64-bit architectures before it gets converted into an
unsigned type.

However, anything that passes an 'unsigned short' or 'unsigned int'
argument into IS_ERR_VALUE() is guaranteed to be broken, as are
8-bit integers and types that are wider than 'unsigned long'.

Andrzej Hajda has already fixed a lot of the worst abusers that
were causing actual bugs, but it would be nice to prevent any
users that are not passing 'unsigned long' arguments.

This patch changes all users of IS_ERR_VALUE() that I could find
on 32-bit ARM randconfig builds and x86 allmodconfig. For the
moment, this doesn't change the definition of IS_ERR_VALUE()
because there are probably still architecture specific users
elsewhere.

Almost all the warnings I got are for files that are better off
using 'if (err)' or 'if (err < 0)'.
The only legitimate user I could find that we get a warning for
is the (32-bit only) freescale fman driver, so I did not remove
the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
For 9pfs, I just worked around one user whose calling conventions
are so obscure that I did not dare change the behavior.

I was using this definition for testing:

 #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
       unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))

which ends up making all 16-bit or wider types work correctly with
the most plausible interpretation of what IS_ERR_VALUE() was supposed
to return according to its users, but also causes a compile-time
warning for any users that do not pass an 'unsigned long' argument.

I suggested this approach earlier this year, but back then we ended
up deciding to just fix the users that are obviously broken. After
the initial warning that caused me to get involved in the discussion
(fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
asked me to send the whole thing again.

[ Updated the 9p parts as per Al Viro  - Linus ]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lkml.org/lkml/2016/1/7/363
Link: https://lkml.org/lkml/2016/5/27/486
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-05-27 15:26:11 -07:00
..
acpica Merge back new ACPICA material for v4.7. 2016-05-06 01:41:06 +02:00
apei Power management and ACPI material for v4.6-rc1, part 1 2016-03-16 14:10:53 -07:00
pmic drivers/acpi: make pmic/intel_pmic_crc.c explicitly non-modular 2016-03-09 23:46:07 +01:00
Kconfig Merge branches 'acpi-pci', 'acpi-misc' and 'acpi-tools' 2016-05-16 16:45:48 +02:00
Makefile Merge branches 'acpi-numa', 'acpi-tables' and 'acpi-osi' 2016-05-16 16:45:25 +02:00
ac.c
acpi_amba.c ACPI / amba: Remove CLK_IS_ROOT 2016-04-27 23:42:57 +02:00
acpi_apd.c ACPI / APD: Remove CLK_IS_ROOT 2016-04-27 23:42:57 +02:00
acpi_cmos_rtc.c
acpi_dbg.c remove lots of IS_ERR_VALUE abuses 2016-05-27 15:26:11 -07:00
acpi_extlog.c
acpi_ipmi.c
acpi_lpat.c
acpi_lpss.c
acpi_memhotplug.c
acpi_pad.c
acpi_platform.c Power management and ACPI material for v4.6-rc1, part 1 2016-03-16 14:10:53 -07:00
acpi_pnp.c
acpi_processor.c ACPI / processor: Request native thermal interrupt handling via _OSC 2016-03-26 02:00:38 +01:00
acpi_video.c ACPI/video: export acpi_video_get_levels 2016-05-04 23:41:14 +02:00
battery.c ACPI / battery: Correctly serialise with the pending async probe 2016-05-21 01:25:07 +02:00
battery.h
bgrt.c drivers/acpi: make bgrt driver explicitly non-modular 2016-03-09 23:46:07 +01:00
blacklist.c ACPI / osi: Collect _OSI handling into one single file 2016-05-05 00:13:53 +02:00
bus.c ACPI 2.0 / ECDT: Enable correct ECDT initialization order 2016-04-09 03:06:44 +02:00
button.c
cm_sbs.c
container.c
cppc_acpi.c ACPI / CPPC: use MRTT/MPAR to decide if/when a req can be sent 2016-03-09 23:35:29 +01:00
custom_method.c
debugfs.c
device_pm.c ACPI / PM: Export acpi_device_fix_up_power() 2016-05-20 15:54:01 +02:00
device_sysfs.c ACPI / device_sysfs: Clean up checkpatch errors 2016-05-04 23:47:32 +02:00
dock.c
ec.c ACPI 2.0 / ECDT: Remove early namespace reference from EC 2016-04-09 03:06:44 +02:00
ec_sys.c
event.c
evged.c ACPI / GED: make evged.c explicitly non-modular 2016-05-09 22:59:25 +02:00
fan.c
glue.c
gsi.c
hed.c
int340x_thermal.c
internal.h Merge branches 'acpi-numa', 'acpi-tables' and 'acpi-osi' 2016-05-16 16:45:25 +02:00
ioapic.c
nfit.c Merge branch 'for-4.7/acpi6.1' into libnvdimm-for-next 2016-05-18 10:07:19 -07:00
nfit.h Merge branch 'for-4.7/acpi6.1' into libnvdimm-for-next 2016-05-18 10:07:19 -07:00
numa.c ACPI / SRAT: fix SRAT parsing order with both LAPIC and X2APIC present 2016-04-21 22:13:03 +02:00
nvs.c
osi.c ACPI / osi: Collect _OSI handling into one single file 2016-05-05 00:13:53 +02:00
osl.c Merge branches 'acpi-numa', 'acpi-tables' and 'acpi-osi' 2016-05-16 16:45:25 +02:00
pci_irq.c
pci_link.c ACPI,PCI,IRQ: remove SCI penalize function 2016-05-05 01:10:32 +02:00
pci_root.c
pci_slot.c
power.c
proc.c
processor_core.c
processor_driver.c
processor_idle.c Power management and ACPI material for v4.6-rc1, part 1 2016-03-16 14:10:53 -07:00
processor_pdc.c
processor_perflib.c
processor_thermal.c
processor_throttling.c
property.c ACPI / property: fix data node parsing in acpi_get_next_subnode() 2016-03-17 03:06:38 +01:00
reboot.c
resource.c PCI: ACPI: IA64: fix IO port generic range check 2016-03-22 23:07:49 +01:00
sbs.c
sbshc.c
sbshc.h
scan.c
sleep.c ACPI / PM: Introduce efi poweroff for HW-full platforms without _S5 2016-04-09 02:11:43 +02:00
sleep.h
sysfs.c ACPI / sysfs: fix error code in get_status() 2016-05-05 15:28:58 +02:00
tables.c ACPI / tables: Fix DSDT override mechanism 2016-05-06 13:20:11 +02:00
thermal.c
utils.c libnvdimm for 4.7 2016-05-23 11:18:01 -07:00
video_detect.c video / backlight: remove the backlight_device_registered API 2016-05-04 23:41:14 +02:00
wakeup.c