summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/db/btree/bt_open.c5
-rw-r--r--lib/libc/db/hash/hash.c11
-rw-r--r--lib/libc/db/hash/hash_bigkey.c8
-rw-r--r--lib/libc/gen/auth_subr.c8
-rw-r--r--lib/libc/gen/getpwent.c20
-rw-r--r--lib/libc/gen/glob.c14
-rw-r--r--lib/libc/gen/login_cap.c8
-rw-r--r--lib/libc/net/freeaddrinfo.c5
-rw-r--r--lib/libc/regex/regcomp.c5
-rw-r--r--lib/libc/regex/regfree.c5
-rw-r--r--lib/libc/rpc/pmap_rmt.c5
-rw-r--r--lib/libc/stdio/asprintf.c8
-rw-r--r--lib/libc/stdio/vasprintf.c8
-rw-r--r--lib/libc/stdio/vfprintf.c11
-rw-r--r--lib/libc/stdio/vfwprintf.c20
-rw-r--r--lib/libc/stdlib/ecvt.c8
16 files changed, 53 insertions, 96 deletions
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
index b6a715cc7ef..f8ea301f1b8 100644
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_open.c,v 1.18 2014/09/15 06:12:19 guenther Exp $ */
+/* $OpenBSD: bt_open.c,v 1.19 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -318,8 +318,7 @@ eftype: errno = EFTYPE;
err: saved_errno = errno;
if (t) {
- if (t->bt_dbp)
- free(t->bt_dbp);
+ free(t->bt_dbp);
if (t->bt_fd != -1)
(void)close(t->bt_fd);
free(t);
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index 7578e507da4..5b1c2980362 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hash.c,v 1.27 2015/11/01 03:45:28 guenther Exp $ */
+/* $OpenBSD: hash.c,v 1.28 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -407,12 +407,9 @@ hdestroy(HTAB *hashp)
save_errno = errno;
/* Free Bigmaps */
for (i = 0; i < hashp->nmaps; i++)
- if (hashp->mapp[i])
- free(hashp->mapp[i]);
- if (hashp->tmp_key)
- free(hashp->tmp_key);
- if (hashp->tmp_buf)
- free(hashp->tmp_buf);
+ free(hashp->mapp[i]);
+ free(hashp->tmp_key);
+ free(hashp->tmp_buf);
if (hashp->fp != -1)
(void)close(hashp->fp);
diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c
index 18682cc1b28..c98165432ba 100644
--- a/lib/libc/db/hash/hash_bigkey.c
+++ b/lib/libc/db/hash/hash_bigkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hash_bigkey.c,v 1.18 2015/01/16 16:48:51 deraadt Exp $ */
+/* $OpenBSD: hash_bigkey.c,v 1.19 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -452,8 +452,7 @@ collect_data(HTAB *hashp, BUFHEAD *bufp, int len, int set)
if (bp[2] == FULL_KEY_DATA) { /* End of Data */
totlen = len + mylen;
- if (hashp->tmp_buf)
- free(hashp->tmp_buf);
+ free(hashp->tmp_buf);
if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL)
return (-1);
if (set) {
@@ -518,8 +517,7 @@ collect_key(HTAB *hashp, BUFHEAD *bufp, int len, DBT *val, int set)
save_addr = bufp->addr;
totlen = len + mylen;
if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */
- if (hashp->tmp_key != NULL)
- free(hashp->tmp_key);
+ free(hashp->tmp_key);
if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL)
return (-1);
if (__big_return(hashp, bufp, 1, val, set))
diff --git a/lib/libc/gen/auth_subr.c b/lib/libc/gen/auth_subr.c
index 9fd6d442121..b7d904a5f36 100644
--- a/lib/libc/gen/auth_subr.c
+++ b/lib/libc/gen/auth_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth_subr.c,v 1.49 2015/11/24 22:03:33 millert Exp $ */
+/* $OpenBSD: auth_subr.c,v 1.50 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 2000-2002,2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -313,10 +313,8 @@ auth_challenge(auth_session_t *as)
as->state = 0;
- if (as->challenge) {
- free(as->challenge);
- as->challenge = NULL;
- }
+ free(as->challenge);
+ as->challenge = NULL;
auth_call(as, path, as->style, "-s", "challenge", as->name,
as->class, (char *)NULL);
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c
index 81a834d6fe6..cfd0d2e4f98 100644
--- a/lib/libc/gen/getpwent.c
+++ b/lib/libc/gen/getpwent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getpwent.c,v 1.59 2015/12/01 15:08:25 deraadt Exp $ */
+/* $OpenBSD: getpwent.c,v 1.60 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 2008 Theo de Raadt
* Copyright (c) 1988, 1993
@@ -553,10 +553,8 @@ __yppwlookup(int lookup, char *name, uid_t uid, struct passwd *pw,
switch (pw->pw_name[1]) {
case '\0':
- if (ypcurrent) {
- free(ypcurrent);
- ypcurrent = NULL;
- }
+ free(ypcurrent);
+ ypcurrent = NULL;
r = yp_match(__ypdomain, map,
name, strlen(name),
&ypcurrent, &ypcurrentlen);
@@ -568,10 +566,8 @@ __yppwlookup(int lookup, char *name, uid_t uid, struct passwd *pw,
break;
case '@':
pwnam_netgrp:
- if (ypcurrent) {
- free(ypcurrent);
- ypcurrent = NULL;
- }
+ free(ypcurrent);
+ ypcurrent = NULL;
if (s == -1) /* first time */
setnetgrent(pw->pw_name + 2);
s = getnetgrent(&host, &user, &dom);
@@ -599,10 +595,8 @@ pwnam_netgrp:
}
break;
default:
- if (ypcurrent) {
- free(ypcurrent);
- ypcurrent = NULL;
- }
+ free(ypcurrent);
+ ypcurrent = NULL;
user = pw->pw_name + 1;
r = yp_match(__ypdomain, map,
user, strlen(user),
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c
index e098992f4b5..e521dcd098d 100644
--- a/lib/libc/gen/glob.c
+++ b/lib/libc/gen/glob.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glob.c,v 1.45 2015/11/24 22:03:33 millert Exp $ */
+/* $OpenBSD: glob.c,v 1.46 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -810,14 +810,10 @@ globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp,
pglob->gl_pathv && pglob->gl_pathv[i])
free(pglob->gl_statv[i]);
}
- if (pglob->gl_pathv) {
- free(pglob->gl_pathv);
- pglob->gl_pathv = NULL;
- }
- if (pglob->gl_statv) {
- free(pglob->gl_statv);
- pglob->gl_statv = NULL;
- }
+ free(pglob->gl_pathv);
+ pglob->gl_pathv = NULL;
+ free(pglob->gl_statv);
+ pglob->gl_statv = NULL;
return(GLOB_NOSPACE);
}
diff --git a/lib/libc/gen/login_cap.c b/lib/libc/gen/login_cap.c
index ccbd303bf91..4f32f3f61f7 100644
--- a/lib/libc/gen/login_cap.c
+++ b/lib/libc/gen/login_cap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login_cap.c,v 1.32 2015/09/14 16:09:13 tedu Exp $ */
+/* $OpenBSD: login_cap.c,v 1.33 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 2000-2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -164,10 +164,8 @@ login_getstyle(login_cap_t *lc, char *style, char *atype)
if (style && strcmp(style, "s/key") == 0)
style = "skey";
- if (lc->lc_style) {
- free(lc->lc_style);
- lc->lc_style = NULL;
- }
+ free(lc->lc_style);
+ lc->lc_style = NULL;
if (!atype || !(auths = login_getcapstr(lc, atype, NULL, NULL)))
auths = login_getcapstr(lc, "auth", NULL, NULL);
diff --git a/lib/libc/net/freeaddrinfo.c b/lib/libc/net/freeaddrinfo.c
index 5efb97db921..2ac84a31f3b 100644
--- a/lib/libc/net/freeaddrinfo.c
+++ b/lib/libc/net/freeaddrinfo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: freeaddrinfo.c,v 1.7 2015/09/14 07:38:38 guenther Exp $ */
+/* $OpenBSD: freeaddrinfo.c,v 1.8 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 1999, Craig Metz, All rights reserved.
@@ -43,8 +43,7 @@ freeaddrinfo(struct addrinfo *ai)
do {
p = ai;
ai = ai->ai_next;
- if (p->ai_canonname)
- free(p->ai_canonname);
+ free(p->ai_canonname);
free((void *)p);
} while (ai);
}
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index f02b753f8ac..e455a571c68 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regcomp.c,v 1.27 2015/11/01 03:45:29 guenther Exp $ */
+/* $OpenBSD: regcomp.c,v 1.28 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -1184,8 +1184,7 @@ mcadd( struct parse *p, cset *cs, char *cp)
cs->smultis += strlen(cp) + 1;
np = realloc(cs->multis, cs->smultis);
if (np == NULL) {
- if (cs->multis)
- free(cs->multis);
+ free(cs->multis);
cs->multis = NULL;
SETERROR(REG_ESPACE);
return;
diff --git a/lib/libc/regex/regfree.c b/lib/libc/regex/regfree.c
index 82f506ab826..ae962745ab4 100644
--- a/lib/libc/regex/regfree.c
+++ b/lib/libc/regex/regfree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regfree.c,v 1.9 2015/09/14 12:22:49 guenther Exp $ */
+/* $OpenBSD: regfree.c,v 1.10 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
* Copyright (c) 1992, 1993, 1994
@@ -66,8 +66,7 @@ regfree(regex_t *preg)
free((char *)g->sets);
if (g->setbits != NULL)
free((char *)g->setbits);
- if (g->must != NULL)
- free(g->must);
+ free(g->must);
free((char *)g);
}
DEF_WEAK(regfree);
diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c
index 58f8ac31008..50237f324c2 100644
--- a/lib/libc/rpc/pmap_rmt.c
+++ b/lib/libc/rpc/pmap_rmt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_rmt.c,v 1.33 2015/09/13 15:36:56 guenther Exp $ */
+/* $OpenBSD: pmap_rmt.c,v 1.34 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@@ -373,8 +373,7 @@ clnt_broadcast(u_long prog, /* program number */
}
}
done_broad:
- if (addrs)
- free(addrs);
+ free(addrs);
if (sock >= 0)
(void)close(sock);
if (unix_auth != NULL)
diff --git a/lib/libc/stdio/asprintf.c b/lib/libc/stdio/asprintf.c
index bd12726fbf0..48236775908 100644
--- a/lib/libc/stdio/asprintf.c
+++ b/lib/libc/stdio/asprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asprintf.c,v 1.21 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: asprintf.c,v 1.22 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -52,10 +52,8 @@ asprintf(char **str, const char *fmt, ...)
return (ret);
err:
- if (f._bf._base) {
- free(f._bf._base);
- f._bf._base = NULL;
- }
+ free(f._bf._base);
+ f._bf._base = NULL;
*str = NULL;
errno = ENOMEM;
return (-1);
diff --git a/lib/libc/stdio/vasprintf.c b/lib/libc/stdio/vasprintf.c
index 11d90a4b187..98cdb45549f 100644
--- a/lib/libc/stdio/vasprintf.c
+++ b/lib/libc/stdio/vasprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vasprintf.c,v 1.18 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: vasprintf.c,v 1.19 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -48,10 +48,8 @@ vasprintf(char **str, const char *fmt, __va_list ap)
return (ret);
err:
- if (f._bf._base) {
- free(f._bf._base);
- f._bf._base = NULL;
- }
+ free(f._bf._base);
+ f._bf._base = NULL;
*str = NULL;
errno = ENOMEM;
return (-1);
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 1e55ad7f494..aa971796342 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfprintf.c,v 1.69 2015/09/29 03:19:24 guenther Exp $ */
+/* $OpenBSD: vfprintf.c,v 1.70 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -846,10 +846,8 @@ fp_common:
if (flags & LONGINT) {
wchar_t *wcp;
- if (convbuf != NULL) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
+ convbuf = NULL;
if ((wcp = GETARG(wchar_t *)) == NULL) {
cp = "(null)";
} else {
@@ -1075,8 +1073,7 @@ overflow:
finish:
#ifdef PRINTF_WIDE_CHAR
- if (convbuf)
- free(convbuf);
+ free(convbuf);
#endif
#ifdef FLOATING_POINT
if (dtoaresult)
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index be83aabe7ef..520c8bc7d22 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfwprintf.c,v 1.14 2015/09/29 03:19:24 guenther Exp $ */
+/* $OpenBSD: vfwprintf.c,v 1.15 2015/12/28 22:08:18 mmcc Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -667,10 +667,7 @@ reswitch: switch (ch) {
prec = dtoaend - dtoaresult;
if (expt == INT_MAX)
ox[1] = '\0';
- if (convbuf) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
cp = convbuf = __mbsconv(dtoaresult, -1);
if (cp == NULL)
goto error;
@@ -719,10 +716,7 @@ fp_begin:
if (expt == 9999)
expt = INT_MAX;
}
- if (convbuf) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
cp = convbuf = __mbsconv(dtoaresult, -1);
if (cp == NULL)
goto error;
@@ -828,10 +822,7 @@ fp_common:
char *mbsarg;
if ((mbsarg = GETARG(char *)) == NULL)
mbsarg = "(null)";
- if (convbuf) {
- free(convbuf);
- convbuf = NULL;
- }
+ free(convbuf);
convbuf = __mbsconv(mbsarg, prec);
if (convbuf == NULL) {
fp->_flags |= __SERR;
@@ -1047,8 +1038,7 @@ overflow:
ret = -1;
finish:
- if (convbuf)
- free(convbuf);
+ free(convbuf);
#ifdef FLOATING_POINT
if (dtoaresult)
__freedtoa(dtoaresult);
diff --git a/lib/libc/stdlib/ecvt.c b/lib/libc/stdlib/ecvt.c
index a0bbbec0737..dfcf45fe6c5 100644
--- a/lib/libc/stdlib/ecvt.c
+++ b/lib/libc/stdlib/ecvt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ecvt.c,v 1.9 2015/08/20 21:49:29 deraadt Exp $ */
+/* $OpenBSD: ecvt.c,v 1.10 2015/12/28 22:08:18 mmcc Exp $ */
/*
* Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -40,10 +40,8 @@ __cvt(double value, int ndigit, int *decpt, int *sign, int fmode, int pad)
return ("");
}
- if (s) {
- free(s);
- s = NULL;
- }
+ free(s);
+ s = NULL;
if (ndigit < 0)
siz = -ndigit + 1;