Using uninitialized_var() is dangerous as it papers over real bugs[1] (or can in the future), and suppresses unrelated compiler warnings (e.g. "unused variable"). If the compiler thinks it is uninitialized, either simply initialize the variable or make compiler changes. As a precursor to removing[2] this[3] macro[4], refactor code to avoid its need. The original reason for its use here was to work around the #ifdef being the only place the variable was used. This is better expressed using IS_ENABLED() and a new code block where the variable can be used unconditionally. [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/ [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/ [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/ [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/
Unified · Split
| @@ -543,7 +543,6 @@ static void __init numa_clear_kernel_node_hotplug(void) · 542 unmodified lines | |||
| 543 | 543 | ||
| 544 | static int __init numa_register_memblks(struct numa_meminfo *mi) | 544 | static int __init numa_register_memblks(struct numa_meminfo *mi) |
| 545 | { | 545 | { |
| 546 | unsigned long uninitialized_var(pfn_align); | ||
| 547 | int i, nid; | 546 | int i, nid; |
| 548 | 547 | ||
| 549 | /* Account for nodes with cpus and no memory */ | 548 | /* Account for nodes with cpus and no memory */ |
| @@ -571,15 +570,16 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) · 21 unmodified lines | |||
| 571 | * If sections array is gonna be used for pfn -> nid mapping, check | 570 | * If sections array is gonna be used for pfn -> nid mapping, check |
| 572 | * whether its granularity is fine enough. | 571 | * whether its granularity is fine enough. |
| 573 | */ | 572 | */ |
| 574 | #ifdef NODE_NOT_IN_PAGE_FLAGS | 573 | if (IS_ENABLED(NODE_NOT_IN_PAGE_FLAGS)) { |
| 575 | pfn_align = node_map_pfn_alignment(); | 574 | unsigned long pfn_align = node_map_pfn_alignment(); |
| 576 | if (pfn_align && pfn_align < PAGES_PER_SECTION) { | 575 | |
| 577 | printk(KERN_WARNING "Node alignment %LuMB < min %LuMB, rejecting NUMA config\n", | 576 | if (pfn_align && pfn_align < PAGES_PER_SECTION) { |
| 578 | PFN_PHYS(pfn_align) >> 20, | 577 | pr_warn("Node alignment %LuMB < min %LuMB, rejecting NUMA config\n", |
| 579 | PFN_PHYS(PAGES_PER_SECTION) >> 20); | 578 | PFN_PHYS(pfn_align) >> 20, |
| 580 | return -EINVAL; | 579 | PFN_PHYS(PAGES_PER_SECTION) >> 20); |
| 580 | return -EINVAL; | ||
| 581 | } | ||
| 581 | } | 582 | } |
| 582 | #endif | ||
| 583 | if (!numa_meminfo_cover_memory(mi)) | 583 | if (!numa_meminfo_cover_memory(mi)) |
| 584 | return -EINVAL; | 584 | return -EINVAL; |
| 585 | 585 | ||
| @@ -98,9 +98,11 @@ · 97 unmodified lines | |||
| 98 | /* | 98 | /* |
| 99 | * We are going to use the flags for the page to node mapping if its in | 99 | * We are going to use the flags for the page to node mapping if its in |
| 100 | * there. This includes the case where there is no node, so it is implicit. | 100 | * there. This includes the case where there is no node, so it is implicit. |
| 101 | * Note that this #define MUST have a value so that it can be tested with | ||
| 102 | * the IS_ENABLED() macro. | ||
| 101 | */ | 103 | */ |
| 102 | #if !(NODES_WIDTH > 0 || NODES_SHIFT == 0) | 104 | #if !(NODES_WIDTH > 0 || NODES_SHIFT == 0) |
| 103 | #define NODE_NOT_IN_PAGE_FLAGS | 105 | #define NODE_NOT_IN_PAGE_FLAGS 1 |
| 104 | #endif | 106 | #endif |
| 105 | 107 | ||
| 106 | #if defined(CONFIG_NUMA_BALANCING) && LAST_CPUPID_WIDTH == 0 | 108 | #if defined(CONFIG_NUMA_BALANCING) && LAST_CPUPID_WIDTH == 0 |