Linux Warning Report - 5.6-rc2

From: Zzy Wysm
Date: Sun Feb 16 2020 - 19:53:45 EST


On February 12, 2020, Linus Torvalds wrote:
"I do not want to see a _single_ warning in the kernel build. Yes, we
have one in the samples code, and even that annoys the hell out of me.â

(Source: <https://lkml.org/lkml/2020/2/12/996>)

A noble goal, and one I endorse.

With that in mind, I decided to see if the Linux kernel truly builds warning-free. Spoiler: it did not. I built Linux 5.6-rc2 with gcc 9.2.1-9ubuntu2 using make defconfig.

Result: 33 warnings.

Let me know if youâre interested in:
* regular warning reports
* additional code coverage beyond defconfig
* additional warning types

(Note, I am not a member of this list, please include me directly on any replies.)

Regards,
zzy



zzy@esquivalience:~/linux-5.6-rc2$ make -j6 KCFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers" > build_log_5.6-rc2
kernel/time/hrtimer.c:120:21: warning: initialized field overwritten [-Woverride-init]
120 | [CLOCK_REALTIME] = HRTIMER_BASE_REALTIME,
| ^~~~~~~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:120:21: note: (near initialization for âhrtimer_clock_to_base_table[0]â)
kernel/time/hrtimer.c:121:22: warning: initialized field overwritten [-Woverride-init]
121 | [CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC,
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:121:22: note: (near initialization for âhrtimer_clock_to_base_table[1]â)
kernel/time/hrtimer.c:122:21: warning: initialized field overwritten [-Woverride-init]
122 | [CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME,
| ^~~~~~~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:122:21: note: (near initialization for âhrtimer_clock_to_base_table[7]â)
kernel/time/hrtimer.c:123:17: warning: initialized field overwritten [-Woverride-init]
123 | [CLOCK_TAI] = HRTIMER_BASE_TAI,
| ^~~~~~~~~~~~~~~~
kernel/time/hrtimer.c:123:17: note: (near initialization for âhrtimer_clock_to_base_table[11]â)
In file included from kernel/bpf/core.c:21:
kernel/bpf/core.c: In function â___bpf_prog_runâ:
./include/linux/filter.h:863:3: warning: cast between incompatible function types from âu64 (*)(u64, u64, u64, u64, u64)â {aka âlong long unsigned int (*)(long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int)â} to âu64 (*)(u64, u64, u64, u64, u64, const struct bpf_insn *)â {aka âlong long unsigned int (*)(long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, const struct bpf_insn *)â} [-Wcast-function-type]
863 | ((u64 (*)(u64, u64, u64, u64, u64, const struct bpf_insn *)) \
| ^
kernel/bpf/core.c:1513:13: note: in expansion of macro â__bpf_call_base_argsâ
1513 | BPF_R0 = (__bpf_call_base_args + insn->imm)(BPF_R1, BPF_R2,
| ^~~~~~~~~~~~~~~~~~~~
kernel/bpf/core.c: In function âbpf_patch_call_argsâ:
./include/linux/filter.h:863:3: warning: cast between incompatible function types from âu64 (*)(u64, u64, u64, u64, u64)â {aka âlong long unsigned int (*)(long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int)â} to âu64 (*)(u64, u64, u64, u64, u64, const struct bpf_insn *)â {aka âlong long unsigned int (*)(long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, const struct bpf_insn *)â} [-Wcast-function-type]
863 | ((u64 (*)(u64, u64, u64, u64, u64, const struct bpf_insn *)) \
| ^
kernel/bpf/core.c:1704:3: note: in expansion of macro â__bpf_call_base_argsâ
1704 | __bpf_call_base_args;
| ^~~~~~~~~~~~~~~~~~~~
arch/x86/kernel/jump_label.c:61:1: warning: âinlineâ is not at beginning of declaration [-Wold-style-declaration]
61 | static void inline __jump_label_transform(struct jump_entry *entry,
| ^~~~~~
kernel/trace/blktrace.c: In function â__trace_note_messageâ:
kernel/trace/blktrace.c:145:63: warning: parameter âblkcgâ set but not used [-Wunused-but-set-parameter]
145 | void __trace_note_message(struct blk_trace *bt, struct blkcg *blkcg,
| ~~~~~~~~~~~~~~^~~~~
In file included from ./include/linux/capability.h:16,
from security/commoncap.c:5:
security/commoncap.c: In function âcap_prctl_dropâ:
./include/uapi/linux/capability.h:373:27: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
373 | #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
| ^~
security/commoncap.c:1145:7: note: in expansion of macro âcap_validâ
1145 | if (!cap_valid(cap))
| ^~~~~~~~~
security/commoncap.c: In function âcap_task_prctlâ:
./include/uapi/linux/capability.h:373:27: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
373 | #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
| ^~
security/commoncap.c:1175:8: note: in expansion of macro âcap_validâ
1175 | if (!cap_valid(arg2))
| ^~~~~~~~~
./include/uapi/linux/capability.h:373:27: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
373 | #define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
| ^~
security/commoncap.c:1260:10: note: in expansion of macro âcap_validâ
1260 | if (((!cap_valid(arg3)) | arg4 | arg5))
| ^~~~~~~~~
drivers/video/fbdev/core/fbmon.c: In function âget_monspecsâ:
drivers/video/fbdev/core/fbmon.c:812:47: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
812 | DPRINTK(" Configurable signal level\n");
| ^
drivers/video/fbdev/core/fbmon.c:842:24: warning: suggest braces around empty body in an âelseâ statement [-Wempty-body]
842 | DPRINTK("variable\n");
| ^
drivers/video/fbdev/core/fbmon.c:847:24: warning: suggest braces around empty body in an âelseâ statement [-Wempty-body]
847 | DPRINTK("variable\n");
| ^
drivers/acpi/scan.c: In function âacpi_bus_get_wakeup_device_flagsâ:
drivers/acpi/scan.c:903:43: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
903 | "error in _DSW or _PSW evaluation\n"));
| ^
drivers/acpi/acpi_processor.c: In function âacpi_processor_errata_piix4â:
drivers/acpi/acpi_processor.c:133:67: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
133 | "Bus master activity detection (BM-IDE) erratum enabled\n"));
| ^
drivers/acpi/acpi_processor.c:136:54: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
136 | "Type-F DMA livelock erratum (C3 disabled)\n"));
| ^
drivers/acpi/acpi_processor.c: In function âacpi_processor_get_infoâ:
drivers/acpi/acpi_processor.c:251:49: warning: suggest braces around empty body in an âelseâ statement [-Wempty-body]
251 | "No bus mastering arbitration control\n"));
| ^
drivers/acpi/processor_pdc.c: In function âacpi_processor_eval_pdcâ:
drivers/acpi/processor_pdc.c:136:65: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
136 | "Could not evaluate _PDC, using legacy perf. control.\n"));
| ^
drivers/tty/vt/keyboard.c: In function âk_fnâ:
drivers/tty/vt/keyboard.c:740:22: warning: comparison is always true due to limited range of data type [-Wtype-limits]
740 | if ((unsigned)value < ARRAY_SIZE(func_table)) {
| ^
fs/posix_acl.c: In function âget_aclâ:
fs/posix_acl.c:127:22: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
127 | /* fall through */ ;
| ^
drivers/scsi/sr.c:691:12: warning: initialized field overwritten [-Woverride-init]
691 | .ioctl = sr_block_compat_ioctl,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/scsi/sr.c:691:12: note: (near initialization for âsr_bdops.ioctlâ)
In file included from drivers/ata/ahci.c:35:
drivers/ata/ahci.h:384:16: warning: initialized field overwritten [-Woverride-init]
384 | .can_queue = AHCI_MAX_CMDS, \
| ^~~~~~~~~~~~~
drivers/ata/ahci.c:103:2: note: in expansion of macro âAHCI_SHTâ
103 | AHCI_SHT("ahci"),
| ^~~~~~~~
drivers/ata/ahci.h:384:16: note: (near initialization for âahci_sht.can_queueâ)
384 | .can_queue = AHCI_MAX_CMDS, \
| ^~~~~~~~~~~~~
drivers/ata/ahci.c:103:2: note: in expansion of macro âAHCI_SHTâ
103 | AHCI_SHT("ahci"),
| ^~~~~~~~
drivers/ata/ahci.h:388:17: warning: initialized field overwritten [-Woverride-init]
388 | .sdev_attrs = ahci_sdev_attrs
| ^~~~~~~~~~~~~~~
drivers/ata/ahci.c:103:2: note: in expansion of macro âAHCI_SHTâ
103 | AHCI_SHT("ahci"),
| ^~~~~~~~
drivers/ata/ahci.h:388:17: note: (near initialization for âahci_sht.sdev_attrsâ)
388 | .sdev_attrs = ahci_sdev_attrs
| ^~~~~~~~~~~~~~~
drivers/ata/ahci.c:103:2: note: in expansion of macro âAHCI_SHTâ
103 | AHCI_SHT("ahci"),
| ^~~~~~~~
lib/errname.c:15:67: warning: initialized field overwritten [-Woverride-init]
15 | #define E(err) [err + BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
| ^~~
lib/errname.c:172:2: note: in expansion of macro âEâ
172 | E(EDEADLK), /* EDEADLOCK */
| ^
lib/errname.c:15:67: note: (near initialization for ânames_0[35]â)
15 | #define E(err) [err + BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
| ^~~
lib/errname.c:172:2: note: in expansion of macro âEâ
172 | E(EDEADLK), /* EDEADLOCK */
| ^
lib/radix-tree.c: In function âset_iter_tagsâ:
lib/radix-tree.c:1134:15: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1134 | if (tag_long < RADIX_TREE_TAG_LONGS - 1) {
| ^
drivers/input/mouse/synaptics.c: In function âsynaptics_process_packetâ:
drivers/input/mouse/synaptics.c:1105:6: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
1105 | ; /* Nothing, treat a pen as a single finger */
| ^
drivers/usb/core/sysfs.c: In function âusb_create_sysfs_intf_filesâ:
drivers/usb/core/sysfs.c:1266:3: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
1266 | ; /* We don't actually care if the function fails. */
| ^
drivers/md/md.c: In function âbind_rdev_to_arrayâ:
drivers/md/md.c:2438:27: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
2438 | /* failure here is OK */;
| ^
drivers/md/md.c: In function âslot_storeâ:
drivers/md/md.c:3200:28: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
3200 | /* failure here is OK */;
| ^
drivers/md/md.c: In function âremove_and_add_sparesâ:
drivers/md/md.c:9045:29: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
9045 | /* failure here is OK */;
| ^
drivers/hid/hid-lgff.c: In function âhid_lgff_playâ:
drivers/hid/hid-lgff.c:65:24: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
65 | #define CLAMP(x) if (x < 0) x = 0; if (x > 0xff) x = 0xff
| ^
drivers/hid/hid-lgff.c:86:3: note: in expansion of macro âCLAMPâ
86 | CLAMP(left);
| ^~~~~
drivers/hid/hid-lgff.c:65:24: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
65 | #define CLAMP(x) if (x < 0) x = 0; if (x > 0xff) x = 0xff
| ^
drivers/hid/hid-lgff.c:87:3: note: in expansion of macro âCLAMPâ
87 | CLAMP(right);
| ^~~~~