]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: shctx: Change max. object size type to unsigned int.
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 25 Oct 2018 18:31:40 +0000 (20:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 26 Oct 2018 02:54:40 +0000 (04:54 +0200)
This change is there to prevent implicit conversions when comparing
shctx maximum object sizes with other unsigned values.

include/proto/shctx.h
include/types/shctx.h
src/shctx.c

index 594a81d52a6ea996fbadcc869ff2d3b4bb5b9f80..9fc6fad8181e5c2616a60d4c3fe26730e19084b8 100644 (file)
@@ -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);
index 53dca3f1349d3fc567ec791b021f5d063e00cfb2..7d9d8c8a16d862cb5c058d22d3183b2301dd7b81 100644 (file)
@@ -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];
index 604fd7df0f32b1883223f361c12ea73ac5b2075c..9fe12e8151a73a679181c426441d116dcb1f1967 100644 (file)
@@ -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;