From a12c5145b3018243909e5a4a7dddec07acfc12cc Mon Sep 17 00:00:00 2001 From: Eric Faurot Date: Thu, 14 May 2009 15:05:13 +0000 Subject: use the nitems() macro where appropriate ok gilles@, jacekm@ --- usr.sbin/smtpd/control.c | 6 +++--- usr.sbin/smtpd/enqueue.c | 4 ++-- usr.sbin/smtpd/lka.c | 6 +++--- usr.sbin/smtpd/mda.c | 6 +++--- usr.sbin/smtpd/mfa.c | 6 +++--- usr.sbin/smtpd/mta.c | 6 +++--- usr.sbin/smtpd/queue.c | 6 +++--- usr.sbin/smtpd/runner.c | 6 +++--- usr.sbin/smtpd/smtp.c | 6 +++--- usr.sbin/smtpd/smtp_session.c | 20 ++++++++++---------- usr.sbin/smtpd/smtpd.c | 18 +++++++++--------- 11 files changed, 45 insertions(+), 45 deletions(-) diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index b12c2e1ee92..af8dde4339d 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.24 2009/05/09 20:04:36 jacekm Exp $ */ +/* $OpenBSD: control.c,v 1.25 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -165,8 +165,8 @@ control(struct smtpd *env) TAILQ_INIT(&ctl_conns); - config_pipes(env, peers, 5); - config_peers(env, peers, 5); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); control_listen(env); event_dispatch(); control_shutdown(); diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index 3c7e79f9088..ed172abad9f 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.14 2009/04/21 18:12:05 jacekm Exp $ */ +/* $OpenBSD: enqueue.c,v 1.15 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2005 Henning Brauer @@ -325,7 +325,7 @@ parse_message(FILE *fin, int get_from, int tflag) } for (i = 0; !header_done && cur == HDR_NONE && - i < (sizeof(keywords) / sizeof(keywords[0])); i++) + i < nitems(keywords); i++) if (len > strlen(keywords[i].word) && !strncasecmp(buf, keywords[i].word, strlen(keywords[i].word))) diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 2f0bc905446..10e65eaaed9 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.45 2009/05/09 17:04:55 jacekm Exp $ */ +/* $OpenBSD: lka.c,v 1.46 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -614,8 +614,8 @@ lka(struct smtpd *env) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - config_pipes(env, peers, 6); - config_peers(env, peers, 6); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); lka_setup_events(env); event_dispatch(); diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index d0ed665bc6f..b1fb9bf42af 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.15 2009/04/28 21:27:25 jacekm Exp $ */ +/* $OpenBSD: mda.c,v 1.16 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -429,8 +429,8 @@ mda(struct smtpd *env) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - config_pipes(env, peers, 3); - config_peers(env, peers, 3); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); mda_setup_events(env); event_dispatch(); diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c index 4e3665c86cc..8095394af91 100644 --- a/usr.sbin/smtpd/mfa.c +++ b/usr.sbin/smtpd/mfa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfa.c,v 1.24 2009/04/28 23:11:25 gilles Exp $ */ +/* $OpenBSD: mfa.c,v 1.25 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -347,8 +347,8 @@ mfa(struct smtpd *env) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - config_pipes(env, peers, 4); - config_peers(env, peers, 4); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); mfa_setup_events(env); event_dispatch(); diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 27f2d543e5f..cf39a9ca47d 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.46 2009/05/13 21:29:16 jacekm Exp $ */ +/* $OpenBSD: mta.c,v 1.47 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -505,8 +505,8 @@ mta(struct smtpd *env) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - config_pipes(env, peers, 3); - config_peers(env, peers, 3); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); SPLAY_INIT(&env->batch_queue); diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index aee6760e501..fd0ef84eef6 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.61 2009/04/21 14:37:32 eric Exp $ */ +/* $OpenBSD: queue.c,v 1.62 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -584,8 +584,8 @@ queue(struct smtpd *env) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - config_pipes(env, peers, 6); - config_peers(env, peers, 6); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); queue_purge(PATH_INCOMING); queue_purge(PATH_ENQUEUE); diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index a907ec4f4f6..f64560a9a7f 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.44 2009/05/10 11:29:40 jacekm Exp $ */ +/* $OpenBSD: runner.c,v 1.45 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -501,8 +501,8 @@ runner(struct smtpd *env) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - config_pipes(env, peers, 6); - config_peers(env, peers, 6); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); unlink(PATH_QUEUE "/envelope.tmp"); runner_reset_flags(); diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index 85f668395af..f1f9de3e9e8 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.44 2009/05/10 11:29:40 jacekm Exp $ */ +/* $OpenBSD: smtp.c,v 1.45 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -620,8 +620,8 @@ smtp(struct smtpd *env) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, SIG_IGN); - config_pipes(env, peers, 5); - config_peers(env, peers, 5); + config_pipes(env, peers, nitems(peers)); + config_peers(env, peers, nitems(peers)); smtp_setup_events(env); event_dispatch(); diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index bf7fe2d958d..07711efdb60 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.87 2009/05/14 08:29:37 jacekm Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.88 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -492,35 +492,35 @@ session_rfc5321_help_handler(struct session *s, char *args) void session_command(struct session *s, char *cmd, char *args) { - int i; + unsigned int i; if (!(s->s_flags & F_EHLO)) goto rfc5321; /* RFC 1652 - 8BITMIME */ - for (i = 0; i < (int)(sizeof(rfc1652_cmdtab) / sizeof(struct session_cmd)); ++i) + for (i = 0; i < nitems(rfc1652_cmdtab); ++i) if (strcasecmp(rfc1652_cmdtab[i].name, cmd) == 0) break; - if (i < (int)(sizeof(rfc1652_cmdtab) / sizeof(struct session_cmd))) { + if (i < nitems(rfc1652_cmdtab)) { if (rfc1652_cmdtab[i].func(s, args)) return; } /* RFC 3207 - STARTTLS */ - for (i = 0; i < (int)(sizeof(rfc3207_cmdtab) / sizeof(struct session_cmd)); ++i) + for (i = 0; i < nitems(rfc3207_cmdtab); ++i) if (strcasecmp(rfc3207_cmdtab[i].name, cmd) == 0) break; - if (i < (int)(sizeof(rfc3207_cmdtab) / sizeof(struct session_cmd))) { + if (i < nitems(rfc3207_cmdtab)) { if (rfc3207_cmdtab[i].func(s, args)) return; } /* RFC 4954 - AUTH */ if ((s->s_l->flags & F_AUTH) && (s->s_flags & F_SECURE)) { - for (i = 0; i < (int)(sizeof(rfc4954_cmdtab) / sizeof(struct session_cmd)); ++i) + for (i = 0; i < nitems(rfc4954_cmdtab); ++i) if (strcasecmp(rfc4954_cmdtab[i].name, cmd) == 0) break; - if (i < (int)(sizeof(rfc4954_cmdtab) / sizeof(struct session_cmd))) { + if (i < nitems(rfc4954_cmdtab)) { if (rfc4954_cmdtab[i].func(s, args)) return; } @@ -528,10 +528,10 @@ session_command(struct session *s, char *cmd, char *args) rfc5321: /* RFC 5321 - SMTP */ - for (i = 0; i < (int)(sizeof(rfc5321_cmdtab) / sizeof(struct session_cmd)); ++i) + for (i = 0; i < nitems(rfc5321_cmdtab); ++i) if (strcasecmp(rfc5321_cmdtab[i].name, cmd) == 0) break; - if (i < (int)(sizeof(rfc5321_cmdtab) / sizeof(struct session_cmd))) { + if (i < nitems(rfc5321_cmdtab)) { if (rfc5321_cmdtab[i].func(s, args)) return; } diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index b6d90c6a414..7dd4a469bbb 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.57 2009/05/10 11:29:40 jacekm Exp $ */ +/* $OpenBSD: smtpd.c,v 1.58 2009/05/14 15:05:12 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -115,7 +115,7 @@ parent_shutdown(void) runner_pid }; - for (i = 0; i < sizeof(pids) / sizeof(pid); i++) + for (i = 0; i < nitems(pids); i++) if (pids[i]) kill(pids[i], SIGTERM); @@ -150,7 +150,7 @@ parent_send_config(int fd, short event, void *p) iov[2].iov_len = s->ssl_key_len; imsg_composev(env->sc_ibufs[PROC_SMTP], IMSG_CONF_SSL, 0, 0, -1, - iov, sizeof(iov)/sizeof(iov[0])); + iov, nitems(iov)); } TAILQ_FOREACH(l, &env->sc_listeners, entry) { @@ -328,10 +328,10 @@ parent_dispatch_mda(int fd, short event, void *p) path = &batchp->message.sender; } - for (i = 0; i < sizeof(action_hdl_table) / sizeof(struct action_handler); ++i) + for (i = 0; i < nitems(action_hdl_table); ++i) if (action_hdl_table[i].action == path->rule.r_action) break; - if (i == sizeof(action_hdl_table) / sizeof(struct action_handler)) + if (i == nitems(action_hdl_table)) fatalx("parent_dispatch_mda: unknown action"); file = path->rule.r_value.path; @@ -840,8 +840,8 @@ main(int argc, char *argv[]) signal_add(&ev_sighup, NULL); signal(SIGPIPE, SIG_IGN); - config_pipes(&env, peers, 6); - config_peers(&env, peers, 6); + config_pipes(&env, peers, nitems(peers)); + config_peers(&env, peers, nitems(peers)); evtimer_set(&env.sc_ev, parent_send_config, &env); bzero(&tv, sizeof(tv)); @@ -929,7 +929,7 @@ setup_spool(uid_t uid, gid_t gid) } ret = 1; - for (n = 0; n < sizeof(paths)/sizeof(paths[0]); n++) { + for (n = 0; n < nitems(paths); n++) { mode_t mode; uid_t owner; gid_t group; @@ -1149,7 +1149,7 @@ parent_maildir_init(struct passwd *pw, char *root) char pathname[MAXPATHLEN]; char *subdir[] = { "/", "/tmp", "/cur", "/new" }; - for (i = 0; i < sizeof (subdir) / sizeof (char *); ++i) { + for (i = 0; i < nitems(subdir); ++i) { if (! bsnprintf(pathname, sizeof(pathname), "%s%s", root, subdir[i])) return 0; -- cgit v1.2.3