Hi, I have compiled the kernel with clang -Wuninitialized and would like to fix these findings: - toshiba_hotkey() is a bug - in rasops_bitops.h is useless code - in elf_load_file() it is nicer to call free(NULL, type, 0) instead of free(NULL, type, undefined). Not a real bug as free(9) checks the pointer before the size, but the compiler cannot know that. - nfs_connect() returns EINVAL at the beginning if nm_sotype is invalid. But the compiler cannot know whether it has changed in the meantime, so in the else case a bunch of variables would not be initialized. A panic() there changes the compiler assumptions and should not be reached anyway.
I did not fix all -Wuninitialized warnings: - The warnings in dev/pci/drm/ are false positives and I don't want to touch the linux code. - In net/art.c is a false positive and the compiler could know better. ok? bluhm Index: dev/acpi/acpitoshiba.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/dev/acpi/acpitoshiba.c,v retrieving revision 1.8 diff -u -p -r1.8 acpitoshiba.c --- dev/acpi/acpitoshiba.c 28 Feb 2017 10:39:07 -0000 1.8 +++ dev/acpi/acpitoshiba.c 6 Sep 2017 13:58:02 -0000 @@ -381,7 +381,7 @@ int toshiba_hotkey(struct aml_node *node, int notify, void *arg) { struct acpitoshiba_softc *sc = arg; - int event, ret; + int event, ret = HCI_FAILURE; event = toshiba_read_events(sc); if (!event) Index: dev/rasops/rasops_bitops.h =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/dev/rasops/rasops_bitops.h,v retrieving revision 1.6 diff -u -p -r1.6 rasops_bitops.h --- dev/rasops/rasops_bitops.h 28 Aug 2010 12:48:14 -0000 1.6 +++ dev/rasops/rasops_bitops.h 6 Sep 2017 13:34:21 -0000 @@ -237,10 +237,8 @@ NAME(copycols)(void *cookie, int row, in rnum = 32 - lnum; db = dst & 31; - if ((src -= db) < 0) { - sp--; + if ((src -= db) < 0) src += 32; - } while (height--) { sp = srp; Index: kern/exec_elf.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/kern/exec_elf.c,v retrieving revision 1.140 diff -u -p -r1.140 exec_elf.c --- kern/exec_elf.c 20 Mar 2017 00:05:21 -0000 1.140 +++ kern/exec_elf.c 6 Sep 2017 13:23:49 -0000 @@ -318,7 +318,7 @@ elf_load_file(struct proc *p, char *path struct nameidata nd; Elf_Ehdr eh; Elf_Phdr *ph = NULL; - u_long phsize; + u_long phsize = 0; Elf_Addr addr; struct vnode *vp; Elf_Phdr *base_ph = NULL; Index: nfs/nfs_socket.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/sys/nfs/nfs_socket.c,v retrieving revision 1.127 diff -u -p -r1.127 nfs_socket.c --- nfs/nfs_socket.c 5 Sep 2017 08:02:48 -0000 1.127 +++ nfs/nfs_socket.c 6 Sep 2017 13:31:24 -0000 @@ -357,6 +357,8 @@ nfs_connect(struct nfsmount *nmp, struct sizeof (u_int32_t)) * 2; rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR + sizeof (u_int32_t)) * 2; + } else { + panic("%s: nm_sotype %d", __func__, nmp->nm_sotype); } error = soreserve(so, sndreserve, rcvreserve); if (error)