From b80bc273a3598f47f7429fa657d5f53874e309d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Thu, 25 Oct 2018 20:31:40 +0200 Subject: [PATCH] MINOR: shctx: Change max. object size type to unsigned int. This change is there to prevent implicit conversions when comparing shctx maximum object sizes with other unsigned values. --- include/proto/shctx.h | 3 ++- include/types/shctx.h | 2 +- src/shctx.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/proto/shctx.h b/include/proto/shctx.h index 594a81d52..9fc6fad81 100644 --- a/include/proto/shctx.h +++ b/include/proto/shctx.h @@ -32,7 +32,8 @@ #endif int shctx_init(struct shared_context **orig_shctx, - int maxblocks, int blocksize, int maxobjsz, int extra, int shared); + int maxblocks, int blocksize, unsigned int maxobjsz, + int extra, int shared); struct shared_block *shctx_row_reserve_hot(struct shared_context *shctx, struct shared_block *last, int data_len); void shctx_row_inc_hot(struct shared_context *shctx, struct shared_block *first); diff --git a/include/types/shctx.h b/include/types/shctx.h index 53dca3f13..7d9d8c8a1 100644 --- a/include/types/shctx.h +++ b/include/types/shctx.h @@ -40,7 +40,7 @@ struct shared_context { struct list avail; /* list for active and free blocks */ struct list hot; /* list for locked blocks */ unsigned int nbav; /* number of available blocks */ - int max_obj_size; /* maximum object size. */ + unsigned int max_obj_size; /* maximum object size (in bytes). */ void (*free_block)(struct shared_block *first, struct shared_block *block); short int block_size; unsigned char data[0]; diff --git a/src/shctx.c b/src/shctx.c index 604fd7df0..9fe12e815 100644 --- a/src/shctx.c +++ b/src/shctx.c @@ -292,7 +292,7 @@ int shctx_row_data_get(struct shared_context *shctx, struct shared_block *first, * and 0 if cache is already allocated. */ int shctx_init(struct shared_context **orig_shctx, int maxblocks, int blocksize, - int maxobjsz, int extra, int shared) + unsigned int maxobjsz, int extra, int shared) { int i; struct shared_context *shctx; @@ -359,7 +359,7 @@ int shctx_init(struct shared_context **orig_shctx, int maxblocks, int blocksize, LIST_INIT(&shctx->hot); shctx->block_size = blocksize; - shctx->max_obj_size = maxobjsz; + shctx->max_obj_size = maxobjsz == (unsigned int)-1 ? 0 : maxobjsz; /* init the free blocks after the shared context struct */ cur = (void *)shctx + sizeof(struct shared_context) + extra;