[6.0] f52e298f1 FlexeLinting: Be more careful about signed/unsigned

Reza Naghibi reza at naghibi.com
Wed Aug 19 13:17:07 UTC 2020


commit f52e298f107283efbab3881eb6a38fe29b1933d7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Apr 29 07:20:10 2019 +0000

    FlexeLinting: Be more careful about signed/unsigned
    
     Conflicts:
            lib/libvmod_directors/shard_dir.h
            lib/libvmod_directors/vmod_shard.c

diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c
index c2e0a326b..a198f0c85 100644
--- a/lib/libvmod_directors/shard_cfg.c
+++ b/lib/libvmod_directors/shard_cfg.c
@@ -368,7 +368,7 @@ shardcfg_backend_lookup(const struct backend_reconfig *re,
 static void
 shardcfg_backend_expand(const struct backend_reconfig *re)
 {
-	unsigned min = re->hint;
+	int min = re->hint;
 
 	CHECK_OBJ_NOTNULL(re->shardd, SHARDDIR_MAGIC);
 
@@ -378,7 +378,7 @@ shardcfg_backend_expand(const struct backend_reconfig *re)
 	if (re->shardd->l_backend < min)
 		re->shardd->l_backend = min;
 	else
-		re->shardd->l_backend <<= 1;
+		re->shardd->l_backend *= 2;
 
 	re->shardd->backend = realloc(re->shardd->backend,
 	    re->shardd->l_backend * sizeof *re->shardd->backend);
diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c
index f18c2131c..fffcad572 100644
--- a/lib/libvmod_directors/shard_dir.c
+++ b/lib/libvmod_directors/shard_dir.c
@@ -311,7 +311,7 @@ sharddir_any_healthy(struct sharddir *shardd, const struct busyobj *bo,
 {
 	unsigned retval = 0;
 	VCL_BACKEND be;
-	unsigned u;
+	int i;
 	vtim_real c;
 
 	CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC);
@@ -319,8 +319,8 @@ sharddir_any_healthy(struct sharddir *shardd, const struct busyobj *bo,
 	sharddir_rdlock(shardd);
 	if (changed != NULL)
 		*changed = 0;
-	for (u = 0; u < shardd->n_backend; u++) {
-		be = shardd->backend[u].backend;
+	for (i = 0; i < shardd->n_backend; i++) {
+		be = shardd->backend[i].backend;
 		CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
 		retval = be->healthy(be, bo, &c);
 		if (changed != NULL && c > *changed)
diff --git a/lib/libvmod_directors/shard_dir.h b/lib/libvmod_directors/shard_dir.h
index 1daae58ca..384b32cb9 100644
--- a/lib/libvmod_directors/shard_dir.h
+++ b/lib/libvmod_directors/shard_dir.h
@@ -76,8 +76,8 @@ struct sharddir {
 
 	const char				*name;
 
-	unsigned				n_backend;
-	unsigned				l_backend;
+	int					n_backend;
+	int					l_backend;
 	struct shard_backend			*backend;
 
 	struct shard_circlepoint		*hashcircle;
diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c
index 4ea5e5ae7..815b28432 100644
--- a/lib/libvmod_directors/vmod_shard.c
+++ b/lib/libvmod_directors/vmod_shard.c
@@ -466,8 +466,8 @@ static uint32_t
 shard_blob_key(VCL_BLOB key_blob)
 {
 	uint8_t k[4] = { 0 };
-	uint8_t *b;
-	int i, ki;
+	const uint8_t *b;
+	size_t i, ki;
 
 	assert(key_blob);
 	assert(key_blob->len > 0);


More information about the varnish-commit mailing list