summaryrefslogtreecommitdiffstats
path: root/usr.sbin/inetd
diff options
context:
space:
mode:
authorlteo <lteo@openbsd.org>2014-06-17 03:12:37 +0000
committerlteo <lteo@openbsd.org>2014-06-17 03:12:37 +0000
commita31c5aa33f6d4f93581ba82cec1c3b8c04330297 (patch)
tree4e0ba96e98554c6983c86d94c5e27685a5585504 /usr.sbin/inetd
parentansi function declarations. (diff)
downloadwireguard-openbsd-a31c5aa33f6d4f93581ba82cec1c3b8c04330297.tar.xz
wireguard-openbsd-a31c5aa33f6d4f93581ba82cec1c3b8c04330297.zip
Convert malloc/memset to calloc, and remove pointless casts while here.
From Benjamin Baier.
Diffstat (limited to 'usr.sbin/inetd')
-rw-r--r--usr.sbin/inetd/inetd.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c
index 64597bec4e7..02032df2b27 100644
--- a/usr.sbin/inetd/inetd.c
+++ b/usr.sbin/inetd/inetd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inetd.c,v 1.137 2013/11/23 17:24:29 deraadt Exp $ */
+/* $OpenBSD: inetd.c,v 1.138 2014/06/17 03:12:37 lteo Exp $ */
/*
* Copyright (c) 1983,1991 The Regents of the University of California.
@@ -455,7 +455,7 @@ main(int argc, char *argv[])
if (readablen != allsockn) {
if (fdsrp)
free(fdsrp);
- fdsrp = (fd_set *)calloc(allsockn, 1);
+ fdsrp = calloc(allsockn, 1);
if (fdsrp == NULL) {
syslog(LOG_ERR, "Out of memory.");
exit(1);
@@ -1085,7 +1085,7 @@ enter(struct servtab *cp)
struct servtab *sep;
sigset_t omask;
- sep = (struct servtab *)malloc(sizeof (*sep));
+ sep = malloc(sizeof (*sep));
if (sep == NULL) {
syslog(LOG_ERR, "Out of memory.");
exit(1);
@@ -1180,13 +1180,11 @@ getconfigent(void)
char *arg, *cp, *hostdelim, *s;
int argc;
- sep = (struct servtab *) malloc(sizeof(struct servtab));
+ sep = calloc(1, sizeof(struct servtab));
if (sep == NULL) {
- syslog(LOG_ERR, "malloc: %m");
+ syslog(LOG_ERR, "calloc: %m");
exit(1);
}
-
- memset(sep, 0, sizeof *sep);
more:
freeconfig(sep);
@@ -1512,15 +1510,13 @@ dupconfig(struct servtab *sep)
struct servtab *newtab;
int argc;
- newtab = (struct servtab *) malloc(sizeof(struct servtab));
+ newtab = calloc(1, sizeof(struct servtab));
if (newtab == NULL) {
- syslog(LOG_ERR, "malloc: %m");
+ syslog(LOG_ERR, "calloc: %m");
exit(1);
}
- memset(newtab, 0, sizeof(struct servtab));
-
newtab->se_service = sep->se_service ? newstr(sep->se_service) : NULL;
newtab->se_socktype = sep->se_socktype;
newtab->se_family = sep->se_family;