Skip to content

Commit

Permalink
global: Rename array_first and array_last to array_front and back
Browse files Browse the repository at this point in the history
This is more consistent with other languages
  • Loading branch information
cmouse committed Jan 15, 2019
1 parent c35d4ef commit 505d07d
Show file tree
Hide file tree
Showing 130 changed files with 209 additions and 209 deletions.
2 changes: 1 addition & 1 deletion src/auth/auth-request-handler.c
Expand Up @@ -859,7 +859,7 @@ void auth_request_handler_flush_failures(bool flush_all)
return;
}

auth_requests = array_first_modifiable(&auth_failures_arr);
auth_requests = array_front_modifiable(&auth_failures_arr);
/* count the number of requests that we need to flush */
for (i = 0; i < count; i++) {
auth_request = auth_requests[aqueue_idx(auth_failures, i)];
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth-settings.c
Expand Up @@ -380,7 +380,7 @@ auth_settings_set_self_ips(struct auth_settings *set, pool_t pool,
array_append(&ips_array, ips, ips_count);
}
array_append_zero(&ips_array);
set->proxy_self_ips = array_first(&ips_array);
set->proxy_self_ips = array_front(&ips_array);
return TRUE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth-worker-server.c
Expand Up @@ -500,7 +500,7 @@ void auth_worker_server_deinit(void)
struct auth_worker_connection **connp, *conn;

while (array_count(&connections) > 0) {
connp = array_first_modifiable(&connections);
connp = array_front_modifiable(&connections);
conn = *connp;
auth_worker_destroy(&conn, "Shutting down", FALSE);
}
Expand Down
10 changes: 5 additions & 5 deletions src/auth/db-ldap.c
Expand Up @@ -544,7 +544,7 @@ db_ldap_find_request(struct ldap_connection *conn, int msgid,
if (count == 0)
return NULL;

requests = array_first(&conn->request_array);
requests = array_front(&conn->request_array);
for (i = 0; i < count; i++) {
request = requests[aqueue_idx(conn->request_queue, i)];
if (request->msgid == msgid) {
Expand Down Expand Up @@ -651,7 +651,7 @@ ldap_request_send_subquery(struct ldap_connection *conn,
if (field->ldap_attr_name[0] == '\0') {
str_truncate(tmp_str, 0);
if (var_expand_with_funcs(tmp_str, field->value, table,
array_first(&var_funcs_table), &ctx, &error) <= 0) {
array_front(&var_funcs_table), &ctx, &error) <= 0) {
auth_request_log_error(auth_request,
AUTH_SUBSYS_DB,
"Failed to expand subquery %s: %s",
Expand All @@ -672,7 +672,7 @@ ldap_request_send_subquery(struct ldap_connection *conn,

request->request.msgid =
ldap_search(conn->ld, named_res->dn, LDAP_SCOPE_BASE,
NULL, array_first_modifiable(&ctx.attr_names), 0);
NULL, array_front_modifiable(&ctx.attr_names), 0);
if (request->request.msgid == -1) {
auth_request_log_error(auth_request, AUTH_SUBSYS_DB,
"ldap_search(dn=%s) failed: %s",
Expand Down Expand Up @@ -1326,7 +1326,7 @@ static void db_ldap_conn_close(struct ldap_connection *conn)
timeout_remove(&conn->to);

if (conn->pending_count != 0) {
requests = array_first(&conn->request_array);
requests = array_front(&conn->request_array);
for (i = 0; i < conn->pending_count; i++) {
request = requests[aqueue_idx(conn->request_queue, i)];

Expand Down Expand Up @@ -1467,7 +1467,7 @@ void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
}
}
array_append_zero(&ctx.attr_names);
*attr_names_r = array_first_modifiable(&ctx.attr_names);
*attr_names_r = array_front_modifiable(&ctx.attr_names);
}

static const struct var_expand_table *
Expand Down
2 changes: 1 addition & 1 deletion src/config/config-connection.c
Expand Up @@ -103,7 +103,7 @@ static int config_connection_request(struct config_connection *conn,
}
array_append_zero(&modules);
wanted_modules = array_count(&modules) == 1 ? NULL :
array_first(&modules);
array_front(&modules);

if (is_master) {
/* master reads configuration only when reloading settings */
Expand Down
8 changes: 4 additions & 4 deletions src/config/config-filter.c
Expand Up @@ -245,12 +245,12 @@ config_filter_find_all(struct config_filter_context *ctx, pool_t pool,
}
if (filter->service == NULL) {
array_append_zero(&service_names);
output_r->specific_services = array_first(&service_names);
output_r->specific_services = array_front(&service_names);
}

array_sort(&matches, config_filter_parser_cmp);
array_append_zero(&matches);
return array_first(&matches);
return array_front(&matches);
}

struct config_filter_parser *const *
Expand All @@ -265,7 +265,7 @@ config_filter_get_all(struct config_filter_context *ctx)
}
array_sort(&filters, config_filter_parser_cmp_rev);
array_append_zero(&filters);
return array_first(&filters);
return array_front(&filters);
}

struct config_filter_parser *const *
Expand Down Expand Up @@ -298,7 +298,7 @@ config_filter_find_subset(struct config_filter_context *ctx,
}
array_sort(&matches, config_filter_parser_cmp_rev);
array_append_zero(&matches);
return array_first(&matches);
return array_front(&matches);
}

static bool
Expand Down
4 changes: 2 additions & 2 deletions src/config/config-parser.c
Expand Up @@ -738,7 +738,7 @@ static int config_parse_finish(struct config_parser_context *ctx, const char **e

new_filter = config_filter_init(ctx->pool);
array_append_zero(&ctx->all_parsers);
config_filter_add_all(new_filter, array_first(&ctx->all_parsers));
config_filter_add_all(new_filter, array_front(&ctx->all_parsers));

if (ret < 0)
;
Expand Down Expand Up @@ -1108,7 +1108,7 @@ void config_parse_load_modules(void)
for (i = 0; all_roots[i] != NULL; i++)
array_push_back(&new_roots, &all_roots[i]);
array_append_zero(&new_roots);
all_roots = array_first(&new_roots);
all_roots = array_front(&new_roots);
roots_free_at_deinit = new_roots;
} else {
array_free(&new_roots);
Expand Down
2 changes: 1 addition & 1 deletion src/config/doveconf.c
Expand Up @@ -938,7 +938,7 @@ int main(int argc, char *argv[])
}
array_append_zero(&module_names);
wanted_modules = array_count(&module_names) == 1 ? NULL :
array_first(&module_names);
array_front(&module_names);

config_path = master_service_get_config_path(master_service);
/* use strcmp() instead of !=, because dovecot -n always gives us
Expand Down
4 changes: 2 additions & 2 deletions src/dict/dict-commands.c
Expand Up @@ -80,7 +80,7 @@ static void dict_connection_cmds_flush(struct dict_connection *conn)

dict_connection_ref(conn);
while (array_count(&conn->cmds) > 0) {
first_cmdp = array_first(&conn->cmds);
first_cmdp = array_front(&conn->cmds);
cmd = *first_cmdp;

i_assert(cmd->async_reply_id == 0);
Expand Down Expand Up @@ -659,7 +659,7 @@ static void dict_connection_cmd_output_more(struct dict_connection_cmd *cmd)
struct dict_connection_cmd *const *first_cmdp;

if (cmd->conn->minor_version < DICT_CLIENT_PROTOCOL_TIMINGS_MIN_VERSION) {
first_cmdp = array_first(&cmd->conn->cmds);
first_cmdp = array_front(&cmd->conn->cmds);
if (*first_cmdp != cmd)
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/director/director-connection.c
Expand Up @@ -942,7 +942,7 @@ director_cmd_host_hand_start(struct director_connection *conn,
conn->name);
hosts = mail_hosts_get(conn->dir->mail_hosts);
while (array_count(hosts) > 0) {
hostp = array_first(hosts);
hostp = array_front(hosts);
director_remove_host(conn->dir, NULL, NULL, *hostp);
}
} else if (remote_ring_completed == 0 && conn->dir->ring_handshaked) {
Expand Down
2 changes: 1 addition & 1 deletion src/director/director-request.c
Expand Up @@ -89,7 +89,7 @@ static void director_request_timeout(struct director *dir)
string_t *str = t_str_new(128);

while (array_count(&dir->pending_requests) > 0) {
requestp = array_first_modifiable(&dir->pending_requests);
requestp = array_front_modifiable(&dir->pending_requests);
request = *requestp;

if (request->create_time +
Expand Down
4 changes: 2 additions & 2 deletions src/director/director.c
Expand Up @@ -1465,7 +1465,7 @@ void director_deinit(struct director **_dir)
*_dir = NULL;

while (array_count(&dir->connections) > 0) {
connp = array_first(&dir->connections);
connp = array_front(&dir->connections);
conn = *connp;
director_connection_deinit(&conn, "Shutting down");
}
Expand All @@ -1481,7 +1481,7 @@ void director_deinit(struct director **_dir)
timeout_remove(&dir->to_remove_dirs);
timeout_remove(&dir->to_callback);
while (array_count(&dir->dir_hosts) > 0) {
hostp = array_first(&dir->dir_hosts);
hostp = array_front(&dir->dir_hosts);
host = *hostp;
director_host_free(&host);
}
Expand Down
4 changes: 2 additions & 2 deletions src/dns/dns-client.c
Expand Up @@ -71,9 +71,9 @@ static int dns_client_input_args(struct connection *client, const char *const *a
}
array_append_zero(&tmp);
e_debug(e->event(), "Resolve success: %s",
t_strarray_join(array_first(&tmp), ", "));
t_strarray_join(array_front(&tmp), ", "));
o_stream_nsend_str(client->output,
t_strarray_join(array_first(&tmp), "\t"));
t_strarray_join(array_front(&tmp), "\t"));
o_stream_nsend_str(client->output, "\n");
}
} else if (strcmp(args[0], "NAME") == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-cmd.c
Expand Up @@ -523,7 +523,7 @@ int doveadm_cmd_run_ver2(int argc, const char *const argv[],
}
i_assert(pargc == array_count(&opts)-1); /* opts is NULL-terminated */

while((c = getopt_long(argc, (char*const*)argv, str_c(optbuf), array_first(&opts), &li)) > -1) {
while((c = getopt_long(argc, (char*const*)argv, str_c(optbuf), array_front(&opts), &li)) > -1) {
switch(c) {
case 0:
for(unsigned int i = 0; i < array_count(&pargv); i++) {
Expand Down
6 changes: 3 additions & 3 deletions src/doveadm/doveadm-dsync.c
Expand Up @@ -223,7 +223,7 @@ mirror_get_remote_cmd_line(const char *const *argv,
}
array_push_back(&cmd_args, &p);
array_append_zero(&cmd_args);
*cmd_args_r = array_first(&cmd_args);
*cmd_args_r = array_front(&cmd_args);
}

static const char *const *
Expand Down Expand Up @@ -273,7 +273,7 @@ get_ssh_cmd_args(const char *host, const char *login, const char *mail_user)
array_push_back(&cmd_args, &value);
}
array_append_zero(&cmd_args);
return array_first(&cmd_args);
return array_front(&cmd_args);
}

static bool mirror_get_remote_cmd(struct dsync_cmd_context *ctx,
Expand Down Expand Up @@ -614,7 +614,7 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
t_strsplit_spaces(doveadm_settings->dsync_hashed_headers, " ,");
if (array_count(&ctx->exclude_mailboxes) > 0) {
/* array is NULL-terminated in init() */
set.exclude_mailboxes = array_first(&ctx->exclude_mailboxes);
set.exclude_mailboxes = array_front(&ctx->exclude_mailboxes);
}
doveadm_user_init_dsync(user);

Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-dump-index.c
Expand Up @@ -376,7 +376,7 @@ static void dump_keywords(struct mail_index *index)
if (count == 0)
return;

keywords = array_first(&index->keywords);
keywords = array_front(&index->keywords);
for (i = 0; i < count; i++)
printf("%3u = %s\n", i, keywords[kw_indexes[i]]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-kick.c
Expand Up @@ -71,7 +71,7 @@ kick_pid_want_kicked(struct kick_context *ctx, const struct kick_pid *k_pid,
const struct kick_user *user;

if (array_count(&k_pid->users) == 1) {
user = array_first(&k_pid->users);
user = array_front(&k_pid->users);
if (!user->kick_me)
return FALSE;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-mail-fetch.c
Expand Up @@ -606,7 +606,7 @@ cmd_fetch_box(struct fetch_cmd_context *ctx, const struct mailbox_info *info)

if (doveadm_mail_iter_init(&ctx->ctx, info, ctx->ctx.search_args,
ctx->wanted_fields,
array_first(&ctx->header_fields),
array_front(&ctx->header_fields),
FALSE,
&iter) < 0)
return -1;
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-mail-flags.c
Expand Up @@ -108,7 +108,7 @@ static void cmd_flags_init(struct doveadm_mail_cmd_context *_ctx,
}
if (array_count(&keywords) > 0 || ctx->modify_type == MODIFY_REPLACE) {
array_append_zero(&keywords);
ctx->keywords = array_first(&keywords);
ctx->keywords = array_front(&keywords);
}

_ctx->search_args = doveadm_mail_build_search_args(args+1);
Expand Down
4 changes: 2 additions & 2 deletions src/doveadm/doveadm-mail-server.c
Expand Up @@ -119,7 +119,7 @@ static void doveadm_cmd_callback(int exit_code, const char *error,

if (array_count(&server->queue) > 0) {
struct server_connection *conn;
char *const *usernamep = array_first(&server->queue);
char *const *usernamep = array_front(&server->queue);
char *username = *usernamep;

conn = doveadm_server_find_unused_conn(server);
Expand Down Expand Up @@ -337,7 +337,7 @@ static void doveadm_servers_destroy_all_connections(void)
while (array_count(&server->connections) > 0) {
struct server_connection *const *connp, *conn;

connp = array_first(&server->connections);
connp = array_front(&server->connections);
conn = *connp;
server_connection_destroy(&conn);
}
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-mail.c
Expand Up @@ -1139,7 +1139,7 @@ doveadm_cmd_ver2_to_mail_cmd_wrapper(struct doveadm_cmd_context *cctx)
array_append_array(&full_args, &pargv);

mctx->args = array_idx(&full_args, args_pos);
mctx->full_args = array_first(&full_args);
mctx->full_args = array_front(&full_args);

doveadm_mail_cmd_exec(mctx, wildcard_user);
doveadm_mail_cmd_free(mctx);
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-mailbox-list-iter.c
Expand Up @@ -108,7 +108,7 @@ doveadm_mailbox_list_iter_init_nsmask(struct doveadm_mail_cmd_context *ctx,
iter->only_selectable = TRUE;
iter->iter_flags = iter_flags;
iter->iter = mailbox_list_iter_init_namespaces(user->namespaces,
array_first(&iter->patterns),
array_front(&iter->patterns),
ns_mask, iter_flags);
return iter;
}
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-print-formatted.c
Expand Up @@ -64,7 +64,7 @@ static void doveadm_print_formatted_print(const char *value)
entry->value = value;

if (ctx.idx >= array_count(&ctx.headers)) {
if (var_expand(ctx.buf, ctx.format, array_first(&ctx.headers), &error) <= 0) {
if (var_expand(ctx.buf, ctx.format, array_front(&ctx.headers), &error) <= 0) {
i_error("Failed to expand print format '%s': %s",
ctx.format, error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/doveadm/doveadm-who.c
Expand Up @@ -28,7 +28,7 @@ static void who_user_ip(const struct who_user *user, struct ip_addr *ip_r)
if (array_count(&user->ips) == 0)
i_zero(ip_r);
else {
const struct ip_addr *ip = array_first(&user->ips);
const struct ip_addr *ip = array_front(&user->ips);
*ip_r = *ip;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/doveadm/dsync/dsync-brain-mailbox.c
Expand Up @@ -644,7 +644,7 @@ dsync_cache_fields_update(const struct dsync_mailbox *local_box,
if (array_count(&local_sorted) == 0) {
/* local has no cached fields. set them to same as remote. */
array_append_zero(&remote_sorted);
update->cache_updates = array_first(&remote_sorted);
update->cache_updates = array_front(&remote_sorted);
return;
}

Expand Down Expand Up @@ -689,7 +689,7 @@ dsync_cache_fields_update(const struct dsync_mailbox *local_box,
i_assert(li == local_count && ri == remote_count);
if (array_count(&changes) > 0) {
array_append_zero(&changes);
update->cache_updates = array_first(&changes);
update->cache_updates = array_front(&changes);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/doveadm/dsync/dsync-ibc-pipe.c
Expand Up @@ -111,7 +111,7 @@ dsync_ibc_pipe_pop_item(struct dsync_ibc_pipe *pipe, enum item_type type)
if (array_count(&pipe->item_queue) == 0)
return NULL;

item = array_first_modifiable(&pipe->item_queue);
item = array_front_modifiable(&pipe->item_queue);
i_assert(item->type == type);
pipe->pop_item = *item;
array_pop_front(&pipe->item_queue);
Expand All @@ -129,7 +129,7 @@ static bool dsync_ibc_pipe_try_pop_eol(struct dsync_ibc_pipe *pipe)
if (array_count(&pipe->item_queue) == 0)
return FALSE;

item = array_first(&pipe->item_queue);
item = array_front(&pipe->item_queue);
if (item->type != ITEM_END_OF_LIST)
return FALSE;

Expand Down Expand Up @@ -526,7 +526,7 @@ static void pipe_close_mail_streams(struct dsync_ibc_pipe *pipe)
struct item *item;

if (array_count(&pipe->item_queue) > 0) {
item = array_first_modifiable(&pipe->item_queue);
item = array_front_modifiable(&pipe->item_queue);
if (item->type == ITEM_MAIL &&
item->u.mail.input != NULL)
i_stream_unref(&item->u.mail.input);
Expand Down
4 changes: 2 additions & 2 deletions src/doveadm/dsync/dsync-mailbox-export.c
Expand Up @@ -745,7 +745,7 @@ dsync_mailbox_export_body_search_init(struct dsync_mailbox_exporter *exporter)
array_count(&instances->seqs) == 0)
continue;

uids = array_first(&instances->seqs);
uids = array_front(&instances->seqs);
seq = uids[0].seq1;
if (!instances->searched) {
instances->searched = TRUE;
Expand All @@ -762,7 +762,7 @@ dsync_mailbox_export_body_search_init(struct dsync_mailbox_exporter *exporter)
&const_guid);
continue;
}
uids = array_first(&instances->seqs);
uids = array_front(&instances->seqs);
seq = uids[0].seq1;
seq_range_array_add(&sarg->value.seqset, seq);
}
Expand Down

0 comments on commit 505d07d

Please sign in to comment.