summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/inet/rpc/auth_unix.c3
-rw-r--r--libc/inet/rpc/getrpcent.c9
-rw-r--r--libc/inet/rpc/rcmd.c11
-rw-r--r--libc/misc/glob/glob.c3
-rw-r--r--libc/misc/regex/regex_old.c11
-rw-r--r--libc/misc/search/_hsearch_r.c5
-rw-r--r--libc/misc/wordexp/wordexp.c30
-rw-r--r--libc/stdio/open_memstream.c4
-rw-r--r--libc/stdlib/_atexit.c3
-rw-r--r--libc/sysdeps/linux/common/getgroups.c3
-rw-r--r--libc/sysdeps/linux/common/setgroups.c3
-rw-r--r--libc/unistd/usershell.c9
12 files changed, 31 insertions, 63 deletions
diff --git a/libc/inet/rpc/auth_unix.c b/libc/inet/rpc/auth_unix.c
index 8015e4f61..0654b51c1 100644
--- a/libc/inet/rpc/auth_unix.c
+++ b/libc/inet/rpc/auth_unix.c
@@ -212,8 +212,7 @@ authunix_create_default (void)
list of groups to NGRPS members since the code in
authuxprot.c transforms a fixed array. Grrr. */
ret_auth = authunix_create (machname, uid, gid, MIN (NGRPS, len), gids);
- if (gids)
- free (gids);
+ free (gids);
return ret_auth;
}
libc_hidden_def(authunix_create_default)
diff --git a/libc/inet/rpc/getrpcent.c b/libc/inet/rpc/getrpcent.c
index 7b9b93758..186bd130f 100644
--- a/libc/inet/rpc/getrpcent.c
+++ b/libc/inet/rpc/getrpcent.c
@@ -93,10 +93,8 @@ void endrpcent(void)
return;
if (d->stayopen)
return;
- if (d->current) {
- free(d->current);
- d->current = NULL;
- }
+ free(d->current);
+ d->current = NULL;
if (d->rpcf) {
fclose(d->rpcf);
d->rpcf = NULL;
@@ -115,8 +113,7 @@ void setrpcent(int f)
d->rpcf = fopen(RPCDB, "r");
else
rewind(d->rpcf);
- if (d->current)
- free(d->current);
+ free(d->current);
d->current = NULL;
d->stayopen |= f;
}
diff --git a/libc/inet/rpc/rcmd.c b/libc/inet/rpc/rcmd.c
index 47b92751b..6a9b437bf 100644
--- a/libc/inet/rpc/rcmd.c
+++ b/libc/inet/rpc/rcmd.c
@@ -197,9 +197,7 @@ int rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
#ifdef __ARCH_USE_MMU__
tmphstbuf = alloca (hstbuflen);
#else
- if (tmphstbuf) {
- free(tmphstbuf);
- }
+ free(tmphstbuf);
tmphstbuf = malloc (hstbuflen);
#endif
}
@@ -411,9 +409,7 @@ int ruserok(rhost, superuser, ruser, luser)
#ifdef __ARCH_USE_MMU__
buffer = alloca (buflen);
#else
- if (buffer) {
- free(buffer);
- }
+ free(buffer);
buffer = malloc (buflen);
#endif
}
@@ -780,8 +776,7 @@ __ivaliduser2(hostf, raddr, luser, ruser, rhost)
}
}
- if (buf != NULL)
- free (buf);
+ free (buf);
return retval;
}
diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c
index 00c49688f..8d3e3c450 100644
--- a/libc/misc/glob/glob.c
+++ b/libc/misc/glob/glob.c
@@ -482,8 +482,7 @@ static int glob_in_dir (const char *pattern, const char *directory, int flags,
}
while (names != NULL)
{
- if (names->name != NULL)
- free (names->name);
+ free (names->name);
names = names->next;
}
return GLOB_NOSPACE;
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index 57b97ae68..7a9c4d7e0 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -5132,7 +5132,7 @@ strong_alias(__re_search_2, re_search_2)
#ifdef MATCH_MAY_ALLOCATE
# define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL
#else
-# define FREE_VAR(var) if (var) free (var); var = NULL
+# define FREE_VAR(var) free (var); var = NULL
#endif
#ifdef WCHAR
@@ -8313,20 +8313,17 @@ void
regfree (preg)
regex_t *preg;
{
- if (preg->buffer != NULL)
- free (preg->buffer);
+ free (preg->buffer);
preg->buffer = NULL;
preg->allocated = 0;
preg->used = 0;
- if (preg->fastmap != NULL)
- free (preg->fastmap);
+ free (preg->fastmap);
preg->fastmap = NULL;
preg->fastmap_accurate = 0;
- if (preg->translate != NULL)
- free (preg->translate);
+ free (preg->translate);
preg->translate = NULL;
}
#if defined _LIBC || defined __UCLIBC__
diff --git a/libc/misc/search/_hsearch_r.c b/libc/misc/search/_hsearch_r.c
index 257c0610c..c9c4a9ccf 100644
--- a/libc/misc/search/_hsearch_r.c
+++ b/libc/misc/search/_hsearch_r.c
@@ -110,9 +110,8 @@ void hdestroy_r (struct hsearch_data *htab)
return;
}
- if (htab->table != NULL)
- /* free used memory */
- free (htab->table);
+ /* free used memory */
+ free (htab->table);
/* the sign for an existing table is an value != NULL in htable */
htab->table = NULL;
diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c
index 6872a65ba..45d5a876e 100644
--- a/libc/misc/wordexp/wordexp.c
+++ b/libc/misc/wordexp/wordexp.c
@@ -1076,8 +1076,7 @@ parse_comm(char **word, size_t * word_length, size_t * max_length,
}
/* Premature end */
- if (comm)
- free(comm);
+ free(comm);
return WRDE_SYNTAX;
}
@@ -1370,8 +1369,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
&buffer[20]);
*word = w_addstr(*word, word_length, max_length, value);
free(env);
- if (pattern)
- free(pattern);
+ free(pattern);
return *word ? 0 : WRDE_NOSPACE;
}
/* Is it `$*' or `$@' (unquoted) ? */
@@ -1530,8 +1528,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (free_value)
free(value);
- if (expanded)
- free(expanded);
+ free(expanded);
goto do_error;
}
@@ -1550,8 +1547,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (free_value)
free(value);
- if (expanded)
- free(expanded);
+ free(expanded);
goto do_error;
}
@@ -1573,8 +1569,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
goto no_space;
}
- if (pattern)
- free(pattern);
+ free(pattern);
pattern = expanded;
}
@@ -1723,7 +1718,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
/* Substitute parameter */
break;
- if (free_value && value)
+ if (free_value)
free(value);
if (!colon_seen && value)
@@ -1740,7 +1735,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
case ACT_NONNULL_SUBST:
if (value && (*value || !colon_seen)) {
- if (free_value && value)
+ if (free_value)
free(value);
value = pattern ? strdup(pattern) : pattern;
@@ -1769,7 +1764,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
goto success;
}
- if (free_value && value)
+ if (free_value)
free(value);
value = pattern ? strdup(pattern) : pattern;
@@ -1895,11 +1890,9 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
error = WRDE_SYNTAX;
do_error:
- if (env)
- free(env);
+ free(env);
- if (pattern)
- free(pattern);
+ free(pattern);
return error;
}
@@ -2269,8 +2262,7 @@ int wordexp(const char *words, wordexp_t * we, int flags)
* set we members back to what they were.
*/
- if (word != NULL)
- free(word);
+ free(word);
if (error == WRDE_NOSPACE)
return WRDE_NOSPACE;
diff --git a/libc/stdio/open_memstream.c b/libc/stdio/open_memstream.c
index 71c437c78..a9327608a 100644
--- a/libc/stdio/open_memstream.c
+++ b/libc/stdio/open_memstream.c
@@ -160,9 +160,7 @@ FILE *open_memstream(char **__restrict bufloc, size_t *__restrict sizeloc)
}
}
- if (cookie->buf != NULL) {
- free(cookie->buf);
- }
+ free(cookie->buf);
EXIT_cookie:
free(cookie);
diff --git a/libc/stdlib/_atexit.c b/libc/stdlib/_atexit.c
index a27a4a199..21aa30c81 100644
--- a/libc/stdlib/_atexit.c
+++ b/libc/stdlib/_atexit.c
@@ -298,8 +298,7 @@ void __exit_handler(int status)
}
#ifdef __UCLIBC_DYNAMIC_ATEXIT__
/* Free up memory used by the __exit_function_table structure */
- if (__exit_function_table)
- free(__exit_function_table);
+ free(__exit_function_table);
#endif
}
#endif
diff --git a/libc/sysdeps/linux/common/getgroups.c b/libc/sysdeps/linux/common/getgroups.c
index b2f34ed2f..10da03ddd 100644
--- a/libc/sysdeps/linux/common/getgroups.c
+++ b/libc/sysdeps/linux/common/getgroups.c
@@ -53,8 +53,7 @@ ret_error:
}
}
- if (kernel_groups)
- free(kernel_groups);
+ free(kernel_groups);
return ngids;
}
}
diff --git a/libc/sysdeps/linux/common/setgroups.c b/libc/sysdeps/linux/common/setgroups.c
index 7bfcc6c20..eb5245d59 100644
--- a/libc/sysdeps/linux/common/setgroups.c
+++ b/libc/sysdeps/linux/common/setgroups.c
@@ -56,8 +56,7 @@ ret_error:
}
i = __syscall_setgroups(size, kernel_groups);
- if (kernel_groups)
- free(kernel_groups);
+ free(kernel_groups);
return i;
}
}
diff --git a/libc/unistd/usershell.c b/libc/unistd/usershell.c
index ea4a04ba4..4a9ba0bca 100644
--- a/libc/unistd/usershell.c
+++ b/libc/unistd/usershell.c
@@ -80,13 +80,9 @@ char * getusershell(void)
static void __free_initshell_memory(void)
{
- if (shells != NULL) {
- free(shells);
- }
+ free(shells);
shells = NULL;
- if (strings != NULL) {
- free(strings);
- }
+ free(strings);
strings = NULL;
}
@@ -98,7 +94,6 @@ void endusershell(void)
void setusershell(void)
{
-
curshell = initshells();
}