[PATCH 02/11] mm/zsmalloc: Make all obj_idx unsigned ints

Joshua Hahn
2026-03-11T19:52:02Z

object indices, which describe the location of an object in a zspage,
cannot be negative. To reflect this most helpers calculate and return
these values as unsigned ints.

Convert find_alloced_obj, the only function that calculates obj_idx as
a signed int, to use an unsigned int as well.

No functional change intended.

Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
---
mm/zsmalloc.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 7a9b8f55d529..7758486e1d06 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1491,10 +1491,11 @@ static void zs_obj_copy(struct size_class *class, unsigned long dst,
* return handle.
*/
static unsigned long find_alloced_obj(struct size_class *class,
- struct zpdesc *zpdesc, int *obj_idx)
+ struct zpdesc *zpdesc,
+ unsigned int *obj_idx)
{
unsigned int offset;
- int index = *obj_idx;
+ unsigned int index = *obj_idx;
unsigned long handle = 0;
void *addr = kmap_local_zpdesc(zpdesc);

@@ -1521,7 +1522,7 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage,
{
unsigned long used_obj, free_obj;
unsigned long handle;
- int obj_idx = 0;
+ unsigned int obj_idx = 0;
struct zpdesc *s_zpdesc = get_first_zpdesc(src_zspage);
struct size_class *class = pool->size_class[src_zspage->class];

--
2.52.0