Skip to contentSkip to conversation

arch/ia64: no need to initialise statics to 0

PATCH In review Jason Wang 2 participants 2 messages May 8, 2022

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 arch/ia64: no need to initialise statics to 0

Static variables do not need to be initialised to 0, because compiler will initialise all uninitialised statics to 0. Thus, remove the unneeded initializations.

---
 arch/ia64/mm/tlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/ia64/mm/tlb.c +2 -2
index 7a2d608fba74..854e90c4e7eb 100644
@@ -84,7 +84,7 @@ wrap_mmu_context (struct mm_struct *mm)
 		flush_bit = xchg(&ia64_ctx.flushmap[i], 0);
 		ia64_ctx.bitmap[i] ^= flush_bit;
 	}
- 
+
 	/* use offset at 300 to skip daemons */
 	ia64_ctx.next = find_next_zero_bit(ia64_ctx.bitmap,
 				ia64_ctx.max_ctx, 300);
@@ -144,7 +144,7 @@ static inline void up_spin(struct spinaphore *ss)
 static struct spinaphore ptcg_sem;
 static u16 nptcg = 1;
 static int need_ptcg_sem = 1;
-static int toolatetochangeptcgsem = 0;
+static int toolatetochangeptcgsem;
 
 /*
  * Kernel parameter "nptcg=" overrides max number of concurrent global TLB
Signature · 1 line
2.35.1
#1 lore raw

+ Fenghua Yu <[email protected]>

Quoted 5 lines · Jason Wang

Static variables do not need to be initialised to 0, because compiler will initialise all uninitialised statics to 0. Thus, remove the unneeded initializations.

Not sure why checkpatch picked me to be a reviewer for this. Nevertheless...

Quoted 9 lines
---
 arch/ia64/mm/tlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/ia64/mm/tlb.c +0 -0
index 7a2d608fba74..854e90c4e7eb 100644

arch/ia64/mm/tlb.c wrap_mmu_context (struct mm_struct *mm) · line 87

Quoted 5 lines
arch/ia64/mm/tlb.c +1 -1
@@ -84,7 +84,7 @@ wrap_mmu_context (struct mm_struct *mm)
 		flush_bit = xchg(&ia64_ctx.flushmap[i], 0);
 		ia64_ctx.bitmap[i] ^= flush_bit;
 	}
- 
+

This one is unrelated to the patch description. Can you split the patch, or add a couple words about this cleanup?

arch/ia64/mm/tlb.c static inline void up_spin(struct spinaphore *ss) · line 147

Quoted 9 lines
arch/ia64/mm/tlb.c +1 -1
 	/* use offset at 300 to skip daemons */
 	ia64_ctx.next = find_next_zero_bit(ia64_ctx.bitmap,
 				ia64_ctx.max_ctx, 300);
@@ -144,7 +144,7 @@ static inline void up_spin(struct spinaphore *ss)
 static struct spinaphore ptcg_sem;
 static u16 nptcg = 1;
 static int need_ptcg_sem = 1;
-static int toolatetochangeptcgsem = 0;
+static int toolatetochangeptcgsem;

There are at least 460 global static variables initialized explicitly.

yury:linux$ git grep "^static" | grep "= 0;" | wc -l 460

Are you going to fix them all? If not why this one is so special?

Before applying this, let's ask Fenghua - maybe it was his intention to underline that the variable is initialized as 0.

Thanks,
Yury

Quoted 4 lines
arch/ia64/mm/tlb.c +0 -0
 /*
  * Kernel parameter "nptcg=" overrides max number of concurrent global TLB
Signature · 1 line
2.35.1