Skip to contentSkip to conversation

x86/ldt: make a size variable unsigned

PATCH New Dan Carpenter 1 participant 1 message Dec 10, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/ldt: make a size variable unsigned

My static checker complains that we put an upper bound on the "size" variable but not a lower bound. The checker is not smart enough to know the possible ranges of "old_mm->context.ldt->size" from init_new_context_ldt() so it thinks maybe it could be negative.

Let's make it unsigned to silence the warning and future proof the code a bit. Also make alloc_size unsigned as well to match.

---
v2: change alloc_size

arch/x86/kernel/ldt.c +2 -2
index 4d12cdf2b453..62ccc27428e4 100644
@@ -34,10 +34,10 @@ static void flush_ldt(void *current_mm)
 }
 
 /* The caller must call finalize_ldt_struct on the result. LDT starts zeroed. */
-static struct ldt_struct *alloc_ldt_struct(int size)
+static struct ldt_struct *alloc_ldt_struct(unsigned int size)
 {
 	struct ldt_struct *new_ldt;
-	int alloc_size;
+	unsigned int alloc_size;
 
 	if (size > LDT_ENTRIES)
 		return NULL;