linux
Disabling PCI support implies that a void* pointer will be dereferenced
When PCI is disabled VORTEX_PCI(vp) will always return NULL, which is of type void*. VORTEX_PCI(vp) is defined by a conditional expression, but the compiler can infer that the pointer returned is always of this type, and emits a warning because it is being dereferenced later on.
Bug fixed by commit d530db0db90
| Type | VoidPointerDereference |
| Config | "VORTEX && !PCI" (2nd degree) |
| Fix-in | code |
| Location | drivers/net/ |
#ifdef CONFIG_VORTEX
#include <stdlib.h>
int some_int = 1;
#ifdef CONFIG_PCI
#define DEVICE_PCI(dev) ((dev % 2) ? &some_int : NULL)
#else
#define DEVICE_PCI(dev) NULL
#endif
#define VORTEX_PCI(vp) ((vp) ? DEVICE_PCI(vp) : NULL)
void acpi_set_WOL(int vp)
{
if (1) {
if (*VORTEX_PCI(vp) < 0) // ERROR
return;
}
}
#endif
int main()
{
#ifdef CONFIG_VORTEX
acpi_set_WOL(1);
#endif
return 0;
}
diff --git a/simple/d530db0.c b/simple/d530db0.c
--- a/simple/d530db0.c
+++ b/simple/d530db0.c
@@ -11,7 +11,7 @@
#define DEVICE_PCI(dev) NULL
#endif
-#define VORTEX_PCI(vp) ((vp) ? DEVICE_PCI(vp) : NULL)
+#define VORTEX_PCI(vp) ((int) (vp) ? DEVICE_PCI(vp) : NULL)
void acpi_set_WOL(int vp)
{
#ifdef CONFIG_VORTEX
#include <stdlib.h>
int some_int = 1;
#ifdef CONFIG_PCI
#define DEVICE_PCI(dev) ((dev % 2) ? &some_int : NULL)
#else
#define DEVICE_PCI(dev) NULL
#endif
#define VORTEX_PCI(vp) ((vp) ? DEVICE_PCI(vp) : NULL)
int main()
{
#ifdef CONFIG_VORTEX
// acpi_set_WOL(1);
if (1) {
if (*VORTEX_PCI(1) < 0) // ERROR
return;
}
#endif
return 0;
}