Skip to content

Commit 3f649ab

Browse files
committed
treewide: Remove uninitialized_var() usage
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. In preparation for removing[2] the[3] macro[4], remove all remaining needless uses with the following script: git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \ xargs perl -pi -e \ 's/\buninitialized_var\(([^\)]+)\)/\1/g; s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;' drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid pathological white-space. No outstanding warnings were found building allmodconfig with GCC 9.3.0 for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64, alpha, and m68k. [1] https://lore.kernel.org/lkml/[email protected]/ [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/ Reviewed-by: Leon Romanovsky <[email protected]> # drivers/infiniband and mlx4/mlx5 Acked-by: Jason Gunthorpe <[email protected]> # IB Acked-by: Kalle Valo <[email protected]> # wireless drivers Reviewed-by: Chao Yu <[email protected]> # erofs Signed-off-by: Kees Cook <[email protected]>
1 parent d8b44b5 commit 3f649ab

File tree

179 files changed

+278
-279
lines changed

Some content is hidden

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

179 files changed

+278
-279
lines changed

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

arch/powerpc/kvm/powerpc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ static inline u32 dp_to_sp(u64 fprd)
11101110
static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu)
11111111
{
11121112
struct kvm_run *run = vcpu->run;
1113-
u64 uninitialized_var(gpr);
1113+
u64 gpr;
11141114

11151115
if (run->mmio.len > sizeof(gpr)) {
11161116
printk(KERN_ERR "bad MMIO length: %d\n", run->mmio.len);

0 commit comments

Comments
 (0)