From: Timo Sirainen Date: Sun, 9 May 2010 19:04:46 +0000 (+0300) Subject: lib-sql: Code cleanup to make clang's static analyzer happy. X-Git-Tag: 2.0.beta5~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=902acc26200957a1f04da3cc947211f0b9ffce05;p=thirdparty%2Fdovecot%2Fcore.git lib-sql: Code cleanup to make clang's static analyzer happy. --HG-- branch : HEAD --- 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; }