changeset 10869:bf978f2de0fd HEAD

doveadm: Minor code cleanup.
author Timo Sirainen <tss@iki.fi>
date Mon, 08 Mar 2010 21:08:00 +0200
parents 863eafcf8428
children 6d260794f278
files src/doveadm/doveadm-who.c
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/doveadm/doveadm-who.c	Mon Mar 08 20:28:08 2010 +0200
+++ b/src/doveadm/doveadm-who.c	Mon Mar 08 21:08:00 2010 +0200
@@ -93,11 +93,21 @@
 	(void)net_addr2ip(ip_str, &line_r->ip);
 }
 
+static bool who_user_has_pid(struct who_user *user, pid_t pid)
+{
+	const pid_t *ex_pid;
+
+	array_foreach(&user->pids, ex_pid) {
+		if (*ex_pid == pid)
+			return TRUE;
+	}
+	return FALSE;
+}
+
 static void who_aggregate_line(struct who_context *ctx,
 			       const struct who_line *line)
 {
 	struct who_user *user, lookup_user;
-	const pid_t *ex_pid;
 
 	lookup_user.username = line->username;
 	lookup_user.service = line->service;
@@ -116,11 +126,7 @@
 	if (line->ip.family != 0 && !who_user_has_ip(user, &line->ip))
 		array_append(&user->ips, &line->ip, 1);
 
-	array_foreach(&user->pids, ex_pid) {
-		if (*ex_pid == line->pid)
-			break;
-	}
-	if (*ex_pid != line->pid)
+	if (!who_user_has_pid(user, line->pid))
 		array_append(&user->pids, &line->pid, 1);
 }