Re: [ACPI] Re: [PATCH] cleanup ACPI numa warnings

From: Alex Williamson
Date: Fri Aug 20 2004 - 14:07:39 EST



I'm not sure where we stand on this, sorry for the delay. To recap,
the first patch I submitted cleaned up the original functions, but moved
the ugliness up into multi-line macros. People didn't like the macros
and suggested static inlines. However, static inlines don't work for
this application because the debug print needs state setup by the
ACPI_FUNCTION_NAME call. IMHO, it's not worth setting up that state in
the static inline function for this little bit of cleanup.

So, I think we left it at nobody liked the macros and static inlines
don't work. General unhappiness. Below is a patch that doesn't attempt
to cleanup the original code, it just adds the #ifdefs and range
checking w/ no macros. Does this look better? Below is the original
submit comment outlining the goal. Thanks,

Alex

The patch below removes these warnings:

CC drivers/acpi/numa.o
drivers/acpi/numa.c: In function `acpi_table_print_srat_entry':
drivers/acpi/numa.c:55: warning: unused variable `p'
drivers/acpi/numa.c:65: warning: unused variable `p'
drivers/acpi/numa.c: In function `acpi_numa_init':
drivers/acpi/numa.c:179: warning: passing arg 2 of
`acpi_table_parse_srat' from incompatible pointer type
drivers/acpi/numa.c:182: warning: passing arg 2 of
`acpi_table_parse_srat' from incompatible pointer type

And propagates the MADT error checking code into the SRAT code.

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>

===== drivers/acpi/numa.c 1.10 vs edited =====
--- 1.10/drivers/acpi/numa.c 2004-02-18 02:19:31 -07:00
+++ edited/drivers/acpi/numa.c 2004-08-10 16:58:37 -06:00
@@ -51,6 +51,7 @@
switch (header->type) {

case ACPI_SRAT_PROCESSOR_AFFINITY:
+#ifdef ACPI_DEBUG_OUTPUT
{
struct acpi_table_processor_affinity *p =
(struct acpi_table_processor_affinity*) header;
@@ -58,9 +59,11 @@
p->apic_id, p->lsapic_eid, p->proximity_domain,
p->flags.enabled?"enabled":"disabled"));
}
+#endif
break;

case ACPI_SRAT_MEMORY_AFFINITY:
+#ifdef ACPI_DEBUG_OUTPUT
{
struct acpi_table_memory_affinity *p =
(struct acpi_table_memory_affinity*) header;
@@ -70,6 +73,7 @@
p->flags.enabled ? "enabled" : "disabled",
p->flags.hot_pluggable ? " hot-pluggable" : ""));
}
+#endif
break;

default:
@@ -103,12 +107,14 @@


static int __init
-acpi_parse_processor_affinity (acpi_table_entry_header *header)
+acpi_parse_processor_affinity (acpi_table_entry_header *header, unsigned long size)
{
struct acpi_table_processor_affinity *processor_affinity;

processor_affinity = (struct acpi_table_processor_affinity*) header;
- if (!processor_affinity)
+ if (!processor_affinity || (unsigned long)processor_affinity +
+ sizeof(*processor_affinity) > size ||
+ header->length != sizeof(*processor_affinity))
return -EINVAL;

acpi_table_print_srat_entry(header);
@@ -121,12 +127,14 @@


static int __init
-acpi_parse_memory_affinity (acpi_table_entry_header *header)
+acpi_parse_memory_affinity (acpi_table_entry_header *header, unsigned long size)
{
struct acpi_table_memory_affinity *memory_affinity;

memory_affinity = (struct acpi_table_memory_affinity*) header;
- if (!memory_affinity)
+ if (!memory_affinity || (unsigned long)memory_affinity +
+ sizeof(*memory_affinity) > size ||
+ header->length != sizeof(*memory_affinity))
return -EINVAL;

acpi_table_print_srat_entry(header);



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/