dovecot-2.2: Added i_stream_get_data_size(). Used it where possi...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jun 25 02:15:56 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/9646f80ac3e9
changeset: 14683:9646f80ac3e9
user: Timo Sirainen <tss at iki.fi>
date: Mon Jun 25 02:15:22 2012 +0300
description:
Added i_stream_get_data_size(). Used it where possible.
diffstat:
src/director/director-connection.c | 5 +----
src/doveadm/dsync/dsync-slave-io.c | 6 ++----
src/imap/cmd-append.c | 8 ++------
src/imap/imap-client.c | 11 +++--------
src/lib-dict/dict-client.c | 4 +---
src/lib-mail/istream-dot.c | 4 ++--
src/lib-mail/istream-header-filter.c | 2 +-
src/lib-mail/istream-nonuls.c | 7 ++-----
src/lib-mail/message-parser.c | 8 ++------
src/lib-storage/index/istream-mail.c | 2 +-
src/lib-storage/index/mbox/istream-raw-mbox.c | 4 +---
src/lib-storage/index/pop3c/pop3c-client.c | 6 ++----
src/lib/istream-base64-encoder.c | 6 +++---
src/lib/istream-crlf.c | 4 ++--
src/lib/istream-seekable.c | 8 +++-----
src/lib/istream-tee.c | 6 ++----
src/lib/istream.c | 10 ++++++++++
src/lib/istream.h | 1 +
src/lib/test-istream-base64-encoder.c | 3 +--
src/lib/test-istream-concat.c | 2 +-
src/lib/test-istream-seekable.c | 4 ++--
src/plugins/fts/fts-expunge-log.c | 2 +-
src/plugins/zlib/istream-bzlib.c | 2 +-
src/plugins/zlib/istream-zlib.c | 2 +-
24 files changed, 48 insertions(+), 69 deletions(-)
diffs (truncated from 502 to 300 lines):
diff -r d0d7b810646b -r 9646f80ac3e9 src/director/director-connection.c
--- a/src/director/director-connection.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/director/director-connection.c Mon Jun 25 02:15:22 2012 +0300
@@ -1275,10 +1275,7 @@
/* just read everything the remote sends, and wait for it
to disconnect. we mainly just want the remote to read the
CONNECT we sent it. */
- size_t size;
-
- (void)i_stream_get_data(conn->input, &size);
- i_stream_skip(conn->input, size);
+ i_stream_skip(conn->input, i_stream_get_data_size(conn->input));
return;
}
diff -r d0d7b810646b -r 9646f80ac3e9 src/doveadm/dsync/dsync-slave-io.c
--- a/src/doveadm/dsync/dsync-slave-io.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/doveadm/dsync/dsync-slave-io.c Mon Jun 25 02:15:22 2012 +0300
@@ -144,8 +144,6 @@
static int dsync_slave_io_read_mail_stream(struct dsync_slave_io *slave)
{
- size_t size;
-
if (i_stream_read(slave->mail_input) < 0) {
if (slave->mail_input->stream_errno != 0) {
errno = slave->mail_input->stream_errno;
@@ -159,8 +157,8 @@
slave->mail_input = NULL;
return 1;
}
- (void)i_stream_get_data(slave->mail_input, &size);
- i_stream_skip(slave->mail_input, size);
+ i_stream_skip(slave->mail_input,
+ i_stream_get_data_size(slave->mail_input));
return 0;
}
diff -r d0d7b810646b -r 9646f80ac3e9 src/imap/cmd-append.c
--- a/src/imap/cmd-append.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/imap/cmd-append.c Mon Jun 25 02:15:22 2012 +0300
@@ -150,7 +150,6 @@
static bool cmd_append_continue_cancel(struct client_command_context *cmd)
{
struct cmd_append_context *ctx = cmd->context;
- size_t size;
if (cmd->cancel) {
cmd_append_finish(ctx);
@@ -158,8 +157,7 @@
}
(void)i_stream_read(ctx->input);
- (void)i_stream_get_data(ctx->input, &size);
- i_stream_skip(ctx->input, size);
+ i_stream_skip(ctx->input, i_stream_get_data_size(ctx->input));
if (cmd->client->input->closed) {
cmd_append_finish(ctx);
@@ -712,7 +710,6 @@
{
struct client *client = cmd->client;
struct cmd_append_context *ctx = cmd->context;
- size_t size;
int ret = 0;
if (cmd->cancel) {
@@ -736,8 +733,7 @@
if (ctx->save_ctx == NULL) {
(void)i_stream_read(ctx->input);
- (void)i_stream_get_data(ctx->input, &size);
- i_stream_skip(ctx->input, size);
+ i_stream_skip(ctx->input, i_stream_get_data_size(ctx->input));
}
if (ctx->litinput->eof || client->input->closed) {
diff -r d0d7b810646b -r 9646f80ac3e9 src/imap/imap-client.c
--- a/src/imap/imap-client.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/imap/imap-client.c Mon Jun 25 02:15:22 2012 +0300
@@ -600,8 +600,6 @@
void client_continue_pending_input(struct client *client)
{
- size_t size;
-
i_assert(!client->handling_input);
if (client->input_lock != NULL) {
@@ -626,8 +624,8 @@
client_add_missing_io(client);
/* if there's unread data in buffer, handle it. */
- (void)i_stream_get_data(client->input, &size);
- if (size > 0 && !client->disconnected) {
+ if (i_stream_get_data_size(client->input) > 0 &&
+ !client->disconnected) {
if (client_handle_input(client))
client_continue_pending_input(client);
}
@@ -750,8 +748,6 @@
static bool client_handle_next_command(struct client *client, bool *remove_io_r)
{
- size_t size;
-
*remove_io_r = FALSE;
if (client->input_lock != NULL) {
@@ -772,8 +768,7 @@
/* don't bother creating a new client command before there's at least
some input */
- (void)i_stream_get_data(client->input, &size);
- if (size == 0)
+ if (i_stream_get_data_size(client->input) == 0)
return FALSE;
/* beginning a new command */
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-dict/dict-client.c
--- a/src/lib-dict/dict-client.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-dict/dict-client.c Mon Jun 25 02:15:22 2012 +0300
@@ -669,15 +669,13 @@
static void dict_async_input(struct client_dict *dict)
{
char *line;
- size_t size;
int ret;
i_assert(!dict->in_iteration);
do {
ret = client_dict_read_one_line(dict, &line);
- (void)i_stream_get_data(dict->input, &size);
- } while (ret == 0 && size > 0);
+ } while (ret == 0 && i_stream_get_data_size(dict->input) > 0);
if (ret < 0)
io_remove(&dict->io);
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-mail/istream-dot.c
--- a/src/lib-mail/istream-dot.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-mail/istream-dot.c Mon Jun 25 02:15:22 2012 +0300
@@ -27,7 +27,7 @@
size_t size, avail;
ssize_t ret;
- (void)i_stream_get_data(stream->parent, &size);
+ size = i_stream_get_data_size(stream->parent);
if (size == 0) {
ret = i_stream_read(stream->parent);
if (ret <= 0 && (ret != -2 || stream->skip == 0)) {
@@ -40,7 +40,7 @@
}
return ret;
}
- (void)i_stream_get_data(stream->parent, &size);
+ size = i_stream_get_data_size(stream->parent);
i_assert(size != 0);
}
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-mail/istream-header-filter.c
--- a/src/lib-mail/istream-header-filter.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-mail/istream-header-filter.c Mon Jun 25 02:15:22 2012 +0300
@@ -407,7 +407,7 @@
while (!mstream->header_read &&
i_stream_read(&mstream->istream.istream) != -1) {
- (void)i_stream_get_data(&mstream->istream.istream, &pos);
+ pos = i_stream_get_data_size(&mstream->istream.istream);
i_stream_skip(&mstream->istream.istream, pos);
}
}
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-mail/istream-nonuls.c
--- a/src/lib-mail/istream-nonuls.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-mail/istream-nonuls.c Mon Jun 25 02:15:22 2012 +0300
@@ -11,11 +11,9 @@
static int i_stream_read_parent(struct istream_private *stream)
{
- size_t size;
ssize_t ret;
- (void)i_stream_get_data(stream->parent, &size);
- if (size > 0)
+ if (i_stream_get_data_size(stream->parent) > 0)
return 1;
ret = i_stream_read(stream->parent);
@@ -24,8 +22,7 @@
stream->istream.eof = stream->parent->eof;
return ret;
}
- (void)i_stream_get_data(stream->parent, &size);
- i_assert(size != 0);
+ i_assert(i_stream_get_data_size(stream->parent) != 0);
return 1;
}
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-mail/message-parser.c
--- a/src/lib-mail/message-parser.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-mail/message-parser.c Mon Jun 25 02:15:22 2012 +0300
@@ -505,7 +505,6 @@
{
struct message_part *part = ctx->part;
struct message_header_line *hdr;
- size_t size;
int ret;
if (ctx->skip > 0) {
@@ -515,8 +514,7 @@
ret = message_parse_header_next(ctx->hdr_parser_ctx, &hdr);
if (ret == 0 || (ret < 0 && ctx->input->stream_errno != 0)) {
- (void)i_stream_get_data(ctx->input, &size);
- ctx->want_count = size + 1;
+ ctx->want_count = i_stream_get_data_size(ctx->input) + 1;
return ret;
}
@@ -890,13 +888,11 @@
struct message_block *block_r)
{
struct message_header_line *hdr;
- size_t size;
int ret;
ret = message_parse_header_next(ctx->hdr_parser_ctx, &hdr);
if (ret == 0 || (ret < 0 && ctx->input->stream_errno != 0)) {
- (void)i_stream_get_data(ctx->input, &size);
- ctx->want_count = size + 1;
+ ctx->want_count = i_stream_get_data_size(ctx->input) + 1;
return ret;
}
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-storage/index/istream-mail.c
--- a/src/lib-storage/index/istream-mail.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-storage/index/istream-mail.c Mon Jun 25 02:15:22 2012 +0300
@@ -65,7 +65,7 @@
stream->istream.v_offset);
ret = i_stream_read_copy_from_parent(&stream->istream);
- (void)i_stream_get_data(&stream->istream, &size);
+ size = i_stream_get_data_size(&stream->istream);
if (ret > 0) {
mstream->mail->transaction->stats.files_read_bytes += ret;
if (!mstream->files_read_increased) {
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-storage/index/mbox/istream-raw-mbox.c
--- a/src/lib-storage/index/mbox/istream-raw-mbox.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-storage/index/mbox/istream-raw-mbox.c Mon Jun 25 02:15:22 2012 +0300
@@ -527,7 +527,6 @@
struct raw_mbox_istream *rstream =
(struct raw_mbox_istream *)stream->real_stream;
uoff_t offset;
- size_t pos;
i_assert(rstream->seeked);
@@ -537,8 +536,7 @@
offset = stream->v_offset;
i_stream_seek(stream, rstream->hdr_offset);
while (rstream->body_offset == (uoff_t)-1) {
- (void)i_stream_get_data(stream, &pos);
- i_stream_skip(stream, pos);
+ i_stream_skip(stream, i_stream_get_data_size(stream));
if (i_stream_raw_mbox_read(&rstream->istream) < 0) {
if (rstream->corrupted) {
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib-storage/index/pop3c/pop3c-client.c
--- a/src/lib-storage/index/pop3c/pop3c-client.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib-storage/index/pop3c/pop3c-client.c Mon Jun 25 02:15:22 2012 +0300
@@ -727,15 +727,13 @@
static void pop3c_client_dot_input(struct pop3c_client *client)
{
ssize_t ret;
- size_t size;
if (client->to != NULL)
timeout_reset(client->to);
while ((ret = i_stream_read(client->dot_input)) > 0 || ret == -2) {
- (void)i_stream_get_data(client->dot_input, &size);
- i_stream_skip(client->dot_input, size);
+ i_stream_skip(client->dot_input,
+ i_stream_get_data_size(client->dot_input));
}
- (void)i_stream_get_data(client->dot_input, &size);
if (ret != 0) {
i_assert(ret == -1);
if (client->dot_input->stream_errno != 0) {
diff -r d0d7b810646b -r 9646f80ac3e9 src/lib/istream-base64-encoder.c
--- a/src/lib/istream-base64-encoder.c Mon Jun 25 01:14:03 2012 +0300
+++ b/src/lib/istream-base64-encoder.c Mon Jun 25 02:15:22 2012 +0300
@@ -21,7 +21,7 @@
size_t size;
ssize_t ret;
- (void)i_stream_get_data(stream->parent, &size);
+ size = i_stream_get_data_size(stream->parent);
if (size >= 4)
return 1;
More information about the dovecot-cvs
mailing list