Skip to content

Commit 99ea152

Browse files
committed
Merge tag 'uninit-macro-v5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull uninitialized_var() macro removal from Kees Cook: "This is long overdue, and has hidden too many bugs over the years. The series has several "by hand" fixes, and then a trivial treewide replacement. - Clean up non-trivial uses of uninitialized_var() - Update documentation and checkpatch for uninitialized_var() removal - Treewide removal of uninitialized_var()" * tag 'uninit-macro-v5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: compiler: Remove uninitialized_var() macro treewide: Remove uninitialized_var() usage checkpatch: Remove awareness of uninitialized_var() macro mm/debug_vm_pgtable: Remove uninitialized_var() usage f2fs: Eliminate usage of uninitialized_var() macro media: sur40: Remove uninitialized_var() usage KVM: PPC: Book3S PR: Remove uninitialized_var() usage clk: spear: Remove uninitialized_var() usage clk: st: Remove uninitialized_var() usage spi: davinci: Remove uninitialized_var() usage ide: Remove uninitialized_var() usage rtlwifi: rtl8192cu: Remove uninitialized_var() usage b43: Remove uninitialized_var() usage drbd: Remove uninitialized_var() usage x86/mm/numa: Remove uninitialized_var() usage docs: deprecated.rst: Add uninitialized_var()
2 parents 427714f + 63a0895 commit 99ea152

File tree

195 files changed

+320
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+320
-329
lines changed

Documentation/process/deprecated.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ to make sure their systems do not continue running in the face of
5151
"unreachable" conditions. (For example, see commits like `this one
5252
<https://git.kernel.org/linus/d4689846881d160a4d12a514e991a740bcb5d65a>`_.)
5353

54+
uninitialized_var()
55+
-------------------
56+
For any compiler warnings about uninitialized variables, just add
57+
an initializer. Using the uninitialized_var() macro (or similar
58+
warning-silencing tricks) is dangerous as it papers over `real bugs
59+
<https://lore.kernel.org/lkml/[email protected]/>`_
60+
(or can in the future), and suppresses unrelated compiler warnings
61+
(e.g. "unused variable"). If the compiler thinks it is uninitialized,
62+
either simply initialize the variable or make compiler changes. Keep in
63+
mind that in most cases, if an initialization is obviously redundant,
64+
the compiler's dead-store elimination pass will make sure there are no
65+
needless variable writes.
66+
67+
As Linus has said, this macro
68+
`must <https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/>`_
69+
`be <https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/>`_
70+
`removed <https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/>`_.
71+
5472
open-coded arithmetic in allocator arguments
5573
--------------------------------------------
5674
Dynamic size calculations (especially multiplication) should not be

arch/arm/mach-sa1100/assabet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ static void __init map_sa1100_gpio_regs( void )
652652
*/
653653
static void __init get_assabet_scr(void)
654654
{
655-
unsigned long uninitialized_var(scr), i;
655+
unsigned long scr, i;
656656

657657
GPDR |= 0x3fc; /* Configure GPIO 9:2 as outputs */
658658
GPSR = 0x3fc; /* Write 0xFF to GPIO 9:2 */

arch/arm/mm/alignment.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ static int alignment_get_thumb(struct pt_regs *regs, u16 *ip, u16 *inst)
799799
static int
800800
do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
801801
{
802-
union offset_union uninitialized_var(offset);
802+
union offset_union offset;
803803
unsigned long instrptr;
804804
int (*handler)(unsigned long addr, u32 instr, struct pt_regs *regs);
805805
unsigned int type;

arch/ia64/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static void
445445
do_copy_task_regs (struct task_struct *task, struct unw_frame_info *info, void *arg)
446446
{
447447
unsigned long mask, sp, nat_bits = 0, ar_rnat, urbs_end, cfm;
448-
unsigned long uninitialized_var(ip); /* GCC be quiet */
448+
unsigned long ip;
449449
elf_greg_t *dst = arg;
450450
struct pt_regs *pt;
451451
char nat;

arch/ia64/mm/discontig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void *per_cpu_node_setup(void *cpu_data, int node)
180180
void __init setup_per_cpu_areas(void)
181181
{
182182
struct pcpu_alloc_info *ai;
183-
struct pcpu_group_info *uninitialized_var(gi);
183+
struct pcpu_group_info *gi;
184184
unsigned int *cpu_map;
185185
void *base;
186186
unsigned long base_offset;

arch/ia64/mm/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ EXPORT_SYMBOL(flush_tlb_range);
369369

370370
void ia64_tlb_init(void)
371371
{
372-
ia64_ptce_info_t uninitialized_var(ptce_info); /* GCC be quiet */
372+
ia64_ptce_info_t ptce_info;
373373
u64 tr_pgbits;
374374
long status;
375375
pal_vm_info_1_u_t vm_info_1;

arch/mips/lib/dump_tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void dump_tlb(int first, int last)
7979
unsigned int pagemask, guestctl1 = 0, c0, c1, i;
8080
unsigned long asidmask = cpu_asid_mask(&current_cpu_data);
8181
int asidwidth = DIV_ROUND_UP(ilog2(asidmask) + 1, 4);
82-
unsigned long uninitialized_var(s_mmid);
82+
unsigned long s_mmid;
8383
#ifdef CONFIG_32BIT
8484
bool xpa = cpu_has_xpa && (read_c0_pagegrain() & PG_ELPA);
8585
int pwidth = xpa ? 11 : 8;

arch/mips/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void setup_zero_pages(void)
8383
static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot)
8484
{
8585
enum fixed_addresses idx;
86-
unsigned int uninitialized_var(old_mmid);
86+
unsigned int old_mmid;
8787
unsigned long vaddr, flags, entrylo;
8888
unsigned long old_ctx;
8989
pte_t pte;

arch/mips/mm/tlb-r4k.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
119119
if (size <= (current_cpu_data.tlbsizeftlbsets ?
120120
current_cpu_data.tlbsize / 8 :
121121
current_cpu_data.tlbsize / 2)) {
122-
unsigned long old_entryhi, uninitialized_var(old_mmid);
122+
unsigned long old_entryhi, old_mmid;
123123
int newpid = cpu_asid(cpu, mm);
124124

125125
old_entryhi = read_c0_entryhi();
@@ -213,7 +213,7 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
213213
int cpu = smp_processor_id();
214214

215215
if (cpu_context(cpu, vma->vm_mm) != 0) {
216-
unsigned long uninitialized_var(old_mmid);
216+
unsigned long old_mmid;
217217
unsigned long flags, old_entryhi;
218218
int idx;
219219

@@ -382,7 +382,7 @@ void add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
382382
#ifdef CONFIG_XPA
383383
panic("Broken for XPA kernels");
384384
#else
385-
unsigned int uninitialized_var(old_mmid);
385+
unsigned int old_mmid;
386386
unsigned long flags;
387387
unsigned long wired;
388388
unsigned long old_pagemask;

arch/powerpc/kvm/book3s_64_mmu_radix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
3333
gva_t eaddr, void *to, void *from,
3434
unsigned long n)
3535
{
36-
int uninitialized_var(old_pid), old_lpid;
36+
int old_pid, old_lpid;
3737
unsigned long quadrant, ret = n;
3838
bool is_load = !!to;
3939

0 commit comments

Comments
 (0)