Mercurial > dovecot > core-2.2
changeset 11271:c7c6dbf542b3 HEAD
lib-sql: Code cleanup to make clang's static analyzer happy.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 09 May 2010 22:04:46 +0300 |
parents | b90d0670dfd4 |
children | 79a3aef47ddf |
files | src/lib-sql/driver-sqlpool.c |
diffstat | 1 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-sql/driver-sqlpool.c Sun May 09 22:00:39 2010 +0300 +++ b/src/lib-sql/driver-sqlpool.c Sun May 09 22:04:46 2010 +0300 @@ -214,17 +214,18 @@ struct sqlpool_host *hosts, *min = NULL; unsigned int i, count; - *host_idx_r = -1U; + hosts = array_get_modifiable(&db->hosts, &count); + i_assert(count > 0); - hosts = array_get_modifiable(&db->hosts, &count); - for (i = 0; i < count; i++) { - if (min == NULL || - min->connection_count > hosts[i].connection_count) { + 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; }