dovecot-2.2: pop3: Minor code cleanup

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 16 17:58:26 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/35194cf0693e
changeset: 15786:35194cf0693e
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 16 17:58:20 2013 +0200
description:
pop3: Minor code cleanup

diffstat:

 src/pop3/main.c        |   6 ++----
 src/pop3/pop3-client.c |  15 ++++++++-------
 src/pop3/pop3-client.h |   8 ++++----
 3 files changed, 14 insertions(+), 15 deletions(-)

diffs (80 lines):

diff -r 7e292b8352d9 -r 35194cf0693e src/pop3/main.c
--- a/src/pop3/main.c	Sat Feb 16 17:54:57 2013 +0200
+++ b/src/pop3/main.c	Sat Feb 16 17:58:20 2013 +0200
@@ -116,11 +116,9 @@
 	if (set->verbose_proctitle)
 		verbose_proctitle = TRUE;
 
-	client = client_create(fd_in, fd_out, input->session_id,
-			       mail_user, user, set);
-	if (client != NULL) T_BEGIN {
+	if (client_create(fd_in, fd_out, input->session_id,
+			  mail_user, user, set, &client) == 0)
 		client_add_input(client, input_buf);
-	} T_END;
 	return 0;
 }
 
diff -r 7e292b8352d9 -r 35194cf0693e src/pop3/pop3-client.c
--- a/src/pop3/pop3-client.c	Sat Feb 16 17:54:57 2013 +0200
+++ b/src/pop3/pop3-client.c	Sat Feb 16 17:58:20 2013 +0200
@@ -273,10 +273,10 @@
 	return mask;
 }
 
-struct client *client_create(int fd_in, int fd_out, const char *session_id,
-			     struct mail_user *user,
-			     struct mail_storage_service_user *service_user,
-			     const struct pop3_settings *set)
+int client_create(int fd_in, int fd_out, const char *session_id,
+		  struct mail_user *user,
+		  struct mail_storage_service_user *service_user,
+		  const struct pop3_settings *set, struct client **client_r)
 {
 	struct mail_storage *storage;
 	const char *ident;
@@ -333,14 +333,14 @@
 			mailbox_get_last_error(client->mailbox, NULL));
 		client_send_storage_error(client);
 		client_destroy(client, "Couldn't open INBOX");
-		return NULL;
+		return -1;
 	}
 	client->mail_set = mail_storage_get_settings(storage);
 
 	if (init_mailbox(client, &errmsg) < 0) {
 		i_error("Couldn't init INBOX: %s", errmsg);
 		client_destroy(client, "Mailbox init failed");
-		return NULL;
+		return -1;
 	}
 
 	client->uidl_keymask =
@@ -371,7 +371,8 @@
 		hook_client_created(&client);
 
 	pop3_refresh_proctitle();
-	return client;
+	*client_r = client;
+	return 0;
 }
 
 static const char *client_build_uidl_change_string(struct client *client)
diff -r 7e292b8352d9 -r 35194cf0693e src/pop3/pop3-client.h
--- a/src/pop3/pop3-client.h	Sat Feb 16 17:54:57 2013 +0200
+++ b/src/pop3/pop3-client.h	Sat Feb 16 17:58:20 2013 +0200
@@ -103,10 +103,10 @@
 
 /* Create new client with specified input/output handles. socket specifies
    if the handle is a socket. */
-struct client *client_create(int fd_in, int fd_out, const char *session_id,
-			     struct mail_user *user,
-			     struct mail_storage_service_user *service_user,
-			     const struct pop3_settings *set);
+int client_create(int fd_in, int fd_out, const char *session_id,
+		  struct mail_user *user,
+		  struct mail_storage_service_user *service_user,
+		  const struct pop3_settings *set, struct client **client_r);
 void client_destroy(struct client *client, const char *reason) ATTR_NULL(2);
 
 /* Disconnect client connection */


More information about the dovecot-cvs mailing list