bool master = conn->listen_fd == MASTER_LISTEN_FD_FIRST;
master_service_client_connection_accept(conn);
- anvil_connection_create(conn->fd, master, conn->fifo);
+ (void)anvil_connection_create(conn->fd, master, conn->fifo);
}
static void ATTR_NULL(1)
if (strcmp(key, "service") == 0)
request->service = p_strdup(request->pool, value);
else if (strcmp(key, "lip") == 0)
- net_addr2ip(value, &request->local_ip);
+ (void)net_addr2ip(value, &request->local_ip);
else if (strcmp(key, "rip") == 0)
- net_addr2ip(value, &request->remote_ip);
+ (void)net_addr2ip(value, &request->remote_ip);
else if (strcmp(key, "lport") == 0)
request->local_port = atoi(value);
else if (strcmp(key, "rport") == 0)
{
unsigned int i;
- str_lcase(key);
+ (void)str_lcase(key);
if (strcmp(key, "realm") == 0) {
if (request->auth_request.realm == NULL && *value != '\0')
return FALSE;
}
- str_array_remove(fields, fields[field_count-1]);
+ (void)str_array_remove(fields, fields[field_count-1]);
request->client_final_message_without_proof =
p_strdup(request->pool, t_strarray_join(fields, ","));
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply, verify_plain_callback, request);
+ (void)auth_worker_call(request->pool, reply,
+ verify_plain_callback, request);
}
static bool lookup_credentials_callback(const char *reply, void *context)
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply,
- lookup_credentials_callback, request);
+ (void)auth_worker_call(request->pool, reply,
+ lookup_credentials_callback, request);
}
static bool
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply,
- set_credentials_callback, request);
+ (void)auth_worker_call(request->pool, reply,
+ set_credentials_callback, request);
}
} else {
/* Generate new OTP credentials from plaintext */
unsigned char random_data[OTP_MAX_SEED_LEN / 2];
+ const char *random_hex;
random_fill(random_data, sizeof(random_data));
- i_strocpy(state.seed, binary_to_hex(random_data,
- OTP_MAX_SEED_LEN / 2), sizeof(state.seed));
+ random_hex = binary_to_hex(random_data, sizeof(random_data));
+ if (i_strocpy(state.seed, random_hex, sizeof(state.seed)) < 0)
+ i_unreached();
state.seq = 1024;
state.algo = algo;
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply, user_callback, request);
+ (void)auth_worker_call(request->pool, reply, user_callback, request);
}
static bool iter_callback(const char *reply, void *context)
sql_result_ref(sql_result);
if (ctx->freed)
- userdb_sql_iterate_deinit(&ctx->ctx);
+ (void)userdb_sql_iterate_deinit(&ctx->ctx);
else if (ctx->call_iter)
userdb_sql_iterate_next(&ctx->ctx);
}
config_dump_human_deinit(ctx);
if (dump_section)
- config_dump_human(filter, "", scope, setting_name_filter);
+ (void)config_dump_human(filter, "", scope, setting_name_filter);
return 0;
}
static void client_connected(struct master_service_connection *conn)
{
master_service_client_connection_accept(conn);
- config_connection_create(conn->fd);
+ (void)config_connection_create(conn->fd);
}
int main(int argc, char *argv[])
#include "config-parser-private.h"
#include "old-set-parser.h"
+#define config_apply_line (void)config_apply_line
+
struct socket_set {
const char *path, *mode, *user, *group;
bool master;
conn->iter_ctx = dict_iterate_init_multiple(conn->dict, args+1, flags);
o_stream_set_flush_callback(conn->output, cmd_iterate_flush, conn);
- cmd_iterate_flush(conn);
+ (void)cmd_iterate_flush(conn);
return 0;
}
static void client_connected(struct master_service_connection *conn)
{
master_service_client_connection_accept(conn);
- dict_connection_create(conn->fd);
+ (void)dict_connection_create(conn->fd);
}
static void main_preinit(void)
return FALSE;
}
- director_user_refresh(conn, username_hash, host, timestamp, weak, &user);
+ (void)director_user_refresh(conn, username_hash, host,
+ timestamp, weak, &user);
return TRUE;
}
}
if (host == NULL || !host->self)
- director_resend_sync(dir);
+ (void)director_resend_sync(dir);
return TRUE;
}
i_fatal("Unknown director host: %s", host);
for (i = 0; i < ips_count; i++)
- director_host_add(dir, &ips[i], port);
+ (void)director_host_add(dir, &ips[i], port);
}
void director_host_add_from_string(struct director *dir, const char *hosts)
/* standalone director */
struct ip_addr ip;
- net_addr2ip("127.0.0.1", &ip);
+ if (net_addr2ip("127.0.0.1", &ip) < 0)
+ i_unreached();
dir->self_host = director_host_add(dir, &ip, 0);
dir->self_host->self = TRUE;
}
while we're still trying to connect to it */
host->last_network_failure = 0;
- director_connection_init_out(dir, fd, host);
+ (void)director_connection_init_out(dir, fd, host);
return 0;
}
else if (strcmp(cmd, "DIRECTOR-LIST") == 0)
doveadm_cmd_director_list(conn);
else if (strcmp(cmd, "DIRECTOR-ADD") == 0)
- doveadm_cmd_director_add(conn, args);
+ ret = doveadm_cmd_director_add(conn, args);
else if (strcmp(cmd, "DIRECTOR-REMOVE") == 0)
- doveadm_cmd_director_remove(conn, args);
+ ret = doveadm_cmd_director_remove(conn, args);
else if (strcmp(cmd, "HOST-SET") == 0)
ret = doveadm_cmd_host_set(conn, args);
else if (strcmp(cmd, "HOST-REMOVE") == 0)
}
for (i = 0; i < ips_count; i++)
- mail_host_add_ip(list, &ips[i]);
+ (void)mail_host_add_ip(list, &ips[i]);
return 0;
}
/* create hosts from the final bits */
do {
ip1_arr[i] = ntohl(i1);
- mail_host_add_ip(list, &ip1);
+ (void)mail_host_add_ip(list, &ip1);
i1++;
} while (ip1_arr[i] != ip2_arr[i]);
return 0;
return -1;
}
- director_connection_init_in(director, fd, ip);
+ (void)director_connection_init_in(director, fd, ip);
return 0;
}
auth = auth_connection_init(socket_path);
if (auth_connection_connect(auth) == 0) {
master_service_client_connection_accept(conn);
- login_connection_init(director, conn->fd, auth, userdb);
+ (void)login_connection_init(director, conn->fd, auth, userdb);
} else {
auth_connection_deinit(&auth);
}
test_begin("user directory ascending");
dir = user_directory_init(USER_DIR_TIMEOUT, "%u");
- user_directory_add(dir, 1, host, ioloop_time + count+1);
+ (void)user_directory_add(dir, 1, host, ioloop_time + count+1);
for (i = 0; i < count; i++)
- user_directory_add(dir, i+2, host, ioloop_time + i);
+ (void)user_directory_add(dir, i+2, host, ioloop_time + i);
verify_user_directory(dir, count+1);
user_directory_deinit(&dir);
test_end();
dir = user_directory_init(USER_DIR_TIMEOUT, "%u");
for (i = 0; i < count; i++)
- user_directory_add(dir, i+1, host, ioloop_time - i);
+ (void)user_directory_add(dir, i+1, host, ioloop_time - i);
verify_user_directory(dir, count);
user_directory_deinit(&dir);
test_end();
timestamp = ioloop_time;
else
timestamp = ioloop_time-rand()%100;
- user_directory_add(dir, i+1, host, timestamp);
+ (void)user_directory_add(dir, i+1, host, timestamp);
}
verify_user_directory(dir, count);
user_directory_deinit(&dir);
dump_timestamp(input, "msg.received", line + 1);
break;
case DBOX_METADATA_PHYSICAL_SIZE:
- dump_size(input, "msg.physical-size", line + 1);
+ (void)dump_size(input, "msg.physical-size", line + 1);
break;
case DBOX_METADATA_VIRTUAL_SIZE:
- dump_size(input, "msg.virtual-size", line + 1);
+ (void)dump_size(input, "msg.virtual-size", line + 1);
break;
case DBOX_METADATA_EXT_REF:
printf("msg.ext-ref = %s\n", line + 1);
doveadm_mail_server_handle(conn, input->username);
else if (array_count(&server->connections) <
I_MAX(ctx->set->doveadm_worker_count, 1)) {
- conn = server_connection_create(server);
- doveadm_mail_server_handle(conn, input->username);
+ if (server_connection_create(server, &conn) < 0)
+ internal_failure = TRUE;
+ else
+ doveadm_mail_server_handle(conn, input->username);
} else {
if (array_count(&server->queue) >= DOVEADM_SERVER_QUEUE_MAX)
doveadm_server_flush_one(server);
bool only_selectable;
};
-static int
+static bool
search_args_get_mailbox_patterns(const struct mail_search_arg *args,
ARRAY_TYPE(const_string) *patterns,
bool *have_guid, bool *have_wildcards)
if (!search_args_get_mailbox_patterns(subargs,
patterns, have_guid,
have_wildcards))
- return 0;
+ return FALSE;
}
break;
case SEARCH_MAILBOX_GLOB:
case SEARCH_MAILBOX:
if (args->match_not) {
array_clear(patterns);
- return 0;
+ return FALSE;
}
array_append(patterns, &args->value.str, 1);
break;
break;
}
}
- return 1;
+ return TRUE;
}
static struct doveadm_mailbox_list_iter *
iter->search_args = search_args;
iter->user = user;
i_array_init(&iter->patterns, 16);
- search_args_get_mailbox_patterns(search_args->args, &iter->patterns,
- &have_guid, &have_wildcards);
+ (void)search_args_get_mailbox_patterns(search_args->args,
+ &iter->patterns,
+ &have_guid, &have_wildcards);
if (array_count(&iter->patterns) == 0) {
iter_flags |= MAILBOX_LIST_ITER_SKIP_ALIASES;
{
struct mountpoint_list *mountpoints;
struct mountpoint_list_rec rec;
+ int ret = 0;
if (argc > 3)
mount_cmd_help(cmd_mount_add);
mountpoints = mountpoint_list_get();
if (argv[1] == NULL) {
- mountpoint_list_add_missing(mountpoints,
+ ret = mountpoint_list_add_missing(mountpoints,
MOUNTPOINT_STATE_DEFAULT,
mountpoint_list_default_ignore_prefixes,
mountpoint_list_default_ignore_types);
rec.wildcard = TRUE;
mountpoint_list_add(mountpoints, &rec);
}
- (void)mountpoint_list_save(mountpoints);
+ if (mountpoint_list_save(mountpoints) < 0)
+ ret = -1;
mountpoint_list_deinit(&mountpoints);
+ if (ret < 0)
+ doveadm_exit_code = EX_TEMPFAIL;
}
static void cmd_mount_remove(int argc, char *argv[])
memset(line_r, 0, sizeof(*line_r));
- net_addr2ip(ident, &line_r->ip);
+ (void)net_addr2ip(ident, &line_r->ip);
line_r->penalty = strtoul(penalty_str, NULL, 10);
line_r->last_penalty = strtoul(last_penalty_str, NULL, 10);
line_r->last_update = strtoul(last_update_str, NULL, 10);
if (str_to_uint64(line->prev_values[i], &prev_num) == 0 &&
str_to_uint64(line->cur_values[i], &cur_num) == 0) {
- i_snprintf(numstr, sizeof(numstr), "%llu",
- (unsigned long long)(cur_num - prev_num));
+ if (i_snprintf(numstr, sizeof(numstr), "%llu",
+ (unsigned long long)(cur_num - prev_num)) < 0)
+ i_unreached();
doveadm_print(numstr);
} else if (get_double(line->prev_values[i], &prev_double) == 0 &&
get_double(line->cur_values[i], &cur_double) == 0 &&
get_double(line->prev_values[ctx->last_update_idx], &prev_time) == 0 &&
get_double(line->cur_values[ctx->last_update_idx], &cur_time) == 0) {
/* %CPU */
- i_snprintf(numstr, sizeof(numstr), "%d",
- (int)((cur_double - prev_double) *
- (cur_time - prev_time) * 100));
+ if (i_snprintf(numstr, sizeof(numstr), "%d",
+ (int)((cur_double - prev_double) *
+ (cur_time - prev_time) * 100)) < 0)
+ i_unreached();
doveadm_print(numstr);
} else {
doveadm_print(line->cur_values[i]);
return TRUE;
}
-static struct dsync_slave *
+static int
cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user,
struct dsync_brain *brain, struct dsync_slave *slave2)
{
brain2_running = dsync_brain_run(brain2, &changed2);
}
mail_user_unref(&user2);
- dsync_brain_deinit(&brain2);
- return slave2;
+ return dsync_brain_deinit(&brain2);
}
static void
DSYNC_BRAIN_FLAG_SEND_REQUESTS,
"");
- if (!ctx->remote)
- cmd_dsync_run_local(ctx, user, brain, slave2);
- else
+ if (!ctx->remote) {
+ if (cmd_dsync_run_local(ctx, user, brain, slave2) < 0)
+ _ctx->exit_code = EX_TEMPFAIL;
+ } else {
cmd_dsync_run_remote(user);
+ }
if (dsync_brain_deinit(&brain) < 0)
_ctx->exit_code = EX_TEMPFAIL;
deletes = dsync_mailbox_tree_get_deletes(brain->local_mailbox_tree,
&count);
- dsync_slave_send_mailbox_deletes(brain->slave, deletes, count,
- brain->hierarchy_sep);
+ (void)dsync_slave_send_mailbox_deletes(brain->slave, deletes, count,
+ brain->hierarchy_sep);
brain->state = DSYNC_STATE_RECV_MAILBOX_TREE;
}
}
/* start exporting this mailbox (wait for remote to start importing) */
- dsync_slave_send_mailbox(brain->slave, &dsync_box);
- dsync_brain_sync_mailbox_init(brain, box, &dsync_box,
- DSYNC_BOX_STATE_MAILBOX);
+ (void)dsync_slave_send_mailbox(brain->slave, &dsync_box);
+ (void)dsync_brain_sync_mailbox_init(brain, box, &dsync_box,
+ DSYNC_BOX_STATE_MAILBOX);
brain->state = DSYNC_STATE_SYNC_MAILS;
}
memcpy(delete_box.mailbox_guid, dsync_box->mailbox_guid,
sizeof(delete_box.mailbox_guid));
delete_box.mailbox_lost = TRUE;
- dsync_slave_send_mailbox(brain->slave, &delete_box);
+ (void)dsync_slave_send_mailbox(brain->slave, &delete_box);
return TRUE;
}
i_assert(local_dsync_box.uid_validity != 0);
i_assert(memcmp(dsync_box->mailbox_guid, local_dsync_box.mailbox_guid,
sizeof(dsync_box->mailbox_guid)) == 0);
- dsync_slave_send_mailbox(brain->slave, &local_dsync_box);
+ (void)dsync_slave_send_mailbox(brain->slave, &local_dsync_box);
dsync_brain_mailbox_update_pre(brain, box, &local_dsync_box, dsync_box);
if (changes_during_sync)
brain->changes_during_sync = TRUE;
}
- dsync_slave_send_mailbox_state(brain->slave, &state);
+ (void)dsync_slave_send_mailbox_state(brain->slave, &state);
}
static bool dsync_brain_recv_mail(struct dsync_brain *brain)
return importer;
}
-static int dsync_mail_error(struct dsync_mailbox_importer *importer,
- struct mail *mail, const char *field)
+static void dsync_mail_error(struct dsync_mailbox_importer *importer,
+ struct mail *mail, const char *field)
{
const char *errstr;
enum mail_error error;
errstr = mailbox_get_last_error(importer->box, &error);
if (error == MAIL_ERROR_EXPUNGED)
- return 0;
+ return;
i_error("Can't lookup %s for UID=%u: %s", field, mail->uid, errstr);
importer->failed = TRUE;
- return -1;
}
static bool
importer->cur_guid = NULL;
importer->next_local_seq = 0;
- mailbox_search_deinit(&importer->search_ctx);
+ (void)mailbox_search_deinit(&importer->search_ctx);
dsync_mailbox_import_search_init(importer);
}
dsync_mailbox_common_uid_found(importer);
}
/* skip common local mails */
- importer_next_mail(importer, importer->last_common_uid+1);
+ (void)importer_next_mail(importer, importer->last_common_uid+1);
/* if there are any local mails left, add them to newmails list */
while (importer->cur_mail != NULL)
- dsync_mailbox_try_save(importer, NULL);
+ (void)dsync_mailbox_try_save(importer, NULL);
dsync_mailbox_import_assign_new_uids(importer);
}
mailbox_get_vname(importer->box), msgs_left);
}
- if (importer->search_ctx != NULL)
- mailbox_search_deinit(&importer->search_ctx);
+ if (importer->search_ctx != NULL) {
+ if (mailbox_search_deinit(&importer->search_ctx) < 0)
+ importer->failed = TRUE;
+ }
mail_free(&importer->mail);
mail_free(&importer->ext_mail);
guid_128_hash, guid_128_cmp);
iter = dsync_mailbox_tree_iter_init(tree);
while (dsync_mailbox_tree_iter_next(iter, &name, &node))
- dsync_mailbox_tree_guid_hash_add(tree, node);
+ (void)dsync_mailbox_tree_guid_hash_add(tree, node);
dsync_mailbox_tree_iter_deinit(&iter);
return ret;
}
DSYNC_SLAVE_SEND_RET_OK;
}
-enum dsync_slave_send_ret
-dsync_slave_send_end_of_list(struct dsync_slave *slave)
+void dsync_slave_send_end_of_list(struct dsync_slave *slave)
{
slave->v.send_end_of_list(slave);
- return dsync_slave_send_ret(slave);
}
enum dsync_slave_send_ret
dsync_slave_recv_handshake(struct dsync_slave *slave,
const struct dsync_slave_settings **set_r);
-enum dsync_slave_send_ret
-dsync_slave_send_end_of_list(struct dsync_slave *slave);
+void dsync_slave_send_end_of_list(struct dsync_slave *slave);
enum dsync_slave_send_ret
dsync_slave_send_mailbox_state(struct dsync_slave *slave,
return 0;
}
-struct server_connection *
-server_connection_create(struct doveadm_server *server)
+int server_connection_create(struct doveadm_server *server,
+ struct server_connection **conn_r)
{
#define DOVEADM_SERVER_HANDSHAKE "VERSION\tdoveadm-server\t1\t0\n"
struct server_connection *conn;
o_stream_nsend_str(conn->output, DOVEADM_SERVER_HANDSHAKE);
array_append(&conn->server->connections, &conn, 1);
- server_connection_read_settings(conn);
- return conn;
+ if (server_connection_read_settings(conn) < 0) {
+ server_connection_destroy(&conn);
+ return -1;
+ }
+ *conn_r = conn;
+ return 0;
}
void server_connection_destroy(struct server_connection **_conn)
};
struct doveadm_server;
+struct server_connection;
typedef void server_cmd_callback_t(enum server_cmd_reply reply, void *context);
-struct server_connection *
-server_connection_create(struct doveadm_server *server);
+int server_connection_create(struct doveadm_server *server,
+ struct server_connection **conn_r);
void server_connection_destroy(struct server_connection **conn);
/* Return the server given to create() */
}
}
o_stream_uncork(imap_client->common.output);
- client_unref(&client);
+ (void)client_unref(&client);
}
static struct client *imap_client_alloc(pool_t pool)
if (!fetch_parse_args(ctx, cmd, &args[1], &next_arg) ||
(imap_arg_get_list(next_arg, &list_arg) &&
!fetch_parse_modifiers(ctx, cmd, list_arg))) {
- imap_fetch_deinit(ctx);
+ (void)imap_fetch_deinit(ctx);
return TRUE;
}
ctx->sync_pending = FALSE;
ctx->sync_ctx = imap_sync_init(ctx->client, box, 0, 0);
- cmd_idle_continue(ctx->cmd);
+ (void)cmd_idle_continue(ctx->cmd);
}
static void idle_callback(struct mailbox *box, struct cmd_idle_context *ctx)
imap_quote_append_string(str, str_c(mutf7_name), FALSE);
mailbox_childinfo2str(ctx, str, flags);
- ret = client_send_line(ctx->cmd->client, str_c(str));
+ ret = client_send_line_next(ctx->cmd->client, str_c(str));
if (ctx->used_status) T_BEGIN {
list_send_status(ctx, name, flags);
} T_END;
client_disconnect(client, msg);
}
-int client_send_line(struct client *client, const char *data)
+void client_send_line(struct client *client, const char *data)
+{
+ (void)client_send_line_next(client, data);
+}
+
+int client_send_line_next(struct client *client, const char *data)
{
struct const_iovec iov[2];
return FALSE;
if (client->input_lock == NULL)
- cmd_sync_delayed(client);
+ (void)cmd_sync_delayed(client);
return TRUE;
}
void client_disconnect(struct client *client, const char *reason);
void client_disconnect_with_error(struct client *client, const char *msg);
+/* Send a line of data to client. */
+void client_send_line(struct client *client, const char *data);
/* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,
- -1 if error */
-int client_send_line(struct client *client, const char *data);
+ -1 if error. This should be used when you're (potentially) sending a lot of
+ lines to client. */
+int client_send_line_next(struct client *client, const char *data);
/* Send line of data to client, prefixed with client->tag. You need to prefix
the data with "OK ", "NO " or "BAD ". */
void client_send_tagline(struct client_command_context *cmd, const char *data);
const char *str;
msgpart = imap_msgpart_full();
- fetch_and_free_msgpart(ctx, mail, &msgpart);
+ if (fetch_and_free_msgpart(ctx, mail, &msgpart) < 0)
+ return -1;
str = t_strdup_printf(" RFC822 {%"PRIuUOFF_T"}\r\n", ctx->cur_size);
if (ctx->first) {
const char *str;
msgpart = imap_msgpart_header();
- fetch_and_free_msgpart(ctx, mail, &msgpart);
+ if (fetch_and_free_msgpart(ctx, mail, &msgpart) < 0)
+ return -1;
str = t_strdup_printf(" RFC822.HEADER {%"PRIuUOFF_T"}\r\n",
ctx->cur_size);
const char *str;
msgpart = imap_msgpart_body();
- fetch_and_free_msgpart(ctx, mail, &msgpart);
+ if (fetch_and_free_msgpart(ctx, mail, &msgpart) < 0)
+ return -1;
str = t_strdup_printf(" RFC822.TEXT {%"PRIuUOFF_T"}\r\n",
ctx->cur_size);
str_append(str, "FLAGS (");
imap_write_flags(str, flags, keywords);
str_append(str, "))");
- return client_send_line(ctx->client, str_c(str));
+ return client_send_line_next(ctx->client, str_c(str));
}
static int imap_sync_send_modseq(struct imap_sync_context *ctx, string_t *str)
str_printfa(str, "UID %u ", ctx->mail->uid);
imap_sync_add_modseq(ctx, str);
str_append_c(str, ')');
- return client_send_line(ctx->client, str_c(str));
+ return client_send_line_next(ctx->client, str_c(str));
}
static void imap_sync_vanished(struct imap_sync_context *ctx)
str_truncate(str, 0);
str_printfa(str, "* %u EXPUNGE", ctx->seq);
- ret = client_send_line(ctx->client, str_c(str));
+ ret = client_send_line_next(ctx->client, str_c(str));
}
if (ctx->seq < ctx->sync_rec.seq1) {
/* update only after we're finished, so that
if (input.username == NULL)
i_fatal("USER environment missing");
if ((value = getenv("IP")) != NULL)
- net_addr2ip(value, &input.remote_ip);
+ (void)net_addr2ip(value, &input.remote_ip);
if ((value = getenv("LOCAL_IP")) != NULL)
- net_addr2ip(value, &input.local_ip);
+ (void)net_addr2ip(value, &input.local_ip);
input_base64 = getenv("CLIENT_INPUT");
input_buf = input_base64 == NULL ? NULL :
percentage = counter*100 / max;
if (percentage != percentage_sent && percentage < 100) {
percentage_sent = percentage;
- i_snprintf(percentage_str,
- sizeof(percentage_str), "%u\n",
- percentage);
+ if (i_snprintf(percentage_str,
+ sizeof(percentage_str), "%u\n",
+ percentage) < 0)
+ i_unreached();
(void)write_full(conn->fd, percentage_str,
strlen(percentage_str));
}
}
ret = -1;
} else if (strchr(what, 'i') != NULL) {
- index_mailbox_precache(conn, box);
+ if (index_mailbox_precache(conn, box) < 0)
+ ret = -1;
}
mailbox_free(&box);
return ret;
void auth_client_connect(struct auth_client *client)
{
if (client->conn->fd == -1)
- auth_server_connection_connect(client->conn);
+ (void)auth_server_connection_connect(client->conn);
}
void auth_client_disconnect(struct auth_client *client, const char *reason)
if (parser->str_first_escape >= 0 &&
(parser->flags & IMAP_PARSE_FLAG_NO_UNESCAPE) == 0) {
/* -1 because we skipped the '"' prefix */
- str_unescape(str + parser->str_first_escape-1);
+ (void)str_unescape(str + parser->str_first_escape-1);
}
arg->_data.str = str;
arg->str_len = strlen(str);
str_append_c(str, '"');
}
+static const char *
+imap_quote_internal(pool_t pool, const unsigned char *value,
+ size_t value_len, bool fix_text)
+{
+ string_t *str;
+
+ str = t_str_new(value_len + MAX_INT_STRLEN + 5);
+ imap_quote_append(str, value, value_len, fix_text);
+ return pool->datastack_pool ? str_c(str) :
+ p_strndup(pool, str_data(str), str_len(str));
+}
+
const char *imap_quote(pool_t pool, const unsigned char *value,
size_t value_len, bool fix_text)
{
- string_t *str;
- char *ret;
+ const char *ret;
if (value == NULL)
return "NIL";
if (!pool->datastack_pool)
- t_push();
-
- str = t_str_new(value_len + MAX_INT_STRLEN + 5);
- imap_quote_append(str, value, value_len, fix_text);
- ret = p_strndup(pool, str_data(str), str_len(str));
-
- if (!pool->datastack_pool)
- t_pop();
+ ret = imap_quote_internal(pool, value, value_len, fix_text);
+ else T_BEGIN {
+ ret = imap_quote_internal(pool, value, value_len, fix_text);
+ } T_END;
return ret;
}
buffer_free(&ctx.buffer);
buffer_free(&ctx.field_seen);
- o_stream_seek(output, 0);
+ (void)o_stream_seek(output, 0);
o_stream_nsend(output, &hdr, sizeof(hdr));
mail_cache_view_close(&cache_view);
struct mail_cache_transaction_ctx *ctx = CACHE_TRANS_CONTEXT(t);
struct mail_index_transaction_vfuncs super = ctx->super;
- mail_cache_transaction_commit(&ctx);
+ /* a failed cache commit isn't important enough to fail the entire
+ index transaction, so we'll just ignore it */
+ (void)mail_cache_transaction_commit(&ctx);
return super.commit(t, result_r);
}
file_cache_set_fd(cache->file_cache, cache->fd);
if (fstat(cache->fd, &st) == 0)
- file_cache_set_size(cache->file_cache, st.st_size);
+ (void)file_cache_set_size(cache->file_cache, st.st_size);
else if (!ESTALE_FSTAT(errno))
mail_cache_set_syscall_error(cache, "fstat()");
/* add keyword records so we can start appending names directly */
rec_pos = dest->used;
memset(&new_kw_rec, 0, sizeof(new_kw_rec));
- buffer_append_space_unsafe(dest, keywords_count * sizeof(*kw_rec));
+ (void)buffer_append_space_unsafe(dest, keywords_count * sizeof(*kw_rec));
/* write the actual records and names */
name_base_pos = dest->used;
return -1;
}
- mail_index_map_register_ext(map, name, ext_offset, ext_hdr);
+ (void)mail_index_map_register_ext(map, name, ext_offset, ext_hdr);
}
return 0;
}
for (i = 0; i < count; i++) {
if (mail_index_lookup_seq(ctx->view,
appends[i].uid, &seq1)) {
- mail_index_modseq_update_to_highest(ctx, seq1,
- seq1);
+ (void)mail_index_modseq_update_to_highest(ctx, seq1, seq1);
}
}
return;
rec = array_idx(&uids, i);
if (mail_index_lookup_seq_range(ctx->view, rec->seq1, rec->seq2,
&seq1, &seq2))
- mail_index_modseq_update_to_highest(ctx, seq1, seq2);
+ (void)mail_index_modseq_update_to_highest(ctx, seq1, seq2);
}
}
void mail_index_modseq_append(struct mail_index_modseq_sync *ctx, uint32_t seq)
{
- mail_index_modseq_update_to_highest(ctx, seq, seq);
+ (void)mail_index_modseq_update_to_highest(ctx, seq, seq);
}
void mail_index_modseq_expunge(struct mail_index_modseq_sync *ctx,
void mail_index_fsck_locked(struct mail_index *index);
-int mail_index_set_error(struct mail_index *index, const char *fmt, ...)
+void mail_index_set_error(struct mail_index *index, const char *fmt, ...)
ATTR_FORMAT(2, 3);
/* "%s failed with index file %s: %m" */
-int mail_index_set_syscall_error(struct mail_index *index,
- const char *function);
+void mail_index_set_syscall_error(struct mail_index *index,
+ const char *function);
/* "%s failed with file %s: %m" */
-int mail_index_file_set_syscall_error(struct mail_index *index,
- const char *filepath,
- const char *function);
+void mail_index_file_set_syscall_error(struct mail_index *index,
+ const char *filepath,
+ const char *function);
#endif
i_assert(block_size != 0);
end_offset = output->offset;
- o_stream_seek(output, block_offset);
+ (void)o_stream_seek(output, block_offset);
o_stream_nsend(output, &block_size, sizeof(block_size));
- o_stream_seek(output, end_offset);
+ (void)o_stream_seek(output, end_offset);
if (output->last_failed_errno != 0)
return;
/* write the new records */
output = o_stream_create_fd(view->strmap->fd, 0, FALSE);
- o_stream_seek(output, view->last_read_block_offset);
+ (void)o_stream_seek(output, view->last_read_block_offset);
o_stream_cork(output);
mail_index_strmap_write_block(view, output, i,
view->last_read_uid + 1);
struct mail_index_map *
mail_index_sync_get_atomic_map(struct mail_index_sync_map_ctx *ctx)
{
- mail_index_sync_move_to_private_memory(ctx);
+ (void)mail_index_sync_move_to_private_memory(ctx);
mail_index_record_map_move_to_private(ctx->view->map);
mail_index_modseq_sync_map_replaced(ctx->modseq_ctx);
return ctx->view->map;
unsigned int right_idx,
uint32_t seq);
-bool mail_index_ext_using_reset_id(struct mail_index_transaction *t,
+void mail_index_ext_using_reset_id(struct mail_index_transaction *t,
uint32_t ext_id, uint32_t reset_id);
#endif
seq = *ext_rec < first_new_seq ? *ext_rec :
old_to_newseq_map[*ext_rec - first_new_seq];
- mail_index_seq_array_add(&new_array, seq, ext_rec+1,
- old_array->arr.element_size -
- sizeof(*ext_rec), NULL);
+ (void)mail_index_seq_array_add(&new_array, seq, ext_rec+1,
+ old_array->arr.element_size -
+ sizeof(*ext_rec), NULL);
}
array_free(old_array);
ext_rec_arrays[j] = new_array;
t->log_ext_updates = mail_index_transaction_has_ext_changes(t);
}
-bool mail_index_ext_using_reset_id(struct mail_index_transaction *t,
+void mail_index_ext_using_reset_id(struct mail_index_transaction *t,
uint32_t ext_id, uint32_t reset_id)
{
uint32_t *reset_id_p;
/* reset_id changed, clear existing changes */
mail_index_ext_reset_changes(t, ext_id);
}
- return changed;
}
void mail_index_ext_set_reset_id(struct mail_index_transaction *t,
&old_diff32)) {
/* already incremented this sequence in this transaction */
diff32 += old_diff32;
- mail_index_seq_array_add(array, seq, &diff32, sizeof(diff32),
- NULL);
+ (void)mail_index_seq_array_add(array, seq, &diff32,
+ sizeof(diff32), NULL);
}
return diff32;
}
&kw_reset) < 0)
return -1;
- view_sync_update_keywords(ctx, new_rec->uid);
+ if (view_sync_update_keywords(ctx, new_rec->uid) < 0)
+ return -1;
changed = TRUE;
}
return -1;
mail_index_map_lookup_keywords(new_map, j + 1,
&ctx->lost_new_kw);
- view_sync_update_keywords(ctx, new_rec->uid);
+ if (view_sync_update_keywords(ctx, new_rec->uid) < 0)
+ return -1;
}
*expunge_count_r = view_sync_expunges2seqs(ctx);
}
if ((index->flags & MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS) != 0)
- mail_index_create_backup(index);
+ (void)mail_index_create_backup(index);
if (ret == 0 && rename(path, index->filepath) < 0) {
mail_index_set_error(index, "rename(%s, %s) failed: %m",
if (!MAIL_INDEX_IS_IN_MEMORY(index)) {
if (mail_index_recreate(index) < 0) {
- mail_index_move_to_memory(index);
+ (void)mail_index_move_to_memory(index);
return;
}
}
}
if (index->fd == -1) {
- if (errno != ENOENT)
- return mail_index_set_syscall_error(index, "open()");
+ if (errno != ENOENT) {
+ mail_index_set_syscall_error(index, "open()");
+ return -1;
+ }
/* have to create it */
return 0;
if (nfs_safe_stat(index->filepath, &st2) < 0) {
if (errno == ENOENT)
return 0;
- return mail_index_set_syscall_error(index, "stat()");
+ mail_index_set_syscall_error(index, "stat()");
+ return -1;
}
if (fstat(index->fd, &st1) < 0) {
- if (!ESTALE_FSTAT(errno))
- return mail_index_set_syscall_error(index, "fstat()");
+ if (!ESTALE_FSTAT(errno)) {
+ mail_index_set_syscall_error(index, "fstat()");
+ return -1;
+ }
/* deleted/recreated, reopen */
} else if (st1.st_ino == st2.st_ino &&
CMP_DEV_T(st1.st_dev, st2.st_dev)) {
return index->cache;
}
-int mail_index_set_error(struct mail_index *index, const char *fmt, ...)
+void mail_index_set_error(struct mail_index *index, const char *fmt, ...)
{
va_list va;
i_error("%s", index->error);
}
-
- return -1;
}
bool mail_index_is_in_memory(struct mail_index *index)
mail_index_file_set_syscall_error(index, path, "fchmod()");
}
-int mail_index_set_syscall_error(struct mail_index *index,
- const char *function)
+void mail_index_set_syscall_error(struct mail_index *index,
+ const char *function)
{
- return mail_index_file_set_syscall_error(index, index->filepath,
- function);
+ mail_index_file_set_syscall_error(index, index->filepath, function);
}
-int mail_index_file_set_syscall_error(struct mail_index *index,
- const char *filepath,
- const char *function)
+void mail_index_file_set_syscall_error(struct mail_index *index,
+ const char *filepath,
+ const char *function)
{
const char *errstr;
if (ENOSPACE(errno)) {
index->nodiskspace = TRUE;
if ((index->flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) == 0)
- return -1;
+ return;
}
if (errno == EACCES) {
errstr = eacces_error_get_creating(function, filepath);
else
errstr = eacces_error_get(function, filepath);
- return mail_index_set_error(index, "%s", errstr);
+ mail_index_set_error(index, "%s", errstr);
} else {
const char *suffix = errno != EFBIG ? "" :
" (process was started with ulimit -f limit)";
- return mail_index_set_error(index, "%s failed with file %s: "
- "%m%s", function, filepath, suffix);
+ mail_index_set_error(index, "%s failed with file %s: "
+ "%m%s", function, filepath, suffix);
}
}
static int
mail_transaction_log_file_sync(struct mail_transaction_log_file *file);
-static int
+static void
log_file_set_syscall_error(struct mail_transaction_log_file *file,
const char *function)
{
- return mail_index_file_set_syscall_error(file->log->index,
- file->filepath, function);
+ mail_index_file_set_syscall_error(file->log->index,
+ file->filepath, function);
}
static void
}
if (file->log->index->lock_method == FILE_LOCK_METHOD_DOTLOCK) {
- mail_transaction_log_file_undotlock(file);
+ (void)mail_transaction_log_file_undotlock(file);
return;
}
if (reset)
rename_existing = FALSE;
else if (nfs_safe_stat(file->filepath, &st) < 0) {
- if (errno != ENOENT)
- return log_file_set_syscall_error(file, "stat()");
+ if (errno != ENOENT) {
+ log_file_set_syscall_error(file, "stat()");
+ return -1;
+ }
rename_existing = FALSE;
} else if (st.st_ino == file->st_ino &&
CMP_DEV_T(st.st_dev, file->st_dev) &&
if (index->ext_hdr_init_data != NULL && reset)
log_write_ext_hdr_init_data(index, writebuf);
- if (write_full(new_fd, writebuf->data, writebuf->used) < 0)
- return log_file_set_syscall_error(file, "write_full()");
+ if (write_full(new_fd, writebuf->data, writebuf->used) < 0) {
+ log_file_set_syscall_error(file, "write_full()");
+ return -1;
+ }
if (file->log->index->fsync_mode == FSYNC_MODE_ALWAYS) {
/* the header isn't important, so don't bother calling
fdatasync() unless it's required */
- if (fdatasync(new_fd) < 0)
- return log_file_set_syscall_error(file, "fdatasync()");
+ if (fdatasync(new_fd) < 0) {
+ log_file_set_syscall_error(file, "fdatasync()");
+ return -1;
+ }
}
file->fd = new_fd;
fd = file_dotlock_open(&new_dotlock_set, file->filepath, 0, &dotlock);
umask(old_mask);
- if (fd == -1)
- return log_file_set_syscall_error(file, "file_dotlock_open()");
+ if (fd == -1) {
+ log_file_set_syscall_error(file, "file_dotlock_open()");
+ return -1;
+ }
mail_index_fchown(index, fd, file_dotlock_get_lock_path(dotlock));
/* either fd gets used or the dotlock gets deleted and returned fd
if (errno == ENOENT)
return 0;
- return log_file_set_syscall_error(file, "open()");
+ log_file_set_syscall_error(file, "open()");
+ return -1;
}
ignore_estale = i < MAIL_INDEX_ESTALE_RETRY_COUNT;
Without this check we might see partial transactions,
sometimes causing "Extension record updated without intro
prefix" errors. */
- if (fstat(file->fd, &st) < 0)
- return log_file_set_syscall_error(file, "fstat()");
+ if (fstat(file->fd, &st) < 0) {
+ log_file_set_syscall_error(file, "fstat()");
+ return -1;
+ }
if ((uoff_t)st.st_size != file->last_size) {
file->last_size = st.st_size;
return 0;
/* log file was deleted in NFS server, fail silently */
return 0;
} else {
- return log_file_set_syscall_error(file, "pread()");
+ log_file_set_syscall_error(file, "pread()");
+ return -1;
}
}
/* log file was deleted in NFS server, fail silently */
return 0;
}
- return log_file_set_syscall_error(file, "pread()");
+ log_file_set_syscall_error(file, "pread()");
+ return -1;
}
return 1;
}
if (file->log->nfs_flush && nfs_flush) {
if (!file->locked)
nfs_flush_attr_cache_unlocked(file->filepath);
- else {
- nfs_flush_attr_cache_fd_locked(file->filepath,
- file->fd);
- }
+ else
+ nfs_flush_attr_cache_fd_locked(file->filepath, file->fd);
}
if (file->buffer != NULL && file->buffer_offset > start_offset) {
if (file->mmap_base == MAP_FAILED) {
file->mmap_base = NULL;
file->mmap_size = 0;
- return log_file_set_syscall_error(file, "mmap()");
+ log_file_set_syscall_error(file, "mmap()");
+ return -1;
}
if (file->mmap_size > mmap_get_page_size()) {
i_assert(file->buffer_offset == 0 || file->mmap_base == NULL);
i_assert(file->mmap_size == 0 || file->mmap_base != NULL);
- if (fstat(file->fd, &st) < 0)
- return log_file_set_syscall_error(file, "fstat()");
+ if (fstat(file->fd, &st) < 0) {
+ log_file_set_syscall_error(file, "fstat()");
+ return -1;
+ }
file->last_size = st.st_size;
if ((uoff_t)st.st_size < file->sync_offset) {
test_end();
}
-static bool
+static void
flags_array_check(struct mail_index_transaction *t,
const enum mail_flags *flags, unsigned int msg_count)
{
}
for (; seq <= msg_count; seq++)
test_assert(flags[seq] == 0);
- return TRUE;
}
static void test_mail_index_flag_update_random(void)
updates = array_get(&t->updates, &count);
test_assert(count == 1);
test_assert(updates[0].uid1 == 5 && updates[0].uid2 == 7);
- mail_index_cancel_flag_updates(t, 5);
+ test_assert(mail_index_cancel_flag_updates(t, 5));
test_assert(updates[0].uid1 == 6 && updates[0].uid2 == 7);
- mail_index_cancel_flag_updates(t, 7);
+ test_assert(mail_index_cancel_flag_updates(t, 7));
test_assert(updates[0].uid1 == 6 && updates[0].uid2 == 6);
- mail_index_cancel_flag_updates(t, 6);
+ test_assert(mail_index_cancel_flag_updates(t, 6));
test_assert(!array_is_created(&t->updates));
mail_index_update_flags_range(t, 5, 7, MODIFY_REPLACE, 0);
- mail_index_cancel_flag_updates(t, 6);
+ test_assert(mail_index_cancel_flag_updates(t, 6));
updates = array_get(&t->updates, &count);
test_assert(count == 2);
test_assert(updates[0].uid1 == 5 && updates[0].uid2 == 5);
static bool log_lock_failure = FALSE;
-int mail_index_file_set_syscall_error(struct mail_index *index ATTR_UNUSED,
- const char *filepath ATTR_UNUSED,
- const char *function ATTR_UNUSED)
+void mail_index_file_set_syscall_error(struct mail_index *index ATTR_UNUSED,
+ const char *filepath ATTR_UNUSED,
+ const char *function ATTR_UNUSED)
{
- return -1;
}
int mail_transaction_log_lock_head(struct mail_transaction_log *log ATTR_UNUSED)
buffer_t *dest, bool dtcase)
{
struct decode_utf8_context ctx;
- size_t used = dest->used;
memset(&ctx, 0, sizeof(ctx));
ctx.dest = dest;
const char *error;
};
-static unsigned int
-part_serialize(struct message_part *part, buffer_t *dest)
+static void part_serialize(struct message_part *part, buffer_t *dest,
+ unsigned int *children_count_r)
{
unsigned int count, children_count;
size_t children_offset;
sizeof(children_count));
if (part->children != NULL) {
- children_count =
- part_serialize(part->children, dest);
+ part_serialize(part->children, dest,
+ &children_count);
buffer_write(dest, children_offset,
&children_count,
part = part->next;
}
- return count;
+ *children_count_r = count;
}
void message_part_serialize(struct message_part *part, buffer_t *dest)
{
- part_serialize(part, dest);
+ unsigned int children_count;
+
+ part_serialize(part, dest, &children_count);
}
static bool read_next(struct deserialize_context *ctx,
/* broken / no value */
} else if (*ctx->data == '"') {
ret = rfc822_parse_quoted_string(ctx, tmp);
- str_unescape(str_c_modifiable(tmp) + value_pos);
+ (void)str_unescape(str_c_modifiable(tmp) + value_pos);
} else if (ctx->data != ctx->end && *ctx->data == '=') {
/* workaround for broken input:
name==?utf-8?b?...?= */
}
}
test_istream_set_size(test_input, input_len);
- i_stream_read(test_input);
+ (void)i_stream_read(test_input);
} else {
test_istream_set_size(test_input, input_len);
size = 0;
PUT_32BIT_MSB_FIRST(dest + 4, out[1]);
}
-unsigned char *
-deshash(unsigned char *dst, const unsigned char *key,
- const unsigned char *src)
+void deshash(unsigned char *dst, const unsigned char *key,
+ const unsigned char *src)
{
struct des_context ctx;
GET_32BIT_MSB_FIRST(key + 3), &ctx);
des_cbc_encrypt(dst, src, &ctx);
-
- return dst;
}
#ifndef NTLM_DES_H
#define NTLM_DES_H
-unsigned char * deshash(unsigned char *dst, const unsigned char *key,
- const unsigned char *src);
+void deshash(unsigned char *dst, const unsigned char *key,
+ const unsigned char *src);
#endif
return buffer_free_without_data(&wstr);
}
-const unsigned char *
-lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE])
+void lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE])
{
static const unsigned char lm_magic[8] = "KGS!@#$%";
unsigned char buffer[14];
deshash(hash + 8, buffer + 7, lm_magic);
safe_memset(buffer, 0, sizeof(buffer));
-
- return hash;
}
-const unsigned char *
-ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE])
+void ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE])
{
size_t len;
void *wpwd = t_unicode_str(passwd, 0, &len);
md4_get_digest(wpwd, len, hash);
safe_memset(wpwd, 0, len);
-
- return hash;
}
static void
#ifndef NTLM_ENCRYPT_H
#define NTLM_ENCRYPT_H
-const unsigned char *
-lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE]);
-
-const unsigned char *
-ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE]);
+void lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE]);
+void ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE]);
void ntlmssp_v1_response(const unsigned char *hash,
const unsigned char *challenge,
return -1;
}
-int digest_init(struct digest_context *ctx, const unsigned int algo)
+void digest_init(struct digest_context *ctx, const unsigned int algo)
{
i_assert(algo < N_ELEMENTS(digests));
ctx->digest = digests + algo;
ctx->digest->init(&ctx->ctx);
-
- return 0;
}
void digest_update(struct digest_context *ctx, const void *data,
};
int digest_find(const char *name);
-int digest_init(struct digest_context *ctx, const unsigned int algo);
+void digest_init(struct digest_context *ctx, const unsigned int algo);
void digest_update(struct digest_context *ctx, const void *data,
const size_t size);
void digest_final(struct digest_context *ctx, unsigned char *result);
/* \n isn't part of the DBOX_MAGIC_PRE, but it always preceds it.
assume that at this point we've already just read the \n. when
scanning for it later we'll need to find the \n though. */
- str_find_more(pre_ctx, (const unsigned char *)"\n", 1);
+ (void)str_find_more(pre_ctx, (const unsigned char *)"\n", 1);
orig_offset = input->v_offset;
while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) {
"dbox file size too small");
return 0;
}
- o_stream_seek(ctx->output, st.st_size);
+ if (o_stream_seek(ctx->output, st.st_size) < 0) {
+ dbox_file_set_syscall_error(file, "lseek()");
+ return -1;
+ }
}
*output_r = ctx->output;
return 1;
ctx->trans = trans;
mail_index_reset(ctx->trans);
index_mailbox_reset_uidvalidity(box);
- mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
+ (void)mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
/* open cache and read the caching decisions. we'll reset the cache in
case it contains any invalid data, but we want to preserve the
temporarily vanished */
if (ret > 0) {
(void)dbox_file_unlink(file);
- mdbox_map_remove_file_id(ctx->storage->map, file_id);
+ if (mdbox_map_remove_file_id(ctx->storage->map, file_id) < 0)
+ ret = -1;
} else {
dbox_file_unlock(file);
}
if (mdbox_file_purge(ctx, file, file_id) < 0)
ret = -1;
} else {
- mdbox_map_remove_file_id(storage->map, file_id);
+ if (mdbox_map_remove_file_id(storage->map, file_id) < 0)
+ ret = -1;
}
dbox_file_unref(&file);
} T_END;
ret = sdbox_file_copy_attachments((struct sdbox_file *)src_file,
(struct sdbox_file *)dest_file);
if (ret <= 0) {
- sdbox_file_unlink_aborted_save((struct sdbox_file *)dest_file);
+ (void)sdbox_file_unlink_aborted_save((struct sdbox_file *)dest_file);
dbox_file_unref(&src_file);
dbox_file_unref(&dest_file);
return ret;
if (data->stream == NULL) {
if (!data->initialized) {
/* coming here from mail_set_seq() */
- return mail_set_aborted(_mail);
+ mail_set_aborted(_mail);
+ return -1;
}
fetch_field = get_body ||
(data->access_part & READ_BODY) != 0 ?
enum mailbox_status_items items,
struct mailbox_status *status_r)
{
- index_storage_get_status(&mbox->box, items, status_r);
+ index_storage_get_open_status(&mbox->box, items, status_r);
if ((items & STATUS_PERMANENT_FLAGS) != 0)
status_r->permanent_flags = mbox->permanent_flags;
}
struct index_mail_data *data = &mail->data;
if (data->parts == NULL)
- get_cached_parts(mail);
+ (void)get_cached_parts(mail);
if (data->parts != NULL) {
data->hdr_size_set = TRUE;
if (index_mail_parse_headers(mail, NULL) < 0)
return -1;
} else {
- message_get_header_size(data->stream,
- &data->hdr_size,
- &has_nuls);
+ if (message_get_header_size(data->stream,
+ &data->hdr_size,
+ &has_nuls) < 0) {
+ mail_storage_set_critical(_mail->box->storage,
+ "read(%s) failed: %m",
+ i_stream_get_name(data->stream));
+ return -1;
+ }
data->hdr_size_set = TRUE;
}
}
if (index_mail_parse_body(mail, 0) < 0)
return -1;
} else {
- message_get_body_size(data->stream,
- &data->body_size,
- &has_nuls);
+ if (message_get_body_size(data->stream,
+ &data->body_size,
+ &has_nuls) < 0) {
+ mail_storage_set_critical(_mail->box->storage,
+ "read(%s) failed: %m",
+ i_stream_get_name(data->stream));
+ return -1;
+ }
data->body_size_set = TRUE;
}
}
{
if (hdr == NULL) {
/* end of headers, mark all unknown SEARCH_HEADERs unmatched */
- mail_search_args_foreach(ctx->args, search_header_unmatch, ctx);
+ (void)mail_search_args_foreach(ctx->args, search_header_unmatch,
+ ctx);
return;
}
ctx->hdr = hdr;
ctx->custom_header = FALSE;
- mail_search_args_foreach(ctx->args, search_header_arg, ctx);
+ (void)mail_search_args_foreach(ctx->args, search_header_arg, ctx);
}
}
if (uid_lowwater == 0)
return;
- mail_index_lookup_seq_range(ctx->view, uid_lowwater, (uint32_t)-1,
- &seq1, &seq2);
+ (void)mail_index_lookup_seq_range(ctx->view, uid_lowwater, (uint32_t)-1,
+ &seq1, &seq2);
if (*first_seq < seq1)
*first_seq = seq1;
}
i_assert(nodes[i].seq <= ctx->last_seq);
T_BEGIN {
- index_sort_header_get(mail, nodes[i].seq,
- sort_type, str);
+ (void)index_sort_header_get(mail, nodes[i].seq,
+ sort_type, str);
ctx->sort_strings[nodes[i].seq] =
str_len(str) == 0 ? "" :
p_strdup(pool, str_c(str));
str1 = t_str_new(256);
str2 = t_str_new(256);
- index_sort_header_get(mail, seq1, sort_type, str1);
- index_sort_header_get(mail, seq2, sort_type, str2);
+ (void)index_sort_header_get(mail, seq1, sort_type, str1);
+ (void)index_sort_header_get(mail, seq2, sort_type, str2);
ret = strcmp(str_c(str1), str_c(str2));
} T_END;
enum mailbox_status_items items,
struct mailbox_status *status_r)
{
- const struct mail_index_header *hdr, *hdr_pvt;
-
- memset(status_r, 0, sizeof(struct mailbox_status));
-
if (!box->opened) {
if (mailbox_open(box) < 0)
return -1;
if (mailbox_sync(box, 0) < 0)
return -1;
}
+ index_storage_get_open_status(box, items, status_r);
+ return 0;
+}
+
+void index_storage_get_open_status(struct mailbox *box,
+ enum mailbox_status_items items,
+ struct mailbox_status *status_r)
+{
+ const struct mail_index_header *hdr, *hdr_pvt;
+
+ memset(status_r, 0, sizeof(struct mailbox_status));
/* we can get most of the status items without any trouble */
hdr = mail_index_get_header(box->view);
!box->disallow_new_keywords;
}
}
- return 0;
}
static void
int index_storage_get_status(struct mailbox *box,
enum mailbox_status_items items,
struct mailbox_status *status_r);
+void index_storage_get_open_status(struct mailbox *box,
+ enum mailbox_status_items items,
+ struct mailbox_status *status_r);
int index_mailbox_get_metadata(struct mailbox *box,
enum mailbox_metadata_items items,
struct mailbox_metadata *metadata_r);
break;
/* mark the changes as dirty */
- mail_index_lookup_seq_range(ctx->sync_view,
- sync_rec->uid1,
- sync_rec->uid2,
- &seq1, &seq2);
+ (void)mail_index_lookup_seq_range(ctx->sync_view,
+ sync_rec->uid1,
+ sync_rec->uid2,
+ &seq1, &seq2);
memset(sync_rec, 0, sizeof(*sync_rec));
if (seq1 == 0)
continue;
ibox->recent_flags_count -=
- seq_range_array_remove_range(&ibox->recent_flags,
- start_uid + 1, uid - 1);
+ seq_range_array_remove_range_count(&ibox->recent_flags,
+ start_uid + 1, uid - 1);
}
if (uid + 1 < hdr->next_uid) {
ibox->recent_flags_count -=
- seq_range_array_remove_range(&ibox->recent_flags,
- uid + 1,
- hdr->next_uid - 1);
+ seq_range_array_remove_range_count(&ibox->recent_flags,
+ uid + 1,
+ hdr->next_uid - 1);
}
#ifdef DEBUG
if (!mail_index_view_is_inconsistent(view)) {
for (uid = range[i].seq1; uid <= range[i].seq2; uid++) {
if (uid >= hdr->next_uid)
break;
- mail_index_lookup_seq(view, uid, &seq);
+ (void)mail_index_lookup_seq(view, uid, &seq);
i_assert(seq != 0);
}
}
hdr = mail_index_get_header(box->view);
if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) {
- mail_index_lookup_seq_range(box->view,
- hdr->first_recent_uid,
- hdr->next_uid,
- &seq1, &seq2);
- if (seq1 != 0) {
+ if (mail_index_lookup_seq_range(box->view,
+ hdr->first_recent_uid,
+ hdr->next_uid,
+ &seq1, &seq2)) {
index_mailbox_set_recent_seq(box, box->view,
seq1, seq2);
}
uids = array_get(&removed_uids, &uid_count);
for (i = j = 0; i < uid_count; i++) {
/* find and remove from the map */
- bsearch_insert_pos(&uids[i].seq1, &msgid_map[j], map_count - j,
- sizeof(*msgid_map), msgid_map_cmp, &idx);
+ (void)bsearch_insert_pos(&uids[i].seq1, &msgid_map[j],
+ map_count - j, sizeof(*msgid_map),
+ msgid_map_cmp, &idx);
j += idx;
if (j == map_count) {
/* all removals after this are about messages we never
i_assert(!UIDLIST_IS_LOCKED(uidlist));
*_uidlist = NULL;
- maildir_uidlist_update(uidlist);
+ (void)maildir_uidlist_update(uidlist);
maildir_uidlist_close(uidlist);
hash_table_destroy(&uidlist->files);
if (uidlist->retry_rewind)
return FALSE;
/* Delete the old UID */
- maildir_uidlist_records_array_delete(uidlist, old_rec);
+ (void)maildir_uidlist_records_array_delete(uidlist, old_rec);
/* Replace the old record with this new one */
*old_rec = *rec;
rec = old_rec;
if (!uidlist->box->opened)
return;
- mail_index_refresh(uidlist->box->index);
+ (void)mail_index_refresh(uidlist->box->index);
view = mail_index_view_open(uidlist->box->index);
count = array_count(&uidlist->records);
hdr = mail_index_get_header(view);
offset = stream->v_offset;
i_stream_seek(stream, rstream->hdr_offset);
while (rstream->body_offset == (uoff_t)-1) {
- i_stream_get_data(stream, &pos);
+ (void)i_stream_get_data(stream, &pos);
i_stream_skip(stream, pos);
if (i_stream_raw_mbox_read(&rstream->istream) < 0) {
if (_mail->expunged || mbox->syncing)
return -1;
- if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
- return mail_set_aborted(_mail);
+ if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) {
+ mail_set_aborted(_mail);
+ return -1;
+ }
if (mbox->mbox_stream != NULL &&
istream_raw_mbox_is_corrupted(mbox->mbox_stream)) {
unsigned int finished:1;
};
-static int write_error(struct mbox_save_context *ctx)
+static void write_error(struct mbox_save_context *ctx)
{
mbox_set_syscall_error(ctx->mbox, "write()");
ctx->failed = TRUE;
- return -1;
}
static int mbox_seek_to_end(struct mbox_save_context *ctx, uoff_t *offset)
}
fd = ctx->mbox->mbox_fd;
- if (fstat(fd, &st) < 0)
- return mbox_set_syscall_error(ctx->mbox, "fstat()");
+ if (fstat(fd, &st) < 0) {
+ mbox_set_syscall_error(ctx->mbox, "fstat()");
+ return -1;
+ }
ctx->orig_atime = st.st_atime;
if (st.st_size == 0)
return 0;
- if (lseek(fd, st.st_size-1, SEEK_SET) < 0)
- return mbox_set_syscall_error(ctx->mbox, "lseek()");
+ if (lseek(fd, st.st_size-1, SEEK_SET) < 0) {
+ mbox_set_syscall_error(ctx->mbox, "lseek()");
+ return -1;
+ }
- if (read(fd, &ch, 1) != 1)
- return mbox_set_syscall_error(ctx->mbox, "read()");
+ if (read(fd, &ch, 1) != 1) {
+ mbox_set_syscall_error(ctx->mbox, "read()");
+ return -1;
+ }
if (ch != '\n') {
- if (write_full(fd, "\n", 1) < 0)
- return write_error(ctx);
+ if (write_full(fd, "\n", 1) < 0) {
+ write_error(ctx);
+ return -1;
+ }
*offset += 1;
}
static int mbox_append_lf(struct mbox_save_context *ctx)
{
- if (o_stream_send(ctx->output, "\n", 1) < 0)
- return write_error(ctx);
+ if (o_stream_send(ctx->output, "\n", 1) < 0) {
+ write_error(ctx);
+ return -1;
+ }
return 0;
}
/* flush manually here so that we don't confuse seek() errors with
buffer flushing errors */
- if (o_stream_flush(ctx->output) < 0)
- return write_error(ctx);
+ if (o_stream_flush(ctx->output) < 0) {
+ write_error(ctx);
+ return -1;
+ }
if (o_stream_seek(ctx->output, ctx->extra_hdr_offset +
- ctx->space_end_idx - len) < 0)
- return mbox_set_syscall_error(ctx->mbox, "o_stream_seek()");
+ ctx->space_end_idx - len) < 0) {
+ mbox_set_syscall_error(ctx->mbox, "lseek()");
+ return -1;
+ }
if (o_stream_send(ctx->output, str, len) < 0 ||
- o_stream_flush(ctx->output) < 0)
- return write_error(ctx);
+ o_stream_flush(ctx->output) < 0) {
+ write_error(ctx);
+ return -1;
+ }
- if (o_stream_seek(ctx->output, end_offset) < 0)
- return mbox_set_syscall_error(ctx->mbox, "o_stream_seek()");
+ if (o_stream_seek(ctx->output, end_offset) < 0) {
+ mbox_set_syscall_error(ctx->mbox, "lseek()");
+ return -1;
+ }
return 0;
}
data = i_stream_get_data(ctx->input, &size);
if (size > 0) {
- if (o_stream_send(ctx->output, data, size) < 0)
- return write_error(ctx);
+ if (o_stream_send(ctx->output, data, size) < 0) {
+ write_error(ctx);
+ return -1;
+ }
ctx->last_char = data[size-1];
i_stream_skip(ctx->input, size);
}
/* append our own headers and ending empty line */
ctx->extra_hdr_offset = ctx->output->offset;
if (o_stream_send(ctx->output, str_data(ctx->headers),
- str_len(ctx->headers)) < 0)
- return write_error(ctx);
+ str_len(ctx->headers)) < 0) {
+ write_error(ctx);
+ return -1;
+ }
ctx->eoh_offset = ctx->output->offset;
return 0;
}
if (i != size) {
/* found end of headers. write the rest of them
(not including the finishing empty line) */
- if (o_stream_send(ctx->output, data, i) < 0)
- return write_error(ctx);
+ if (o_stream_send(ctx->output, data, i) < 0) {
+ write_error(ctx);
+ return -1;
+ }
ctx->last_char = '\n';
i_stream_skip(ctx->input, i + 1);
break;
}
- if (o_stream_send(ctx->output, data, size) < 0)
- return write_error(ctx);
+ if (o_stream_send(ctx->output, data, size) < 0) {
+ write_error(ctx);
+ return -1;
+ }
ctx->last_char = data[size-1];
i_stream_skip(ctx->input, size);
}
(void)o_stream_nfinish(ctx->output);
if (ftruncate(ctx->mbox->mbox_fd, (off_t)ctx->mail_offset) < 0)
mbox_set_syscall_error(ctx->mbox, "ftruncate()");
- o_stream_seek(ctx->output, ctx->mail_offset);
+ (void)o_stream_seek(ctx->output, ctx->mail_offset);
ctx->mail_offset = (uoff_t)-1;
}
static MODULE_CONTEXT_DEFINE_INIT(mbox_mailbox_list_module,
&mailbox_list_module_register);
-int mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function)
+void mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function)
{
i_assert(function != NULL);
"%s failed with mbox file %s: %m%s", function,
mailbox_get_path(&mbox->box), toobig_error);
}
- return -1;
}
static const char *
extern const char *mbox_hide_headers[], *mbox_save_drop_headers[];
extern unsigned int mbox_hide_headers_count, mbox_save_drop_headers_count;
-int mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function);
+void mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function);
struct mailbox_sync_context *
mbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
mbox_sync_index_update_ext_header(mbox, trans);
ret = mail_index_transaction_commit(&trans);
}
- mbox_unlock(mbox, lock_id);
+ (void)mbox_unlock(mbox, lock_id);
return ret;
-
}
int mbox_sync_has_changed(struct mbox_mailbox *mbox, bool leave_dirty)
static void pop3c_client_ioloop_changed(struct pop3c_client *client)
{
if (client->to != NULL)
- io_loop_move_timeout(&client->to);
+ client->to = io_loop_move_timeout(&client->to);
if (client->io != NULL)
client->io = io_loop_move_io(&client->io);
if (client->output != NULL)
struct raw_mailbox *mbox = (struct raw_mailbox *)mail->box;
const struct stat *st;
- if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE)
- return mail_set_aborted(mail);
+ if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) {
+ mail_set_aborted(mail);
+ return -1;
+ }
mail->transaction->stats.fstat_lookup_count++;
st = i_stream_stat(mail->box->input, TRUE);
void mail_search_build_add_all(struct mail_search_args *args)
{
- mail_search_build_add(args, SEARCH_ALL);
+ (void)mail_search_build_add(args, SEARCH_ALL);
}
void mail_search_build_add_seqset(struct mail_search_args *args,
/* Returns TRUE if everything should already be in memory after this call. */
bool mail_prefetch(struct mail *mail);
-int mail_set_aborted(struct mail *mail);
+void mail_set_aborted(struct mail *mail);
void mail_set_expunged(struct mail *mail);
void mail_set_seq_saving(struct mail *mail, uint32_t seq);
void mailbox_set_deleted(struct mailbox *box);
return p->v.get_header_stream(mail, headers, stream_r);
}
-int mail_set_aborted(struct mail *mail)
+void mail_set_aborted(struct mail *mail)
{
mail_storage_set_error(mail->box->storage, MAIL_ERROR_NOTPOSSIBLE,
"Mail field not cached");
- return -1;
}
int mail_get_stream(struct mail *mail, struct message_size *hdr_size,
{
struct mail_private *p = (struct mail_private *)mail;
- if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
- return mail_set_aborted(mail);
+ if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) {
+ mail_set_aborted(mail);
+ return -1;
+ }
return p->v.get_stream(mail, TRUE, hdr_size, body_size, stream_r);
}
{
struct mail_private *p = (struct mail_private *)mail;
- if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
- return mail_set_aborted(mail);
+ if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) {
+ mail_set_aborted(mail);
+ return -1;
+ }
return p->v.get_stream(mail, FALSE, hdr_size, NULL, stream_r);
}
void mailbox_get_seq_range(struct mailbox *box, uint32_t uid1, uint32_t uid2,
uint32_t *seq1_r, uint32_t *seq2_r)
{
- mail_index_lookup_seq_range(box->view, uid1, uid2, seq1_r, seq2_r);
+ (void)mail_index_lookup_seq_range(box->view, uid1, uid2, seq1_r, seq2_r);
}
void mailbox_get_uid_range(struct mailbox *box,
}
}
- i_snprintf(buf, sizeof(buf), "%08x", uid_validity);
+ if (i_snprintf(buf, sizeof(buf), "%08x", uid_validity) < 0)
+ i_unreached();
if (pwrite_full(fd, buf, strlen(buf), 0) < 0)
i_error("write(%s) failed: %m", path);
if (close(fd) < 0)
/* fast path succeeded. write the current value to the main
uidvalidity file. */
- i_snprintf(buf, sizeof(buf), "%08x", cur_value);
+ if (i_snprintf(buf, sizeof(buf), "%08x", cur_value) < 0)
+ i_unreached();
if (pwrite_full(fd, buf, strlen(buf), 0) < 0)
i_error("write(%s) failed: %m", path);
if (close(fd) < 0)
i_assert(current_block->left >= size);
/* we've already reserved the space, now we just mark it used */
- t_malloc_real(size, TRUE);
+ (void)t_malloc_real(size, TRUE);
}
void t_buffer_alloc_last_full(void)
{
if (last_buffer_block != NULL)
- t_malloc_real(last_buffer_size, TRUE);
+ (void)t_malloc_real(last_buffer_size, TRUE);
}
void data_stack_set_clean_after_pop(bool enable ATTR_UNUSED)
last_buffer_block = NULL;
last_buffer_size = 0;
- t_push();
+ (void)t_push();
}
void data_stack_deinit(void)
{
- t_pop();
+ (void)t_pop();
if (frame_pos != BLOCK_FRAME_COUNT-1)
i_panic("Missing t_pop() call");
for (i = 0; i < old_size; i++) {
node = &old_nodes[i];
if (node->key != NULL) {
- hash_table_insert_node(table, node->key,
- node->value, FALSE);
+ (void)hash_table_insert_node(table, node->key,
+ node->value, FALSE);
}
for (node = node->next; node != NULL; node = next) {
next = node->next;
if (node->key != NULL) {
- hash_table_insert_node(table, node->key,
- node->value, FALSE);
+ (void)hash_table_insert_node(table, node->key,
+ node->value, FALSE);
}
free_node(table, node);
}
{
static char hostname[256], pid[MAX_INT_STRLEN];
- if (gethostname(hostname, sizeof(hostname)-1) == -1)
- i_strocpy(hostname, "unknown", sizeof(hostname));
+ if (gethostname(hostname, sizeof(hostname)-1) == -1) {
+ if (i_strocpy(hostname, "unknown", sizeof(hostname)) < 0)
+ i_unreached();
+ }
hostname[sizeof(hostname)-1] = '\0';
my_hostname = hostname;
/* allow calling hostpid_init() multiple times to reset hostname */
i_free_and_null(my_domain);
- i_strocpy(pid, dec2str(getpid()), sizeof(pid));
+ if (i_strocpy(pid, dec2str(getpid()), sizeof(pid)) < 0)
+ i_unreached();
my_pid = pid;
}
{
char buf[MAX_INT_STRLEN + 6 + 2];
- i_snprintf(buf, sizeof(buf), "%lu.%06u ",
- (unsigned long)ioloop_timeval.tv_sec,
- (unsigned int)ioloop_timeval.tv_usec);
+ if (i_snprintf(buf, sizeof(buf), "%lu.%06u ",
+ (unsigned long)ioloop_timeval.tv_sec,
+ (unsigned int)ioloop_timeval.tv_usec) < 0)
+ i_unreached();
rawlog_write(rstream, buf, strlen(buf));
}
memcpy(&ctx->buffer[used], data, free);
data = (const unsigned char *) data + free;
size -= free;
- body(ctx, ctx->buffer, 64);
+ (void)body(ctx, ctx->buffer, 64);
}
if (size >= 64) {
if (free < 8) {
memset(&ctx->buffer[used], 0, free);
- body(ctx, ctx->buffer, 64);
+ (void)body(ctx, ctx->buffer, 64);
used = 0;
free = 64;
}
ctx->buffer[62] = ctx->hi >> 16;
ctx->buffer[63] = ctx->hi >> 24;
- body(ctx, ctx->buffer, 64);
+ (void)body(ctx, ctx->buffer, 64);
result[0] = ctx->a;
result[1] = ctx->a >> 8;
memcpy(&ctx->buffer[used], data, free);
data = (const unsigned char *) data + free;
size -= free;
- body(ctx, ctx->buffer, 64);
+ (void)body(ctx, ctx->buffer, 64);
}
if (size >= 64) {
if (free < 8) {
memset(&ctx->buffer[used], 0, free);
- body(ctx, ctx->buffer, 64);
+ (void)body(ctx, ctx->buffer, 64);
used = 0;
free = 64;
}
ctx->buffer[62] = ctx->hi >> 16;
ctx->buffer[63] = ctx->hi >> 24;
- body(ctx, ctx->buffer, 64);
+ (void)body(ctx, ctx->buffer, 64);
result[0] = ctx->a;
result[1] = ctx->a >> 8;
point_r->dev = mnt->dev;
point_r->block_size = st.st_blksize;
}
- mountpoint_iter_deinit(&iter);
+ if (mountpoint_iter_deinit(&iter) < 0 && mnt == NULL)
+ return -1;
return mnt != NULL ? 1 : 0;
#endif
}
nfs_flush_chown_uid(path);
}
-bool nfs_flush_attr_cache_fd_locked(const char *path ATTR_UNUSED,
+void nfs_flush_attr_cache_fd_locked(const char *path ATTR_UNUSED,
int fd ATTR_UNUSED)
{
#ifdef __FreeBSD__
/* FreeBSD doesn't flush attribute cache with fcntl(), so we have
to do it ourself. */
- return nfs_flush_fchown_uid(path, fd);
+ (void)nfs_flush_fchown_uid(path, fd);
#else
/* Linux and Solaris are fine. */
- return TRUE;
#endif
}
p = strrchr(path, '/');
T_BEGIN {
if (p == NULL)
- nfs_flush_file_handle_cache_dir(".", TRUE);
+ (void)nfs_flush_file_handle_cache_dir(".", TRUE);
else
- nfs_flush_file_handle_cache_dir(t_strdup_until(path, p),
- TRUE);
+ (void)nfs_flush_file_handle_cache_dir(t_strdup_until(path, p),
+ TRUE);
} T_END;
}
/* Flush attribute cache for a fcntl locked file descriptor. If locking flushes
the attribute cache with the running OS, this function does nothing.
The given path is used only for logging. */
-bool nfs_flush_attr_cache_fd_locked(const char *path, int fd);
+void nfs_flush_attr_cache_fd_locked(const char *path, int fd);
/* Flush file handle cache for given file. */
void nfs_flush_file_handle_cache(const char *path);
return FALSE;
}
-unsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
- uint32_t seq1, uint32_t seq2)
+void seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
+ uint32_t seq1, uint32_t seq2)
+{
+ (void)seq_range_array_remove_range_count(array, seq1, seq2);
+}
+
+void seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src)
+{
+ (void)seq_range_array_remove_seq_range_count(dest, src);
+}
+
+unsigned int seq_range_array_remove_range_count(ARRAY_TYPE(seq_range) *array,
+ uint32_t seq1, uint32_t seq2)
{
const struct seq_range *data;
unsigned int idx, idx2, count, remove_count = 0;
return remove_count;
}
-unsigned int seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src)
+unsigned int
+seq_range_array_remove_seq_range_count(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src)
{
unsigned int ret = 0;
const struct seq_range *src_range;
array_foreach(src, src_range) {
- ret += seq_range_array_remove_range(dest, src_range->seq1,
- src_range->seq2);
+ ret += seq_range_array_remove_range_count(dest, src_range->seq1,
+ src_range->seq2);
}
return ret;
}
-unsigned int
-seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src)
+void seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src)
{
const struct seq_range *src_range;
unsigned int i, count, ret = 0;
src_range = array_get(src, &count);
for (i = 0; i < count; i++) {
if (last_seq + 1 < src_range[i].seq1) {
- ret += seq_range_array_remove_range(dest, last_seq + 1,
- src_range[i].seq1 - 1);
+ ret += seq_range_array_remove_range_count(dest,
+ last_seq + 1, src_range[i].seq1 - 1);
}
last_seq = src_range[i].seq2;
}
if (last_seq != (uint32_t)-1) {
- ret += seq_range_array_remove_range(dest, last_seq + 1,
- (uint32_t)-1);
+ ret += seq_range_array_remove_range_count(dest, last_seq + 1,
+ (uint32_t)-1);
}
- return ret;
}
bool seq_range_exists(const ARRAY_TYPE(seq_range) *array, uint32_t seq)
void seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
/* Remove the given sequrence from range. Returns TRUE if it was found. */
bool seq_range_array_try_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
+/* Remove a sequence range. */
+void seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
+ uint32_t seq1, uint32_t seq2);
+void seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src);
/* Remove a sequence range. Returns number of sequences actually removed. */
-unsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
- uint32_t seq1, uint32_t seq2);
-unsigned int seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src);
-/* Remove sequences from dest that don't exist in src.
- Returns the number of sequences actually removed. */
+unsigned int seq_range_array_remove_range_count(ARRAY_TYPE(seq_range) *array,
+ uint32_t seq1, uint32_t seq2);
unsigned int
-seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
- const ARRAY_TYPE(seq_range) *src);
+seq_range_array_remove_seq_range_count(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src);
+/* Remove sequences from dest that don't exist in src. */
+void seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
+ const ARRAY_TYPE(seq_range) *src);
/* Returns TRUE if sequence exists in the range. */
bool seq_range_exists(const ARRAY_TYPE(seq_range) *array,
uint32_t seq) ATTR_PURE;
str_truncate(str, 0);
str_truncate(dest, 0);
base64_encode(buf, max, str);
- base64_decode(str_data(str), str_len(str), NULL, dest);
+ test_assert(base64_decode(str_data(str), str_len(str), NULL, dest) >= 0);
test_assert(str_len(dest) == max &&
memcmp(buf, str_data(dest), max) == 0);
}
bool success;
for (i = 0; i < N_ELEMENTS(input); i++) {
- net_addr2ip(input[i].ip, &ip);
- net_addr2ip(input[i].net, &net_ip);
+ test_assert(net_addr2ip(input[i].ip, &ip) == 0);
+ test_assert(net_addr2ip(input[i].net, &net_ip) == 0);
success = net_is_in_network(&ip, &net_ip, input[i].bits) ==
input[i].ret;
test_out(t_strdup_printf("net_is_in_network(%u)", i), success);
size = (rand() % MAX_BUFSIZE) + 1;
random_fill_weak(randbuf, size);
memcpy(buf, randbuf, size);
- (void)o_stream_send(output, buf, size);
+ test_assert(o_stream_send(output, buf, size) > 0);
for (i = 0; i < 10; i++) {
offset = rand() % (MAX_BUFSIZE*3);
size = (rand() % MAX_BUFSIZE) + 1;
random_fill_weak(randbuf, size);
memcpy(buf + offset, randbuf, size);
- o_stream_pwrite(output, randbuf, size, offset);
+ test_assert(o_stream_pwrite(output, randbuf, size, offset) == 0);
if (rand() % 10 == 0)
- (void)o_stream_flush(output);
+ test_assert(o_stream_flush(output) > 0);
}
- (void)o_stream_flush(output);
+ test_assert(o_stream_flush(output) > 0);
o_stream_uncork(output);
ret = pread(fd, buf2, sizeof(buf2), 0);
if (ret < 0)
shadowbuf[seq1] = 0;
break;
case 3:
- ret = seq_range_array_remove_range(&range, seq1, seq2);
+ ret = seq_range_array_remove_range_count(&range, seq1, seq2);
for (ret2 = 0; seq1 <= seq2; seq1++) {
if (shadowbuf[seq1] != 0) {
ret2++;
static struct log_connection *log_connections = NULL;
static ARRAY_DEFINE(logs_by_fd, struct log_connection *);
+static void log_connection_destroy(struct log_connection *log);
+
static struct log_client *log_client_get(struct log_connection *log, pid_t pid)
{
struct log_client *client;
}
}
-struct log_connection *
-log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd)
+void log_connection_create(struct log_error_buffer *errorbuf,
+ int fd, int listen_fd)
{
struct log_connection *log;
DLLIST_PREPEND(&log_connections, log);
log_connection_input(log);
- return log;
}
-void log_connection_destroy(struct log_connection *log)
+static void log_connection_destroy(struct log_connection *log)
{
struct hash_iterate_context *iter;
void *key, *value;
#ifndef LOG_CONNECTION_H
#define LOG_CONNECTION_H
-struct log_connection *
-log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd);
-void log_connection_destroy(struct log_connection *log);
+struct log_connection;
+
+void log_connection_create(struct log_error_buffer *errorbuf,
+ int fd, int listen_fd);
void log_connections_init(void);
void log_connections_deinit(void);
return;
}
- client_unref(&client);
+ (void)client_unref(&client);
}
int client_auth_begin(struct client *client, const char *mech_name,
const char *user)
{
if (!login_proxy_state_try_notify(state, user))
- login_proxy_state_try_notify(state, user);
+ (void)login_proxy_state_try_notify(state, user);
}
i_free(proxy);
client->login_proxy = NULL;
- client_unref(&client);
+ (void)client_unref(&client);
}
void login_proxy_free(struct login_proxy **_proxy)
} else {
proxy->sslout_size += ret;
if (!corked) {
- net_set_cork(proxy->fd_ssl, TRUE);
- corked = TRUE;
+ if (net_set_cork(proxy->fd_ssl, TRUE) == 0)
+ corked = TRUE;
}
ssl_write(proxy);
}
}
if (corked)
- net_set_cork(proxy->fd_ssl, FALSE);
+ (void)net_set_cork(proxy->fd_ssl, FALSE);
ssl_proxy_unref(proxy);
}
if (proxy->sslout_size == 0)
ssl_set_io(proxy, SSL_REMOVE_OUTPUT);
else {
- net_set_cork(proxy->fd_ssl, TRUE);
+ (void)net_set_cork(proxy->fd_ssl, TRUE);
ssl_write(proxy);
- net_set_cork(proxy->fd_ssl, FALSE);
+ (void)net_set_cork(proxy->fd_ssl, FALSE);
}
}
(void)net_disconnect(proxy->fd_plain);
if (proxy->client != NULL)
- client_unref(&proxy->client);
+ (void)client_unref(&proxy->client);
ssl_proxy_unref(proxy);
}
if (fd != -1) {
VA_COPY(args2, args);
str = t_strdup_vprintf(format, args2);
- write_full(fd, str, strlen(str));
+ (void)write_full(fd, str, strlen(str));
(void)close(fd);
}
}
services->set->instance_name);
if (ret == 0) {
/* duplicate instance names. allow without warning.. */
- master_instance_list_update(list, services->set->base_dir);
+ (void)master_instance_list_update(list, services->set->base_dir);
}
if (to_instance != NULL)
service_list_anvil_discard_input(service_anvil_global);
else {
service = service_lookup_type(service_list, SERVICE_TYPE_ANVIL);
- service_process_create(service);
+ (void)service_process_create(service);
}
}
process->refcount++;
}
-int service_process_unref(struct service_process *process)
+void service_process_unref(struct service_process *process)
{
i_assert(process->refcount > 0);
if (--process->refcount > 0)
- return TRUE;
+ return;
i_assert(process->destroyed);
-
i_free(process);
- return FALSE;
}
static const char *
void service_process_destroy(struct service_process *process);
void service_process_ref(struct service_process *process);
-int service_process_unref(struct service_process *process);
+void service_process_unref(struct service_process *process);
void service_process_log_status_error(struct service_process *process,
int status);
bool subscriptions)
{
const char *value;
- char env_name[20];
+ char env_name[13+MAX_INT_STRLEN+1];
unsigned int i = 1;
value = mail_user_plugin_getenv(user, env_name_base);
while (value != NULL) {
add_autobox(user, value, subscriptions);
- i_snprintf(env_name, sizeof(env_name), "%s%d",
- env_name_base, ++i);
+ if (i_snprintf(env_name, sizeof(env_name), "%s%u",
+ env_name_base, ++i) < 0)
+ i_unreached();
value = mail_user_plugin_getenv(user, env_name);
}
}
{
ARRAY_TYPE(const_string) patterns;
const char *str;
- char set_name[20];
+ char set_name[6+MAX_INT_STRLEN+1];
unsigned int i;
t_array_init(&patterns, 16);
for (i = 2; str != NULL; i++) {
array_append(&patterns, &str, 1);
- i_snprintf(set_name, sizeof(set_name), "expire%u", i);
+ if (i_snprintf(set_name, sizeof(set_name), "expire%u", i) < 0)
+ i_unreached();
str = doveadm_plugin_getenv(set_name);
}
(void)array_append_space(&patterns);
if (ectx->iter != NULL) {
if (dict_iterate_deinit(&ectx->iter) < 0)
- i_error("Dictionary iteration failed");
+ i_error("expire: Dictionary iteration failed");
}
- dict_transaction_commit(&ectx->trans);
+ if (dict_transaction_commit(&ectx->trans) < 0)
+ i_error("expire: Dictionary commit failed");
dict_deinit(&ectx->dict);
hash_table_destroy(&ectx->users);
{
ARRAY_TYPE(const_string) patterns;
const char *str;
- char set_name[20];
+ char set_name[6+MAX_INT_STRLEN+1];
unsigned int i;
t_array_init(&patterns, 16);
for (i = 2; str != NULL; i++) {
array_append(&patterns, &str, 1);
- i_snprintf(set_name, sizeof(set_name), "expire%u", i);
+ if (i_snprintf(set_name, sizeof(set_name), "expire%u", i) < 0)
+ i_unreached();
str = mail_user_set_plugin_getenv(user->set, set_name);
}
(void)array_append_space(&patterns);
i_assert(backend->updating);
backend->updating = FALSE;
- if (ctx->lucene_opened)
- lucene_index_build_deinit(backend->index);
+ if (ctx->lucene_opened) {
+ if (lucene_index_build_deinit(backend->index) < 0)
+ ret = -1;
+ }
if (ctx->expunge_ctx != NULL) {
if (fts_expunge_log_append_commit(&ctx->expunge_ctx) < 0)
{
/* the next refresh is going to close the index anyway, so we might as
well do it now */
- fts_backend_lucene_refresh(_backend);
+ (void)fts_backend_lucene_refresh(_backend);
}
struct fts_backend fts_backend_lucene = {
o_stream_cork(output);
if (trie->hdr.used_file_size != 0)
- o_stream_seek(output, trie->hdr.used_file_size);
+ (void)o_stream_seek(output, trie->hdr.used_file_size);
else
o_stream_nsend(output, &trie->hdr, sizeof(trie->hdr));
}
ret = squat_trie_write_lock(ctx);
if (ret == 0) {
trie->hdr.used_file_size = output->offset;
- o_stream_seek(output, 0);
+ (void)o_stream_seek(output, 0);
o_stream_nsend(output, &trie->hdr, sizeof(trie->hdr));
}
if (o_stream_nfinish(output) < 0) {
}
if (uidlist->hdr.indexid != uidlist->trie->hdr.indexid) {
/* see if trie was recreated */
- squat_trie_refresh(uidlist->trie);
+ (void)squat_trie_refresh(uidlist->trie);
}
if (uidlist->hdr.indexid != uidlist->trie->hdr.indexid) {
squat_uidlist_set_corrupted(uidlist, "wrong indexid");
return -1;
if (!ctx->output->closed) {
- o_stream_seek(ctx->output, 0);
+ (void)o_stream_seek(ctx->output, 0);
o_stream_nsend(ctx->output,
&ctx->build_hdr, sizeof(ctx->build_hdr));
- o_stream_seek(ctx->output, ctx->build_hdr.used_file_size);
+ (void)o_stream_seek(ctx->output, ctx->build_hdr.used_file_size);
}
if (o_stream_nfinish(ctx->output) < 0) {
&ctx->new_block_offsets,
&ctx->new_block_end_indexes,
FALSE);
- o_stream_seek(ctx->output, 0);
+ (void)o_stream_seek(ctx->output, 0);
o_stream_nsend(ctx->output, &ctx->build_ctx->build_hdr,
sizeof(ctx->build_ctx->build_hdr));
- o_stream_seek(ctx->output,
- ctx->build_ctx->build_hdr.used_file_size);
+ (void)o_stream_seek(ctx->output,
+ ctx->build_ctx->build_hdr.used_file_size);
if (ctx->uidlist->corrupted)
ret = -1;
}
for (; mask <= 128; mask <<= 1, idx++) {
if ((old_list_idx & mask) != 0) {
- squat_uidlist_build_add_uid(ctx,
- uid_list_idx, idx);
+ (void)squat_uidlist_build_add_uid(ctx,
+ uid_list_idx, idx);
}
}
}
i_array_init(&relative_uids, 128);
i_array_init(&dest_uids, 128);
- squat_uidlist_get(uidlist, uid_list_idx, &relative_uids);
+ if (squat_uidlist_get(uidlist, uid_list_idx, &relative_uids) < 0)
+ ret = -1;
parent_idx = 0;
rel_range = array_get(&relative_uids, &rel_count);
}
if (scores != NULL) {
i_assert(scores->uid == _mail->uid);
- i_snprintf(fmail->score, sizeof(fmail->score),
- "%f", scores->score);
+ (void)i_snprintf(fmail->score, sizeof(fmail->score),
+ "%f", scores->score);
+
*value_r = fmail->score;
return 0;
}
command_unregister("DELETEACL");
command_unregister("LISTRIGHTS");
- imap_client_created_hook_set(next_hook_client_created);
+ (void)imap_client_created_hook_set(next_hook_client_created);
}
const char *imap_acl_plugin_dependencies[] = { "acl", NULL };
command_unregister("GETQUOTA");
command_unregister("SETQUOTA");
- imap_client_created_hook_set(next_hook_client_created);
+ (void)imap_client_created_hook_set(next_hook_client_created);
}
const char *imap_quota_plugin_dependencies[] = { "quota", NULL };
{
command_unregister("COMPRESS");
- imap_client_created_hook_set(next_hook_client_created);
+ (void)imap_client_created_hook_set(next_hook_client_created);
}
const char *imap_zlib_plugin_dependencies[] = { "zlib", NULL };
static int maildirsize_update(struct maildir_quota_root *root,
int count_diff, int64_t bytes_diff)
{
- char str[MAX_INT_STRLEN*2 + 2];
+ char str[MAX_INT_STRLEN*2 + 2 + 1];
int ret = 0;
if (count_diff == 0 && bytes_diff == 0)
a while, and sooner if corruption causes calculations to go
over quota. This is also how Maildir++ spec specifies it should be
done.. */
- i_snprintf(str, sizeof(str), "%lld %d\n",
- (long long)bytes_diff, count_diff);
+ if (i_snprintf(str, sizeof(str), "%lld %d\n",
+ (long long)bytes_diff, count_diff) < 0)
+ i_unreached();
if (write_full(root->fd, str, strlen(str)) < 0) {
ret = -1;
if (errno == ESTALE) {
const char **error_r)
{
struct quota_settings *quota_set;
- char root_name[6 + MAX_INT_STRLEN];
+ char root_name[5 + MAX_INT_STRLEN + 1];
const char *env, *error;
unsigned int i;
pool_t pool;
quota_set->quota_exceeded_msg = DEFAULT_QUOTA_EXCEEDED_MSG;
p_array_init("a_set->root_sets, pool, 4);
- i_strocpy(root_name, "quota", sizeof(root_name));
+ if (i_strocpy(root_name, "quota", sizeof(root_name)) < 0)
+ i_unreached();
for (i = 2;; i++) {
env = mail_user_plugin_getenv(user, root_name);
if (env == NULL || *env == '\0')
pool_unref(&pool);
return -1;
}
- i_snprintf(root_name, sizeof(root_name), "quota%d", i);
+ if (i_snprintf(root_name, sizeof(root_name), "quota%d", i) < 0)
+ i_unreached();
}
if (array_count("a_set->root_sets) == 0) {
pool_unref(&pool);
conn = i_new(struct stats_connection, 1);
conn->refcount = 1;
conn->path = i_strdup(path);
- stats_connection_open(conn);
+ (void)stats_connection_open(conn);
return conn;
}
bbox = virtual_backend_box_lookup(mbox, vrec->mailbox_id);
vmail->backend_mail = backend_mail_find(vmail, bbox->box);
if (vmail->backend_mail == NULL)
- virtual_mail_set_backend_mail(mail, bbox);
+ (void)virtual_mail_set_backend_mail(mail, bbox);
vmail->lost = !mail_set_uid(vmail->backend_mail, vrec->real_uid);
memset(&vmail->imail.data, 0, sizeof(vmail->imail.data));
p_clear(vmail->imail.data_pool);
if (count1 > 0 && count2 > 0) {
t_array_init(&temp_uids, count1);
array_append_array(&temp_uids, &bbox->sync_pending_removes);
- if (seq_range_array_remove_seq_range(
+ if (seq_range_array_remove_seq_range_count(
&bbox->sync_pending_removes, &added_uids) > 0) {
seq_range_array_remove_seq_range(&added_uids,
&temp_uids);
ret = read(fd, buf, sizeof(buf)-1);
if (ret > 0) {
buf[ret] = '\0';
- str_lcase(buf);
+ (void)str_lcase(buf);
match = strstr(buf, " ok begin compression.") != NULL ||
strstr(buf, " compress deflate") != NULL;
}
flush = zstream->ostream.corked || zstream->gz ?
Z_NO_FLUSH : Z_SYNC_FLUSH;
- if (!zstream->header_sent)
- o_stream_zlib_send_gz_header(zstream);
+ if (!zstream->header_sent) {
+ if (o_stream_zlib_send_gz_header(zstream) < 0)
+ return -1;
+ }
zs->next_in = (void *)data;
zs->avail_in = size;
if (zstream->flushed)
return 0;
- if (!zstream->header_sent)
- o_stream_zlib_send_gz_header(zstream);
+ if (!zstream->header_sent) {
+ if (o_stream_zlib_send_gz_header(zstream) < 0)
+ return -1;
+ }
if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
return ret;
if (input.username == NULL)
i_fatal("USER environment missing");
if ((value = getenv("IP")) != NULL)
- net_addr2ip(value, &input.remote_ip);
+ (void)net_addr2ip(value, &input.remote_ip);
if ((value = getenv("LOCAL_IP")) != NULL)
- net_addr2ip(value, &input.local_ip);
+ (void)net_addr2ip(value, &input.local_ip);
input_base64 = getenv("CLIENT_INPUT");
input_buf = input_base64 == NULL ? NULL :
static void client_default_destroy(struct client *client, const char *reason)
{
if (client->seen_change_count > 0)
- client_update_mails(client);
+ (void)client_update_mails(client);
if (!client->disconnected) {
if (reason == NULL)
client->to_idle = timeout_add(0, client_destroy_timeout, client);
}
-int client_send_line(struct client *client, const char *fmt, ...)
+void client_send_line(struct client *client, const char *fmt, ...)
{
va_list va;
ssize_t ret;
if (client->output->closed)
- return -1;
+ return;
va_start(va, fmt);
if (ret >= 0) {
if (o_stream_get_buffer_used_size(client->output) <
OUTBUF_THROTTLE_SIZE) {
- ret = 1;
client->last_output = ioloop_time;
} else {
- ret = 0;
if (client->io != NULL) {
/* no more input until client has read
our output */
}
}
}
-
va_end(va);
- return (int)ret;
}
void client_send_storage_error(struct client *client)
#define MSGS_BITMASK_SIZE(client) \
(((client)->messages_count + (CHAR_BIT-1)) / CHAR_BIT)
+#define POP3_CLIENT_OUTPUT_FULL(client) \
+ ((client)->io == NULL)
+
struct pop3_client_vfuncs {
void (*destroy)(struct client *client, const char *reason);
void client_disconnect(struct client *client, const char *reason);
/* Send a line of data to client */
-int client_send_line(struct client *client, const char *fmt, ...)
+void client_send_line(struct client *client, const char *fmt, ...)
ATTR_FORMAT(2, 3);
void client_send_storage_error(struct client *client);
static void cmd_list_callback(struct client *client)
{
struct cmd_list_context *ctx = client->cmd_context;
- int ret = 1;
for (; ctx->msgnum != client->messages_count; ctx->msgnum++) {
- if (ret == 0) {
+ if (POP3_CLIENT_OUTPUT_FULL(client)) {
/* buffer full */
return;
}
continue;
}
- ret = client_send_line(client, "%u %"PRIuUOFF_T, ctx->msgnum+1,
- client->message_sizes[ctx->msgnum]);
- if (ret < 0)
+ client_send_line(client, "%u %"PRIuUOFF_T, ctx->msgnum+1,
+ client->message_sizes[ctx->msgnum]);
+ if (client->output->closed)
break;
}
mail_update_flags(mail, MODIFY_REMOVE, MAIL_SEEN);
(void)mailbox_search_deinit(&search_ctx);
- mailbox_transaction_commit(&client->trans);
+ (void)mailbox_transaction_commit(&client->trans);
client->trans = mailbox_transaction_begin(client->mailbox, 0);
}
tab[0].value = t_strdup_printf("%u", client->uid_validity);
if ((client->uidl_keymask & UIDL_UID) != 0) {
- i_snprintf(uid_str, sizeof(uid_str), "%u",
- mail->uid);
+ if (i_snprintf(uid_str, sizeof(uid_str), "%u",
+ mail->uid) < 0)
+ i_unreached();
tab[1].value = uid_str;
}
if ((client->uidl_keymask & UIDL_MD5) != 0) {
list_uidls_saved_iter(struct client *client, struct cmd_uidl_context *ctx)
{
bool found = FALSE;
- int ret;
while (ctx->msgnum < client->messages_count) {
uint32_t msgnum = ctx->msgnum++;
}
found = TRUE;
- ret = client_send_line(client,
- ctx->list_all ? "%u %s" : "+OK %u %s",
- msgnum+1, client->message_uidls[msgnum]);
- if (ret < 0 || !ctx->list_all)
+ client_send_line(client,
+ ctx->list_all ? "%u %s" : "+OK %u %s",
+ msgnum+1, client->message_uidls[msgnum]);
+ if (client->output->closed || !ctx->list_all)
break;
- if (ret == 0) {
+ if (POP3_CLIENT_OUTPUT_FULL(client)) {
/* output is being buffered, continue when there's
more space */
return FALSE;
static bool list_uids_iter(struct client *client, struct cmd_uidl_context *ctx)
{
string_t *str;
- int ret;
bool permanent_uidl, found = FALSE;
if (client->message_uidls != NULL)
if (client->set->pop3_save_uidl && !permanent_uidl)
mail_update_pop3_uidl(ctx->mail, str_c(str));
- ret = client_send_line(client,
- ctx->list_all ? "%u %s" : "+OK %u %s",
- msgnum+1, str_c(str));
- if (ret < 0)
+ client_send_line(client, ctx->list_all ? "%u %s" : "+OK %u %s",
+ msgnum+1, str_c(str));
+ if (client->output->closed)
break;
- if (ret == 0 && ctx->list_all) {
+ if (POP3_CLIENT_OUTPUT_FULL(client) && ctx->list_all) {
/* output is being buffered, continue when there's
more space */
return FALSE;
case -2:
/* buffer full */
i_error("Client sent too long line");
- notify_input_error(conn);
+ (void)notify_input_error(conn);
return;
case -1:
/* disconnected */
return -1;
}
if (priority != REPLICATION_PRIORITY_SYNC)
- replicator_queue_add(conn->queue, args[1], priority);
+ (void)replicator_queue_add(conn->queue, args[1], priority);
else if (args[3] == NULL || str_to_uint(args[3], &id) < 0) {
i_error("notify client sent invalid sync id: %s", line);
return -1;
}
mail_server_conn = mail_server_connection_create(conn->fd);
} else {
- client_create(conn->fd);
+ (void)client_create(conn->fd);
}
master_service_client_connection_accept(conn);
}
dec2str(getppid())));
ioloop = io_loop_create();
- rawlog_proxy_create(0, 1, sfd[0], path, flags);
+ (void)rawlog_proxy_create(0, 1, sfd[0], path, flags);
io_loop_run(ioloop);
io_loop_destroy(&ioloop);