The role of the double cast
In this code:
	
	
	
		Code:
	
	
		uint64_t ldt_devs[LDT_ENTRIES] = {0};
uint32_t base;
base = (uint32_t)(uint32_t)ldt_devs;
	 
 
 Why the double cast?
	
	
	
		Code:
	
	
		(uint32_t)(uint32_t)ldt_devs
	 
 
looks redundant — and it is. 
Here are the typical reasons why someone might write that:
1. 
Historical/compiler behavior 
   Some older compilers complained when casting a pointer directly to an integer, so developers used an intermediate cast (e.g., through `uintptr_t` or `unsigned long`) to silence warnings.
2. 
Leftover or typo 
   Often it’s just a leftover from code refactoring, e.g. someone wrote:
   
	
	
	
		Code:
	
	
		   base = (uint32_t)(uintptr_t)ldt_devs;
	 
    and later replaced `uintptr_t` with `uint32_t` twice by accident.
3. 
Intentional but meaningless 
   Double-casting to the same type doesn’t change the result. It’s functionally identical to a single cast:
   
	
	
	
		Code:
	
	
		   base = (uint32_t)ldt_devs;