NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/57829: pci_subr.c: gcc -O failed 'str' may be used uninitialized in this function
>Number: 57829
>Category: kern
>Synopsis: pci_subr.c: gcc -O failed 'str' may be used uninitialized in this function
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jan 08 06:10:00 +0000 2024
>Originator: Kouichi Hashikawa
>Release: 9.3-RELEASE, 10.0-RC2, current
>Organization:
>Environment:
>Description:
gcc -O failed to compile pci_subr.c with 'str' may be used uninitialized in this function.
(10.0-RC2, pci_subr.c is 1.242).
--- pci_subr.o ---
/usr/src/sys/dev/pci/pci_subr.c: In function 'pci_conf_print_type0':
/usr/src/sys/dev/pci/pci_subr.c:4783:2: error: 'str' may be used uninitialized in this function [-Werror=maybe-uninitialized]
4783 | printf("%s\n", str);
| ^~~~~~~~~~~~~~~~~~~
I think 9.3 and current have same problem.
>How-To-Repeat:
>Fix:
I apply following patch.
--- src/sys/dev/pci/pci_subr.c-1242 2022-02-10 14:20:10.212466898 +0900
+++ src/sys/dev/pci/pci_subr.c 2024-01-08 14:43:49.139272695 +0900
@@ -4729,7 +4729,7 @@
{
int off, width;
pcireg_t rval;
- const char *str;
+ const char *str = NULL;
for (off = PCI_MAPREG_START; off < PCI_MAPREG_END; off += width) {
#ifdef _KERNEL
@@ -4780,7 +4780,8 @@
"Valid and trusted contents";
break;
}
- printf("%s\n", str);
+ if (str != NULL)
+ printf("%s\n", str);
printf(" Validation Details: 0x%x\n",
PCIREG_SHIFTOUT(rval, PCI_MAPREG_ROM_VALID_DETAIL));
Home |
Main Index |
Thread Index |
Old Index