]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-sql: Code cleanup to make clang's static analyzer happy.
authorTimo Sirainen <tss@iki.fi>
Sun, 9 May 2010 19:04:46 +0000 (22:04 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 9 May 2010 19:04:46 +0000 (22:04 +0300)
--HG--
branch : HEAD

src/lib-sql/driver-sqlpool.c

index 14285de37515b8872e0155b981a0892aa3b6ab26..32e85613239f7444ca6ec5a7cde4ca3cc1ecde6a 100644 (file)
@@ -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;
 }