Skip to contentSkip to conversation

x86: cleanup - eliminate numbers in LDT allocation code

PATCH Applied Cyrill Gorcunov 2 participants 3 messages Feb 1, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: cleanup - eliminate numbers in LDT allocation code

This patch eliminates numbers in LDT allocation code trying to make it clear to understand from where these numbers are go

---

I hope nobody shoot me ;)

arch/x86/kernel/ldt.c +2 -1
Index: linux-2.6.git/arch/x86/kernel/ldt.c
===================================================================
@@ -35,7 +35,8 @@ static int alloc_ldt(mm_context_t *pc, i
 	if (mincount <= pc->size)
 		return 0;
 	oldsize = pc->size;
-	mincount = (mincount + 511) & (~511);
+	mincount = (mincount + (PAGE_SIZE / LDT_ENTRY_SIZE - 1)) &
+			(~(PAGE_SIZE / LDT_ENTRY_SIZE - 1));
 	if (mincount * LDT_ENTRY_SIZE > PAGE_SIZE)
 		newldt = vmalloc(mincount * LDT_ENTRY_SIZE);
 	else
Applied
#1 lore raw
Quoted 2 lines · Cyrill Gorcunov

This patch eliminates numbers in LDT allocation code trying to make it clear to understand from where these numbers are go

thanks, applied.

Quoted 1 line

I hope nobody shoot me ;)

nope, magic constants are bad in general.

Ingo

#2 lore raw

[Ingo Molnar - Fri, Feb 01, 2008 at 06:18:26PM +0100]

| 
| * Cyrill Gorcunov <[email protected]> wrote:
| 
| > This patch eliminates numbers in LDT allocation code trying to make it 
| > clear to understand from where these numbers are go
| 
| thanks, applied.
| 
| > I hope nobody shoot me ;)
| 
| nope, magic constants are bad in general.
| 
| 	Ingo
|

Thanks Ingo, and really thanks to Andi for his
explanation on this case.

- Cyrill -