From 902acc26200957a1f04da3cc947211f0b9ffce05 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 9 May 2010 22:04:46 +0300 Subject: [PATCH] lib-sql: Code cleanup to make clang's static analyzer happy. --HG-- branch : HEAD --- src/lib-sql/driver-sqlpool.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib-sql/driver-sqlpool.c b/src/lib-sql/driver-sqlpool.c index 14285de375..32e8561323 100644 --- a/src/lib-sql/driver-sqlpool.c +++ b/src/lib-sql/driver-sqlpool.c @@ -214,17 +214,18 @@ sqlpool_find_host_with_least_connections(struct sqlpool_db *db, struct sqlpool_host *hosts, *min = NULL; unsigned int i, count; - *host_idx_r = -1U; - hosts = array_get_modifiable(&db->hosts, &count); - for (i = 0; i < count; i++) { - if (min == NULL || - min->connection_count > hosts[i].connection_count) { + i_assert(count > 0); + + min = &hosts[0]; + *host_idx_r = 0; + + for (i = 1; i < count; i++) { + if (min->connection_count > hosts[i].connection_count) { min = &hosts[i]; *host_idx_r = i; } } - i_assert(min != NULL); return min; } -- 2.47.3