dovecot-2.0: lib-sql: Code cleanup to make clang's static analyz...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 9 22:04:49 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/c7c6dbf542b3
changeset: 11271:c7c6dbf542b3
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 09 22:04:46 2010 +0300
description:
lib-sql: Code cleanup to make clang's static analyzer happy.

diffstat:

 src/lib-sql/driver-sqlpool.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (28 lines):

diff -r b90d0670dfd4 -r c7c6dbf542b3 src/lib-sql/driver-sqlpool.c
--- 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;
 }
 


More information about the dovecot-cvs mailing list