Re: [PATCH 10] inetd: malloc/memset => calloc
bump. anybody? On Sat, 31 May 2014 16:40:35 +0200 Benjamin Baier wrote: > While here also stop casting {m,c}alloc return value. > Index: inetd.c === RCS file: /cvs/src/usr.sbin/inetd/inetd.c,v retrieving revision 1.137 diff -u -p -r1.137 inetd.c --- inetd.c 23 Nov 2013 17:24:29 - 1.137 +++ inetd.c 31 May 2014 13:58:00 - @@ -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,14 +1510,12 @@ 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;
[PATCH 10] inetd: malloc/memset => calloc
While here also stop casting {m,c}alloc return value. Index: inetd.c === RCS file: /cvs/src/usr.sbin/inetd/inetd.c,v retrieving revision 1.137 diff -u -p -r1.137 inetd.c --- inetd.c 23 Nov 2013 17:24:29 - 1.137 +++ inetd.c 31 May 2014 13:58:00 - @@ -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,14 +1510,12 @@ 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;