diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-05-31 21:06:13 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-05-31 21:06:13 +0000 |
commit | 9faafef4900db3f8424ad7e25bd826146631b5d1 (patch) | |
tree | 15940d3fddaa91896ffdaef43ea19b7e37c21f9a | |
parent | e56f180c5018c2a7bd4b4f9bdf43d8eaecedf450 (diff) |
remove 'where' parameter from all x*() functions in utils.c, it doesn't
really help us with anything, propagate the change in codebase
ok millert@
28 files changed, 174 insertions, 188 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index a9304471d15..7b8ee1575c0 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.78 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: bounce.c,v 1.79 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@poolp.org> @@ -163,16 +163,16 @@ bounce_add(uint64_t evpid) key.bounce.ttl = evp.ttl; msg = SPLAY_FIND(bounce_message_tree, &messages, &key); if (msg == NULL) { - msg = xcalloc(1, sizeof(*msg), "bounce_add"); + msg = xcalloc(1, sizeof(*msg)); msg->msgid = key.msgid; msg->bounce = key.bounce; TAILQ_INIT(&msg->envelopes); - msg->smtpname = xstrdup(evp.smtpname, "bounce_add"); + msg->smtpname = xstrdup(evp.smtpname); (void)snprintf(buf, sizeof(buf), "%s@%s", evp.sender.user, evp.sender.domain); - msg->to = xstrdup(buf, "bounce_add"); + msg->to = xstrdup(buf); nmessage += 1; SPLAY_INSERT(bounce_message_tree, &messages, msg); log_debug("debug: bounce: new message %08" PRIx32, @@ -187,9 +187,9 @@ bounce_add(uint64_t evpid) (void)snprintf(buf, sizeof(buf), "%s@%s: %s\n", evp.dest.user, evp.dest.domain, line); - be = xmalloc(sizeof *be, "bounce_add"); + be = xmalloc(sizeof *be); be->id = evpid; - be->report = xstrdup(buf, "bounce_add"); + be->report = xstrdup(buf); (void)strlcpy(be->dest.user, evp.dest.user, sizeof(be->dest.user)); (void)strlcpy(be->dest.domain, evp.dest.domain, sizeof(be->dest.domain)); @@ -225,8 +225,8 @@ bounce_fd(int fd) msg = TAILQ_FIRST(&pending); - s = xcalloc(1, sizeof(*s), "bounce_fd"); - s->smtpname = xstrdup(msg->smtpname, "bounce_fd"); + s = xcalloc(1, sizeof(*s)); + s->smtpname = xstrdup(msg->smtpname); s->state = BOUNCE_EHLO; s->io = io_new(); io_set_callback(s->io, bounce_io, s); diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 172dffbe840..6f9c9aca553 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.122 2018/05/14 15:23:05 gilles Exp $ */ +/* $OpenBSD: control.c,v 1.123 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> @@ -312,7 +312,7 @@ control_accept(int listenfd, short event, void *arg) count = tree_get(&ctl_count, euid); if (count == NULL) { - count = xcalloc(1, sizeof *count, "control_accept"); + count = xcalloc(1, sizeof *count); tree_xset(&ctl_count, euid, count); } @@ -328,7 +328,7 @@ control_accept(int listenfd, short event, void *arg) ++connid; } while (tree_get(&ctl_conns, connid)); - c = xcalloc(1, sizeof(*c), "control_accept"); + c = xcalloc(1, sizeof(*c)); c->euid = euid; c->egid = egid; c->id = connid; diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c index b5c13e61fae..a37e3cd99a7 100644 --- a/usr.sbin/smtpd/dns.c +++ b/usr.sbin/smtpd/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.85 2018/01/06 07:57:53 sunil Exp $ */ +/* $OpenBSD: dns.c,v 1.86 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -119,7 +119,7 @@ dns_imsg(struct mproc *p, struct imsg *imsg) const char *domain, *mx, *host; socklen_t sl; - s = xcalloc(1, sizeof *s, "dns_imsg"); + s = xcalloc(1, sizeof *s); s->type = imsg->hdr.type; s->p = p; @@ -361,7 +361,7 @@ dns_lookup_host(struct dns_session *s, const char *host, int preference) char *p; void *as; - lookup = xcalloc(1, sizeof *lookup, "dns_lookup_host"); + lookup = xcalloc(1, sizeof *lookup); lookup->preference = preference; lookup->session = s; s->refcount++; diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index a02d21ad245..bc59989aaac 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.114 2018/04/23 10:27:24 sunil Exp $ */ +/* $OpenBSD: enqueue.c,v 1.115 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2005 Henning Brauer <henning@bulabula.org> @@ -246,7 +246,7 @@ enqueue(int argc, char *argv[], FILE *ofp) if ((pw = getpwuid(getuid())) == NULL) user = "anonymous"; if (pw != NULL) - user = xstrdup(pw->pw_name, "enqueue"); + user = xstrdup(pw->pw_name); } else { uid_t ruid = getuid(); @@ -258,7 +258,7 @@ enqueue(int argc, char *argv[], FILE *ofp) } else if ((pw = getpwuid(ruid)) == NULL) { user = "anonymous"; } - user = xstrdup(pw ? pw->pw_name : user, "enqueue"); + user = xstrdup(pw ? pw->pw_name : user); } build_from(fake_from, pw); @@ -543,7 +543,7 @@ build_from(char *fake_from, struct passwd *pw) if (fake_from[strlen(fake_from) - 1] != '>') errx(1, "leading < but no trailing >"); fake_from[strlen(fake_from) - 1] = 0; - p = xstrdup(fake_from + 1, "build_from"); + p = xstrdup(fake_from + 1); msg.from = qualify_addr(p); free(p); @@ -758,7 +758,7 @@ qualify_addr(char *in) if (asprintf(&out, "%s@%s", in, host) == -1) err(1, "qualify asprintf"); } else - out = xstrdup(in, "qualify_addr"); + out = xstrdup(in); return (out); } diff --git a/usr.sbin/smtpd/expand.c b/usr.sbin/smtpd/expand.c index fda95be4432..99b25d51f5e 100644 --- a/usr.sbin/smtpd/expand.c +++ b/usr.sbin/smtpd/expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expand.c,v 1.30 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: expand.c,v 1.31 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@poolp.org> @@ -83,7 +83,7 @@ expand_insert(struct expand *expand, struct expandnode *node) return; } - xn = xmemdup(node, sizeof *xn, "expand_insert"); + xn = xmemdup(node, sizeof *xn); xn->rule = expand->rule; xn->parent = expand->parent; if (xn->parent) diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 591a79d931c..40f57159515 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.204 2018/05/29 20:43:07 eric Exp $ */ +/* $OpenBSD: lka.c,v 1.205 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -167,13 +167,13 @@ lka_imsg(struct mproc *p, struct imsg *imsg) case IMSG_SMTP_TLS_VERIFY_CERT: case IMSG_MTA_TLS_VERIFY_CERT: - req_ca_vrfy = xmemdup(imsg->data, sizeof *req_ca_vrfy, "lka:ca_vrfy"); + req_ca_vrfy = xmemdup(imsg->data, sizeof *req_ca_vrfy); req_ca_vrfy->cert = xmemdup((char *)imsg->data + - sizeof *req_ca_vrfy, req_ca_vrfy->cert_len, "lka:ca_vrfy"); + sizeof *req_ca_vrfy, req_ca_vrfy->cert_len); req_ca_vrfy->chain_cert = xcalloc(req_ca_vrfy->n_chain, - sizeof (unsigned char *), "lka:ca_vrfy"); + sizeof (unsigned char *)); req_ca_vrfy->chain_cert_len = xcalloc(req_ca_vrfy->n_chain, - sizeof (off_t), "lka:ca_vrfy"); + sizeof (off_t)); return; case IMSG_SMTP_TLS_VERIFY_CHAIN: @@ -182,7 +182,7 @@ lka_imsg(struct mproc *p, struct imsg *imsg) fatalx("lka:ca_vrfy: chain without a certificate"); req_ca_vrfy_chain = imsg->data; req_ca_vrfy->chain_cert[req_ca_vrfy->chain_offset] = xmemdup((char *)imsg->data + - sizeof *req_ca_vrfy_chain, req_ca_vrfy_chain->cert_len, "lka:ca_vrfy"); + sizeof *req_ca_vrfy_chain, req_ca_vrfy_chain->cert_len); req_ca_vrfy->chain_cert_len[req_ca_vrfy->chain_offset] = req_ca_vrfy_chain->cert_len; req_ca_vrfy->chain_offset++; return; diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c index edc46026d56..ed6ea290118 100644 --- a/usr.sbin/smtpd/lka_session.c +++ b/usr.sbin/smtpd/lka_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_session.c,v 1.82 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: lka_session.c,v 1.83 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -81,7 +81,7 @@ lka_session(uint64_t id, struct envelope *envelope) tree_init(&sessions); } - lks = xcalloc(1, sizeof(*lks), "lka_session"); + lks = xcalloc(1, sizeof(*lks)); lks->id = id; RB_INIT(&lks->expand.tree); TAILQ_INIT(&lks->deliverylist); @@ -466,7 +466,7 @@ lka_submit(struct lka_session *lks, struct rule *rule, struct expandnode *xn) const char *user; const char *format; - ep = xmemdup(&lks->envelope, sizeof *ep, "lka_submit"); + ep = xmemdup(&lks->envelope, sizeof *ep); (void)strlcpy(ep->dispatcher, rule->dispatcher, sizeof ep->dispatcher); dsp = dict_xget(env->sc_dispatchers, ep->dispatcher); diff --git a/usr.sbin/smtpd/mailaddr.c b/usr.sbin/smtpd/mailaddr.c index e48f729d7cd..a15470d7988 100644 --- a/usr.sbin/smtpd/mailaddr.c +++ b/usr.sbin/smtpd/mailaddr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mailaddr.c,v 1.2 2015/12/28 22:08:30 jung Exp $ */ +/* $OpenBSD: mailaddr.c,v 1.3 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2015 Gilles Chehade <gilles@poolp.org> @@ -116,7 +116,7 @@ maddrmap_insert(struct maddrmap *maddrmap, struct maddrnode *maddrnode) { struct maddrnode *mn; - mn = xmemdup(maddrnode, sizeof *maddrnode, "maddrmap_insert"); + mn = xmemdup(maddrnode, sizeof *maddrnode); TAILQ_INSERT_TAIL(&maddrmap->queue, mn, entries); } diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c index 1cc2f7a865d..d2ffeff8407 100644 --- a/usr.sbin/smtpd/makemap.c +++ b/usr.sbin/smtpd/makemap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makemap.c,v 1.68 2018/04/26 20:57:59 eric Exp $ */ +/* $OpenBSD: makemap.c,v 1.69 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -400,7 +400,7 @@ parse_setentry(DB *db, int *dbputs, char *line, size_t len, size_t lineno) static int make_plain(DBT *val, char *text) { - val->data = xstrdup(text, "make_plain"); + val->data = xstrdup(text); val->size = strlen(text) + 1; return (val->size); @@ -416,7 +416,7 @@ make_aliases(DBT *val, char *text) val->data = NULL; val->size = 0; - origtext = xstrdup(text, "make_aliases"); + origtext = xstrdup(text); while ((subrcpt = strsep(&text, ",")) != NULL) { /* subrcpt: strip initial and trailing whitespace. */ @@ -452,7 +452,7 @@ conf_aliases(char *cfgpath) if (table == NULL) return (PATH_ALIASES); - path = xstrdup(table->t_config, "conf_aliases"); + path = xstrdup(table->t_config); p = strstr(path, ".db"); if (p == NULL || strcmp(p, ".db") != 0) { return (path); diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index 2649e452a1a..c6359828c32 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.131 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: mda.c,v 1.132 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -707,7 +707,7 @@ mda_user(const struct envelope *evp) return (u); } - u = xcalloc(1, sizeof *u, "mda_user"); + u = xcalloc(1, sizeof *u); u->id = generate_uid(); TAILQ_INIT(&u->envelopes); (void)strlcpy(u->name, evp->mda_user, sizeof(u->name)); @@ -768,26 +768,25 @@ mda_envelope(const struct envelope *evp) struct mda_envelope *e; char buf[LINE_MAX]; - e = xcalloc(1, sizeof *e, "mda_envelope"); + e = xcalloc(1, sizeof *e); e->id = evp->id; e->creation = evp->creation; buf[0] = '\0'; if (evp->sender.user[0] && evp->sender.domain[0]) (void)snprintf(buf, sizeof buf, "%s@%s", evp->sender.user, evp->sender.domain); - e->sender = xstrdup(buf, "mda_envelope:sender"); + e->sender = xstrdup(buf); (void)snprintf(buf, sizeof buf, "%s@%s", evp->dest.user, evp->dest.domain); - e->dest = xstrdup(buf, "mda_envelope:dest"); + e->dest = xstrdup(buf); (void)snprintf(buf, sizeof buf, "%s@%s", evp->rcpt.user, evp->rcpt.domain); - e->rcpt = xstrdup(buf, "mda_envelope:rcpt"); + e->rcpt = xstrdup(buf); e->user = evp->mda_user[0] ? - xstrdup(evp->mda_user, "mda_envelope:mda_user") : - xstrdup(evp->dest.user, "mda_envelope:user"); - e->dispatcher = xstrdup(evp->dispatcher, "mda_envelope:user"); + xstrdup(evp->mda_user) : xstrdup(evp->dest.user); + e->dispatcher = xstrdup(evp->dispatcher); if (evp->mda_exec[0]) - e->mda_exec = xstrdup(evp->mda_exec, "mda_envelope:mda_exec"); + e->mda_exec = xstrdup(evp->mda_exec); stat_increment("mda.envelope", 1); return (e); } @@ -810,7 +809,7 @@ mda_session(struct mda_user * u) { struct mda_session *s; - s = xcalloc(1, sizeof *s, "mda_session"); + s = xcalloc(1, sizeof *s); s->id = generate_uid(); s->user = u; s->io = io_new(); diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 853973fc715..8e90b503d54 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.212 2018/05/31 11:56:10 eric Exp $ */ +/* $OpenBSD: mta.c,v 1.213 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -259,7 +259,7 @@ mta_imsg(struct mproc *p, struct imsg *imsg) m_get_int(&m, &preference); m_end(&m); domain = tree_xget(&wait_mx, reqid); - mx = xcalloc(1, sizeof *mx, "mta: mx"); + mx = xcalloc(1, sizeof *mx); mx->host = mta_host((struct sockaddr*)&ss); mx->preference = preference; TAILQ_FOREACH(imx, &domain->mxs, entry) { @@ -708,7 +708,7 @@ mta_handle_envelope(struct envelope *evp, const char *smarthost) break; if (task == NULL) { - task = xmalloc(sizeof *task, "mta_task"); + task = xmalloc(sizeof *task); TAILQ_INIT(&task->envelopes); task->relay = relay; relay->ntask += 1; @@ -730,27 +730,26 @@ mta_handle_envelope(struct envelope *evp, const char *smarthost) } } - task->sender = xstrdup(buf, "mta_task:sender"); + task->sender = xstrdup(buf); stat_increment("mta.task", 1); } - e = xcalloc(1, sizeof *e, "mta_envelope"); + e = xcalloc(1, sizeof *e); e->id = evp->id; e->creation = evp->creation; - e->smtpname = xstrdup(evp->smtpname, "mta_envelope:smtpname"); + e->smtpname = xstrdup(evp->smtpname); (void)snprintf(buf, sizeof buf, "%s@%s", evp->dest.user, evp->dest.domain); - e->dest = xstrdup(buf, "mta_envelope:dest"); + e->dest = xstrdup(buf); (void)snprintf(buf, sizeof buf, "%s@%s", evp->rcpt.user, evp->rcpt.domain); if (strcmp(buf, e->dest)) - e->rcpt = xstrdup(buf, "mta_envelope:rcpt"); + e->rcpt = xstrdup(buf); e->task = task; if (evp->dsn_orcpt.user[0] && evp->dsn_orcpt.domain[0]) { (void)snprintf(buf, sizeof buf, "%s@%s", evp->dsn_orcpt.user, evp->dsn_orcpt.domain); - e->dsn_orcpt = xstrdup(buf, - "mta_envelope:dsn_orcpt"); + e->dsn_orcpt = xstrdup(buf); } (void)strlcpy(e->dsn_envid, evp->dsn_envid, sizeof e->dsn_envid); @@ -1768,30 +1767,27 @@ mta_relay(struct envelope *e) key.heloname = NULL; if ((r = SPLAY_FIND(mta_relay_tree, &relays, &key)) == NULL) { - r = xcalloc(1, sizeof *r, "mta_relay"); + r = xcalloc(1, sizeof *r); TAILQ_INIT(&r->tasks); r->id = generate_uid(); r->flags = key.flags; r->domain = key.domain; r->backupname = key.backupname ? - xstrdup(key.backupname, "mta: backupname") : NULL; + xstrdup(key.backupname) : NULL; r->backuppref = -1; r->port = key.port; - r->pki_name = key.pki_name ? xstrdup(key.pki_name, "mta: pki_name") : NULL; - r->ca_name = key.ca_name ? xstrdup(key.ca_name, "mta: ca_name") : NULL; + r->pki_name = key.pki_name ? xstrdup(key.pki_name) : NULL; + r->ca_name = key.ca_name ? xstrdup(key.ca_name) : NULL; if (key.authtable) - r->authtable = xstrdup(key.authtable, "mta: authtable"); + r->authtable = xstrdup(key.authtable); if (key.authlabel) - r->authlabel = xstrdup(key.authlabel, "mta: authlabel"); + r->authlabel = xstrdup(key.authlabel); if (key.sourcetable) - r->sourcetable = xstrdup(key.sourcetable, - "mta: sourcetable"); + r->sourcetable = xstrdup(key.sourcetable); if (key.helotable) - r->helotable = xstrdup(key.helotable, - "mta: helotable"); + r->helotable = xstrdup(key.helotable); if (key.heloname) - r->heloname = xstrdup(key.heloname, - "mta: heloname"); + r->heloname = xstrdup(key.heloname); SPLAY_INSERT(mta_relay_tree, &relays, r); stat_increment("mta.relay", 1); } else { @@ -2091,8 +2087,8 @@ mta_host(const struct sockaddr *sa) h = SPLAY_FIND(mta_host_tree, &hosts, &key); if (h == NULL) { - h = xcalloc(1, sizeof(*h), "mta_host"); - h->sa = xmemdup(sa, sa->sa_len, "mta_host"); + h = xcalloc(1, sizeof(*h)); + h->sa = xmemdup(sa, sa->sa_len); SPLAY_INSERT(mta_host_tree, &hosts, h); stat_increment("mta.host", 1); } @@ -2156,8 +2152,8 @@ mta_domain(char *name, int flags) d = SPLAY_FIND(mta_domain_tree, &domains, &key); if (d == NULL) { - d = xcalloc(1, sizeof(*d), "mta_domain"); - d->name = xstrdup(name, "mta_domain"); + d = xcalloc(1, sizeof(*d)); + d->name = xstrdup(name); d->flags = flags; TAILQ_INIT(&d->mxs); SPLAY_INSERT(mta_domain_tree, &domains, d); @@ -2222,9 +2218,9 @@ mta_source(const struct sockaddr *sa) s = SPLAY_FIND(mta_source_tree, &sources, &key); if (s == NULL) { - s = xcalloc(1, sizeof(*s), "mta_source"); + s = xcalloc(1, sizeof(*s)); if (sa) - s->sa = xmemdup(sa, sa->sa_len, "mta_source"); + s->sa = xmemdup(sa, sa->sa_len); SPLAY_INSERT(mta_source_tree, &sources, s); stat_increment("mta.source", 1); } @@ -2285,7 +2281,7 @@ mta_connector(struct mta_relay *relay, struct mta_source *source) c = tree_get(&relay->connectors, (uintptr_t)(source)); if (c == NULL) { - c = xcalloc(1, sizeof(*c), "mta_connector"); + c = xcalloc(1, sizeof(*c)); c->relay = relay; c->source = source; c->flags |= CONNECTOR_NEW; @@ -2338,7 +2334,7 @@ mta_route(struct mta_source *src, struct mta_host *dst) r = SPLAY_FIND(mta_route_tree, &routes, &key); if (r == NULL) { - r = xcalloc(1, sizeof(*r), "mta_route"); + r = xcalloc(1, sizeof(*r)); r->src = src; r->dst = dst; r->flags |= ROUTE_NEW; @@ -2464,9 +2460,9 @@ mta_block(struct mta_source *src, char *dom) if (b != NULL) return; - b = xcalloc(1, sizeof(*b), "mta_block"); + b = xcalloc(1, sizeof(*b)); if (dom) - b->domain = xstrdup(dom, "mta_block"); + b->domain = xstrdup(dom); b->source = src; mta_source_ref(src); SPLAY_INSERT(mta_block_tree, &blocks, b); diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index bebb01bcea2..f7016e20f03 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.98 2017/05/24 21:27:32 gilles Exp $ */ +/* $OpenBSD: mta_session.c,v 1.99 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -191,7 +191,7 @@ mta_session(struct mta_relay *relay, struct mta_route *route) mta_session_init(); - s = xcalloc(1, sizeof *s, "mta_session"); + s = xcalloc(1, sizeof *s); s->id = generate_uid(); s->relay = relay; s->route = route; @@ -305,7 +305,7 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg) h = s->route->dst; h->lastptrquery = time(NULL); if (name) - h->ptrname = xstrdup(name, "mta: ptr"); + h->ptrname = xstrdup(name); waitq_run(&h->ptrname, h->ptrname); return; @@ -332,9 +332,9 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg) } } - resp_ca_cert = xmemdup(imsg->data, sizeof *resp_ca_cert, "mta:ca_cert"); + resp_ca_cert = xmemdup(imsg->data, sizeof *resp_ca_cert); resp_ca_cert->cert = xstrdup((char *)imsg->data + - sizeof *resp_ca_cert, "mta:ca_cert"); + sizeof *resp_ca_cert); ssl = ssl_mta_init(resp_ca_cert->name, resp_ca_cert->cert, resp_ca_cert->cert_len, env->sc_tls_ciphers); if (ssl == NULL) @@ -377,7 +377,7 @@ mta_session_imsg(struct mproc *p, struct imsg *imsg) return; if (status == LKA_OK) { - s->helo = xstrdup(name, "mta_session_imsg"); + s->helo = xstrdup(name); mta_connect(s); } else { mta_source_error(s->relay, s->route, @@ -489,9 +489,9 @@ mta_connect(struct mta_session *s) return; } else if (s->relay->heloname) - s->helo = xstrdup(s->relay->heloname, "mta_connect"); + s->helo = xstrdup(s->relay->heloname); else - s->helo = xstrdup(env->sc_hostname, "mta_connect"); + s->helo = xstrdup(env->sc_hostname); } if (s->io) { diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index 31a3bb4547d..553c3f16acd 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.206 2018/05/30 19:01:58 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.207 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -386,7 +386,7 @@ dispatcher_local_option dispatcher_local_options dispatcher_local: MBOX { dispatcher->u.local.requires_root = 1; - dispatcher->u.local.user = xstrdup("root", "dispatcher_mda"); + dispatcher->u.local.user = xstrdup("root"); asprintf(&dispatcher->u.local.command, "/usr/libexec/mail.local -f %%{sender} %%{user.username}"); } dispatcher_local_options | MAILDIR { @@ -610,7 +610,7 @@ ACTION STRING { yyerror("dispatcher already declared with that name: %s", $2); YYERROR; } - dispatcher = xcalloc(1, sizeof *dispatcher, "dispatcher"); + dispatcher = xcalloc(1, sizeof *dispatcher); } dispatcher_type dispatcher_options { if (dispatcher->type == DISPATCHER_LOCAL) if (dispatcher->u.local.table_userbase == NULL) @@ -830,7 +830,7 @@ REJECT { match: MATCH { - rule = xcalloc(1, sizeof *rule, "rule"); + rule = xcalloc(1, sizeof *rule); } match_options action { if (!rule->flag_from) { rule->table_from = strdup("<localhost>"); @@ -1351,7 +1351,7 @@ limit : LIMIT SMTP limits_smtp limits = dict_get(conf->sc_limits_dict, $5); if (limits == NULL) { - limits = xcalloc(1, sizeof(*limits), "mta_limits"); + limits = xcalloc(1, sizeof(*limits)); dict_xset(conf->sc_limits_dict, $5, limits); d = dict_xget(conf->sc_limits_dict, "default"); memmove(limits, d, sizeof(*limits)); @@ -1379,7 +1379,7 @@ pkica : PKI STRING { free($2); pki = dict_get(conf->sc_pki_dict, buf); if (pki == NULL) { - pki = xcalloc(1, sizeof *pki, "parse:pki"); + pki = xcalloc(1, sizeof *pki); (void)strlcpy(pki->pki_name, buf, sizeof(pki->pki_name)); dict_set(conf->sc_pki_dict, pki->pki_name, pki); } @@ -1399,7 +1399,7 @@ pkica : PKI STRING { free($2); sca = dict_get(conf->sc_ca_dict, buf); if (sca == NULL) { - sca = xcalloc(1, sizeof *sca, "parse:ca"); + sca = xcalloc(1, sizeof *sca); (void)strlcpy(sca->ca_name, buf, sizeof(sca->ca_name)); dict_set(conf->sc_ca_dict, sca->ca_name, sca); } @@ -1989,7 +1989,7 @@ parse_config(struct smtpd *x_conf, const char *filename, int opts) dict_init(conf->sc_tables_dict); dict_init(conf->sc_limits_dict); - limits = xcalloc(1, sizeof(*limits), "mta_limits"); + limits = xcalloc(1, sizeof(*limits)); limit_mta_set_defaults(limits); dict_xset(conf->sc_limits_dict, "default", limits); @@ -2039,7 +2039,7 @@ parse_config(struct smtpd *x_conf, const char *filename, int opts) table_create("getpwnam", "<getpwnam>", NULL, NULL); /* bounce dispatcher */ - dispatcher = xcalloc(1, sizeof *dispatcher, "dispatcher"); + dispatcher = xcalloc(1, sizeof *dispatcher); dispatcher->type = DISPATCHER_BOUNCE; conf->sc_dispatcher_bounce = dispatcher; dispatcher = NULL; @@ -2164,7 +2164,7 @@ symget(const char *nam) static void create_sock_listener(struct listen_opts *lo) { - struct listener *l = xcalloc(1, sizeof(*l), "create_sock_listener"); + struct listener *l = xcalloc(1, sizeof(*l)); lo->tag = "local"; lo->hostname = conf->sc_hostname; l->ss.ss_family = AF_LOCAL; @@ -2294,7 +2294,7 @@ host_v4(struct listen_opts *lo) if (inet_pton(AF_INET, lo->ifx, &ina) != 1) return (0); - h = xcalloc(1, sizeof(*h), "host_v4"); + h = xcalloc(1, sizeof(*h)); sain = (struct sockaddr_in *)&h->ss; sain->sin_len = sizeof(struct sockaddr_in); sain->sin_family = AF_INET; @@ -2322,7 +2322,7 @@ host_v6(struct listen_opts *lo) if (inet_pton(AF_INET6, lo->ifx, &ina6) != 1) return (0); - h = xcalloc(1, sizeof(*h), "host_v6"); + h = xcalloc(1, sizeof(*h)); sin6 = (struct sockaddr_in6 *)&h->ss; sin6->sin6_len = sizeof(struct sockaddr_in6); sin6->sin6_family = AF_INET6; @@ -2362,7 +2362,7 @@ host_dns(struct listen_opts *lo) if (res->ai_family != AF_INET && res->ai_family != AF_INET6) continue; - h = xcalloc(1, sizeof(*h), "host_dns"); + h = xcalloc(1, sizeof(*h)); h->ss.ss_family = res->ai_family; if (res->ai_family == AF_INET) { @@ -2413,7 +2413,7 @@ interface(struct listen_opts *lo) if (lo->family != AF_UNSPEC && lo->family != p->ifa_addr->sa_family) continue; - h = xcalloc(1, sizeof(*h), "interface"); + h = xcalloc(1, sizeof(*h)); switch (p->ifa_addr->sa_family) { case AF_INET: @@ -2583,7 +2583,7 @@ is_if_in_group(const char *ifname, const char *groupname) len = ifgr.ifgr_len; ifgr.ifgr_groups = xcalloc(len/sizeof(struct ifg_req), - sizeof(struct ifg_req), "is_if_in_group"); + sizeof(struct ifg_req)); if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) err(1, "SIOCGIFGROUP"); diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 7c454048152..29f4e70eb24 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.186 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: queue.c,v 1.187 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -516,7 +516,7 @@ queue_imsg(struct mproc *p, struct imsg *imsg) m_get_msgid(&m, &msgid); m_end(&m); /* handle concurrent walk requests */ - wi = xcalloc(1, sizeof *wi, "queu_imsg"); + wi = xcalloc(1, sizeof *wi); wi->msgid = msgid; wi->peerid = imsg->hdr.peerid; evtimer_set(&wi->ev, queue_msgid_walk, wi); diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c index 82d374bc232..4337051e229 100644 --- a/usr.sbin/smtpd/queue_backend.c +++ b/usr.sbin/smtpd/queue_backend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_backend.c,v 1.63 2018/05/14 15:23:05 gilles Exp $ */ +/* $OpenBSD: queue_backend.c,v 1.64 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -457,7 +457,7 @@ queue_envelope_cache_add(struct envelope *e) while (tree_count(&evpcache_tree) >= env->sc_queue_evpcache_size) queue_envelope_cache_del(TAILQ_LAST(&evpcache_list, evplst)->id); - cached = xcalloc(1, sizeof *cached, "queue_envelope_cache_add"); + cached = xcalloc(1, sizeof *cached); *cached = *e; TAILQ_INSERT_HEAD(&evpcache_list, cached, entry); tree_xset(&evpcache_tree, e->id, cached); diff --git a/usr.sbin/smtpd/queue_fs.c b/usr.sbin/smtpd/queue_fs.c index 8c4ec3b2492..5960663f616 100644 --- a/usr.sbin/smtpd/queue_fs.c +++ b/usr.sbin/smtpd/queue_fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_fs.c,v 1.16 2018/05/14 15:23:05 gilles Exp $ */ +/* $OpenBSD: queue_fs.c,v 1.17 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -561,7 +561,7 @@ fsqueue_qwalk_new(void) char * const path_argv[] = { path, NULL }; struct qwalk *q; - q = xcalloc(1, sizeof(*q), "fsqueue_qwalk_new"); + q = xcalloc(1, sizeof(*q)); (void)strlcpy(path, PATH_QUEUE, sizeof(path)); q->fts = fts_open(path_argv, FTS_PHYSICAL | FTS_NOCHDIR, NULL); diff --git a/usr.sbin/smtpd/scheduler.c b/usr.sbin/smtpd/scheduler.c index e39e5b9d894..f8966fd8c49 100644 --- a/usr.sbin/smtpd/scheduler.c +++ b/usr.sbin/smtpd/scheduler.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler.c,v 1.57 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: scheduler.c,v 1.58 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -452,10 +452,10 @@ scheduler(void) setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) fatal("scheduler: cannot drop privileges"); - evpids = xcalloc(env->sc_scheduler_max_schedule, sizeof *evpids, "scheduler: init evpids"); - types = xcalloc(env->sc_scheduler_max_schedule, sizeof *types, "scheduler: init types"); - msgids = xcalloc(env->sc_scheduler_max_msg_batch_size, sizeof *msgids, "scheduler: list msg"); - state = xcalloc(env->sc_scheduler_max_evp_batch_size, sizeof *state, "scheduler: list evp"); + evpids = xcalloc(env->sc_scheduler_max_schedule, sizeof *evpids); + types = xcalloc(env->sc_scheduler_max_schedule, sizeof *types); + msgids = xcalloc(env->sc_scheduler_max_msg_batch_size, sizeof *msgids); + state = xcalloc(env->sc_scheduler_max_evp_batch_size, sizeof *state); imsg_callback = scheduler_imsg; event_init(); diff --git a/usr.sbin/smtpd/scheduler_ramqueue.c b/usr.sbin/smtpd/scheduler_ramqueue.c index 65043b23d92..8d5efc1009c 100644 --- a/usr.sbin/smtpd/scheduler_ramqueue.c +++ b/usr.sbin/smtpd/scheduler_ramqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scheduler_ramqueue.c,v 1.44 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: scheduler_ramqueue.c,v 1.45 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> @@ -207,7 +207,7 @@ scheduler_ram_insert(struct scheduler_info *si) /* find/prepare a ramqueue update */ if ((update = tree_get(&updates, msgid)) == NULL) { - update = xcalloc(1, sizeof *update, "scheduler_insert"); + update = xcalloc(1, sizeof *update); stat_increment("scheduler.ramqueue.update", 1); rq_queue_init(update); tree_xset(&updates, msgid, update); @@ -215,7 +215,7 @@ scheduler_ram_insert(struct scheduler_info *si) /* find/prepare the msgtree message in ramqueue update */ if ((message = tree_get(&update->messages, msgid)) == NULL) { - message = xcalloc(1, sizeof *message, "scheduler_insert"); + message = xcalloc(1, sizeof *message); message->msgid = msgid; tree_init(&message->envelopes); tree_xset(&update->messages, msgid, message); @@ -223,7 +223,7 @@ scheduler_ram_insert(struct scheduler_info *si) } /* create envelope in ramqueue message */ - envelope = xcalloc(1, sizeof *envelope, "scheduler_insert"); + envelope = xcalloc(1, sizeof *envelope); envelope->evpid = si->evpid; envelope->type = si->type; envelope->message = message; @@ -391,7 +391,7 @@ scheduler_ram_hold(uint64_t evpid, uint64_t holdq) hq = tree_get(&holdqs[evp->type], holdq); if (hq == NULL) { - hq = xcalloc(1, sizeof(*hq), "scheduler_hold"); + hq = xcalloc(1, sizeof(*hq)); TAILQ_INIT(&hq->q); tree_xset(&holdqs[evp->type], holdq, hq); stat_increment("scheduler.ramqueue.holdq", 1); diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 6c766113837..7fa06224e3a 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.330 2018/05/10 07:21:47 eric Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.331 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -746,7 +746,7 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg) smtp_enter_state(s, STATE_QUIT); } else { - rcpt = xcalloc(1, sizeof(*rcpt), "smtp_rcpt"); + rcpt = xcalloc(1, sizeof(*rcpt)); rcpt->destcount = s->tx->destcount; rcpt->maddr = s->tx->evp.rcpt; TAILQ_INSERT_TAIL(&s->tx->rcpts, rcpt, entry); @@ -849,9 +849,9 @@ smtp_session_imsg(struct mproc *p, struct imsg *imsg) return; } - resp_ca_cert = xmemdup(imsg->data, sizeof *resp_ca_cert, "smtp:ca_cert"); + resp_ca_cert = xmemdup(imsg->data, sizeof *resp_ca_cert); resp_ca_cert->cert = xstrdup((char *)imsg->data + - sizeof *resp_ca_cert, "smtp:ca_cert"); + sizeof *resp_ca_cert); ssl_ctx = dict_get(env->sc_ssl_dict, resp_ca_cert->name); ssl = ssl_smtp_init(ssl_ctx, s->listener->flags & F_TLS_VERIFY); io_set_read(s->io); diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 541331194fd..a78c26fa263 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.161 2018/05/24 11:38:24 gilles Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.162 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -126,7 +126,7 @@ srv_connect(void) return (0); } - ibuf = xcalloc(1, sizeof(struct imsgbuf), "smtpctl:srv_connect"); + ibuf = xcalloc(1, sizeof(struct imsgbuf)); imsg_init(ibuf, ctl_sock); return (1); diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index a550353f796..af3c4596b8b 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.297 2018/05/29 22:10:29 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.298 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -228,7 +228,7 @@ parent_imsg(struct mproc *p, struct imsg *imsg) return; } - c->cause = xstrdup(cause, "parent_imsg"); + c->cause = xstrdup(cause); log_debug("debug: smtpd: kill requested for %u: %s", c->pid, c->cause); kill(c->pid, SIGTERM); @@ -1358,18 +1358,18 @@ forkmda(struct mproc *p, uint64_t id, struct deliver *deliver) /* setup environment similar to other MTA */ idx = 0; - mda_environ[idx++] = xasprintf("PATH=%s", _PATH_DEFPATH); - mda_environ[idx++] = xasprintf("DOMAIN=%s", deliver->rcpt.domain); - mda_environ[idx++] = xasprintf("HOME=%s", pw_dir); - mda_environ[idx++] = xasprintf("RECIPIENT=%s@%s", deliver->dest.user, deliver->dest.domain); - mda_environ[idx++] = xasprintf("SHELL=/bin/sh"); - mda_environ[idx++] = xasprintf("LOCAL=%s", deliver->rcpt.user); - mda_environ[idx++] = xasprintf("LOGNAME=%s", pw_name); - mda_environ[idx++] = xasprintf("USER=%s", pw_name); + xasprintf(&mda_environ[idx++], "PATH=%s", _PATH_DEFPATH); + xasprintf(&mda_environ[idx++], "DOMAIN=%s", deliver->rcpt.domain); + xasprintf(&mda_environ[idx++], "HOME=%s", pw_dir); + xasprintf(&mda_environ[idx++], "RECIPIENT=%s@%s", deliver->dest.user, deliver->dest.domain); + xasprintf(&mda_environ[idx++], "SHELL=/bin/sh"); + xasprintf(&mda_environ[idx++], "LOCAL=%s", deliver->rcpt.user); + xasprintf(&mda_environ[idx++], "LOGNAME=%s", pw_name); + xasprintf(&mda_environ[idx++], "USER=%s", pw_name); if ((tag = strchr(deliver->rcpt.user, *env->sc_subaddressing_delim)) != NULL) if (strlen(tag+1)) - mda_environ[idx++] = xasprintf("EXTENSION=%s", tag+1); + xasprintf(&mda_environ[idx++], "EXTENSION=%s", tag+1); mda_environ[idx++] = (char *)NULL; diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 99364ae042b..cfaaeb74491 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.545 2018/05/29 21:05:52 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.546 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1487,11 +1487,11 @@ int rmtree(char *, int); int mvpurge(char *, char *); int mktmpfile(void); const char *parse_smtp_response(char *, size_t, char **, int *); -void *xasprintf(const char *, ...); -void *xmalloc(size_t, const char *); -void *xcalloc(size_t, size_t, const char *); -char *xstrdup(const char *, const char *); -void *xmemdup(const void *, size_t, const char *); +int xasprintf(char **, const char *, ...); +void *xmalloc(size_t); +void *xcalloc(size_t, size_t); +char *xstrdup(const char *); +void *xmemdup(const void *, size_t); char *strip(char *); int io_xprint(struct io *, const char *); int io_xprintf(struct io *, const char *, ...); diff --git a/usr.sbin/smtpd/stat_ramstat.c b/usr.sbin/smtpd/stat_ramstat.c index 6cefaa9ac5d..ede2e130234 100644 --- a/usr.sbin/smtpd/stat_ramstat.c +++ b/usr.sbin/smtpd/stat_ramstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stat_ramstat.c,v 1.10 2015/01/20 17:37:54 deraadt Exp $ */ +/* $OpenBSD: stat_ramstat.c,v 1.11 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> @@ -84,7 +84,7 @@ ramstat_increment(const char *name, size_t val) (void)strlcpy(lk.key, name, sizeof (lk.key)); np = RB_FIND(stats_tree, &stats, &lk); if (np == NULL) { - np = xcalloc(1, sizeof *np, "ramstat_increment"); + np = xcalloc(1, sizeof *np); (void)strlcpy(np->key, name, sizeof (np->key)); RB_INSERT(stats_tree, &stats, np); } @@ -102,7 +102,7 @@ ramstat_decrement(const char *name, size_t val) (void)strlcpy(lk.key, name, sizeof (lk.key)); np = RB_FIND(stats_tree, &stats, &lk); if (np == NULL) { - np = xcalloc(1, sizeof *np, "ramstat_decrement"); + np = xcalloc(1, sizeof *np); (void)strlcpy(np->key, name, sizeof (np->key)); RB_INSERT(stats_tree, &stats, np); } @@ -120,7 +120,7 @@ ramstat_set(const char *name, const struct stat_value *val) (void)strlcpy(lk.key, name, sizeof (lk.key)); np = RB_FIND(stats_tree, &stats, &lk); if (np == NULL) { - np = xcalloc(1, sizeof *np, "ramstat_set"); + np = xcalloc(1, sizeof *np); (void)strlcpy(np->key, name, sizeof (np->key)); RB_INSERT(stats_tree, &stats, np); } diff --git a/usr.sbin/smtpd/table.c b/usr.sbin/smtpd/table.c index 6d0870786d1..10e21d631e2 100644 --- a/usr.sbin/smtpd/table.c +++ b/usr.sbin/smtpd/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.28 2018/05/29 20:58:16 eric Exp $ */ +/* $OpenBSD: table.c,v 1.29 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -230,7 +230,7 @@ table_create(const char *backend, const char *name, const char *tag, if (tb == NULL) fatalx("table_create: backend \"%s\" does not exist", backend); - t = xcalloc(1, sizeof(*t), "table_create"); + t = xcalloc(1, sizeof(*t)); t->t_backend = tb; /* XXX */ @@ -298,7 +298,7 @@ table_add(struct table *t, const char *key, const char *val) return; } - old = dict_set(&t->t_dict, lkey, val ? xstrdup(val, "table_add") : NULL); + old = dict_set(&t->t_dict, lkey, val ? xstrdup(val) : NULL); if (old) { log_warnx("warn: duplicate key \"%s\" in static table \"%s\"", lkey, t->t_name); diff --git a/usr.sbin/smtpd/table_db.c b/usr.sbin/smtpd/table_db.c index fa56abc56eb..aeeed209e87 100644 --- a/usr.sbin/smtpd/table_db.c +++ b/usr.sbin/smtpd/table_db.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_db.c,v 1.9 2015/11/24 07:40:26 gilles Exp $ */ +/* $OpenBSD: table_db.c,v 1.10 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org> @@ -110,7 +110,7 @@ table_db_open(struct table *table) struct dbhandle *handle; struct stat sb; - handle = xcalloc(1, sizeof *handle, "table_db_open"); + handle = xcalloc(1, sizeof *handle); if (strlcpy(handle->pathname, table->t_config, sizeof handle->pathname) >= sizeof handle->pathname) goto error; @@ -219,7 +219,7 @@ table_db_get_entry_match(void *hdl, const char *key, size_t *len, for (r = handle->db->seq(handle->db, &dbk, &dbd, R_FIRST); !r; r = handle->db->seq(handle->db, &dbk, &dbd, R_NEXT)) { - buf = xmemdup(dbk.data, dbk.size, "table_db_get_entry_cmp"); + buf = xmemdup(dbk.data, dbk.size); if (func(key, buf)) { *len = dbk.size; return buf; @@ -249,5 +249,5 @@ table_db_get_entry(void *hdl, const char *key, size_t *len) *len = dbv.size; - return xmemdup(dbv.data, dbv.size, "table_db_get_entry"); + return xmemdup(dbv.data, dbv.size); } diff --git a/usr.sbin/smtpd/table_proc.c b/usr.sbin/smtpd/table_proc.c index e43c01d9aa8..27abbfe0dec 100644 --- a/usr.sbin/smtpd/table_proc.c +++ b/usr.sbin/smtpd/table_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table_proc.c,v 1.6 2015/12/05 13:14:21 claudio Exp $ */ +/* $OpenBSD: table_proc.c,v 1.7 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2013 Eric Faurot <eric@openbsd.org> @@ -123,7 +123,7 @@ table_proc_open(struct table *table) struct table_open_params op; int fd; - priv = xcalloc(1, sizeof(*priv), "table_proc_open"); + priv = xcalloc(1, sizeof(*priv)); fd = fork_proc_backend("table", table->t_config, table->t_name); if (fd == -1) diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index 7f2c7047eb4..ab7689974f2 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.135 2018/05/29 18:16:14 gilles Exp $ */ +/* $OpenBSD: util.c,v 1.136 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -60,73 +60,64 @@ int tracing = 0; int foreground_log = 0; void * -xmalloc(size_t size, const char *where) +xmalloc(size_t size) { void *r; - if ((r = malloc(size)) == NULL) { - log_warnx("%s: malloc(%zu)", where, size); - fatalx("exiting"); - } + if ((r = malloc(size)) == NULL) + fatal("malloc"); return (r); } void * -xcalloc(size_t nmemb, size_t size, const char *where) +xcalloc(size_t nmemb, size_t size) { void *r; - if ((r = calloc(nmemb, size)) == NULL) { - log_warnx("%s: calloc(%zu, %zu)", where, nmemb, size); - fatalx("exiting"); - } + if ((r = calloc(nmemb, size)) == NULL) + fatal("calloc"); return (r); } char * -xstrdup(const char *str, const char *where) +xstrdup(const char *str) { char *r; - if ((r = strdup(str)) == NULL) { - log_warnx("%s: strdup(%p)", where, str); - fatalx("exiting"); - } + if ((r = strdup(str)) == NULL) + fatal("strdup"); return (r); } void * -xmemdup(const void *ptr, size_t size, const char *where) +xmemdup(const void *ptr, size_t size) { void *r; - if ((r = malloc(size)) == NULL) { - log_warnx("%s: malloc(%zu)", where, size); - fatalx("exiting"); - } + if ((r = malloc(size)) == NULL) + fatal("malloc"); + memmove(r, ptr, size); return (r); } -void * -xasprintf(const char *format, ...) +int +xasprintf(char **ret, const char *format, ...) { - int ret; + int r; va_list ap; - char *retp = NULL; va_start(ap, format); - ret = vasprintf(&retp, format, ap); + r = vasprintf(ret, format, ap); va_end(ap); - if (ret == -1) { - log_warnx("asprintf(%p)", format); - fatalx("exiting"); - } - return retp; + if (r == -1) + fatal("vasprintf"); + + return (r); } diff --git a/usr.sbin/smtpd/waitq.c b/usr.sbin/smtpd/waitq.c index 5340ab7a8c5..dc459372016 100644 --- a/usr.sbin/smtpd/waitq.c +++ b/usr.sbin/smtpd/waitq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: waitq.c,v 1.5 2015/01/20 17:37:54 deraadt Exp $ */ +/* $OpenBSD: waitq.c,v 1.6 2018/05/31 21:06:12 gilles Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> @@ -69,13 +69,13 @@ waitq_wait(void *tag, void (*cb)(void *, void *, void *), void *arg) key.tag = tag; wq = SPLAY_FIND(waitqtree, &waitqs, &key); if (wq == NULL) { - wq = xmalloc(sizeof *wq, "waitq_wait"); + wq = xmalloc(sizeof *wq); wq->tag = tag; TAILQ_INIT(&wq->waiters); SPLAY_INSERT(waitqtree, &waitqs, wq); } - w = xmalloc(sizeof *w, "waitq_wait"); + w = xmalloc(sizeof *w); w->cb = cb; w->arg = arg; TAILQ_INSERT_TAIL(&wq->waiters, w, entry); |