about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-03-19 06:43:34 +0000
committerUlrich Drepper <drepper@redhat.com>2008-03-19 06:43:34 +0000
commit72e6cdfa2cd95240439c72705ab28a2eebb7d04e (patch)
treeae830b7817948dc795cc92ec98216c478dde57e3
parent354b75277bc86768eafbbf5f590deb27e0a71d89 (diff)
downloadglibc-72e6cdfa2cd95240439c72705ab28a2eebb7d04e.tar.gz
glibc-72e6cdfa2cd95240439c72705ab28a2eebb7d04e.tar.xz
glibc-72e6cdfa2cd95240439c72705ab28a2eebb7d04e.zip
Remove useless "if" before "free".
-rw-r--r--elf/ldconfig.c3
-rw-r--r--gmon/gmon.c3
-rw-r--r--iconv/gconv_conf.c3
-rw-r--r--inet/rcmd.c3
-rw-r--r--intl/bindtextdom.c3
-rw-r--r--intl/loadmsgcat.c9
-rw-r--r--libidn/stringprep.c6
-rw-r--r--libio/genops.c3
-rw-r--r--libio/wgenops.c3
-rw-r--r--locale/programs/ld-collate.c12
-rw-r--r--locale/programs/linereader.c3
-rw-r--r--nis/nss_compat/compat-pwd.c15
-rw-r--r--nis/nss_compat/compat-spwd.c6
-rw-r--r--resolv/res_debug.c3
-rw-r--r--sunrpc/xdr_sizeof.c6
-rw-r--r--sysdeps/mach/hurd/if_index.c3
-rw-r--r--sysdeps/posix/sprofil.c3
-rw-r--r--time/lc-time-cleanup.c9
-rw-r--r--time/tzset.c3
19 files changed, 33 insertions, 66 deletions
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 75ff79a9cf..e4dfdf5036 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -1184,8 +1184,7 @@ parse_conf_include (const char *config_file, unsigned int lineno,
       break;
     }
 
-  if (copy)
-    free (copy);
+  free (copy);
 }
 
 /* Honour LD_HWCAP_MASK.  */
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 1e94aaba5f..8e2eddd0bc 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -396,6 +396,5 @@ _mcleanup (void)
     write_gmon ();
 
   /* free the memory. */
-  if (_gmonparam.tos != NULL)
-    free (_gmonparam.tos);
+  free (_gmonparam.tos);
 }
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 22ffa4f41c..2023beb267 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -529,8 +529,7 @@ __gconv_get_path (void)
 
       __gconv_path_elem = result ?: (struct path_elem *) &empty_path_elem;
 
-      if (cwd != NULL)
-	free (cwd);
+      free (cwd);
     }
 
   __libc_lock_unlock (lock);
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 341304acd5..5dcbd25568 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -826,8 +826,7 @@ __validuser2_sa(hostf, ra, ralen, luser, ruser, rhost)
 	}
     }
 
-    if (buf != NULL)
-      free (buf);
+    free (buf);
 
     return retval;
 }
diff --git a/intl/bindtextdom.c b/intl/bindtextdom.c
index fd527a180a..7a956d4471 100644
--- a/intl/bindtextdom.c
+++ b/intl/bindtextdom.c
@@ -203,8 +203,7 @@ set_binding_values (domainname, dirnamep, codesetp)
 
 		  if (__builtin_expect (result != NULL, 1))
 		    {
-		      if (binding->codeset != NULL)
-			free (binding->codeset);
+		      free (binding->codeset);
 
 		      binding->codeset = result;
 		      modified = 1;
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 537fd6013c..3cba7b1491 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -1236,8 +1236,7 @@ _nl_load_domain (domain_file, domainbinding)
       /* This is an invalid revision.  */
     invalid:
       /* This is an invalid .mo file.  */
-      if (domain->malloced)
-	free (domain->malloced);
+      free (domain->malloced);
 #ifdef HAVE_MMAP
       if (use_mmap)
 	munmap ((caddr_t) data, size);
@@ -1289,12 +1288,10 @@ _nl_unload_domain (domain)
       if (convd->conv != (__gconv_t) -1)
 	__gconv_close (convd->conv);
     }
-  if (domain->conversions != NULL)
-    free (domain->conversions);
+  free (domain->conversions);
   __libc_rwlock_fini (domain->conversions_lock);
 
-  if (domain->malloced)
-    free (domain->malloced);
+  free (domain->malloced);
 
 # ifdef _POSIX_MAPPED_FILES
   if (domain->use_mmap)
diff --git a/libidn/stringprep.c b/libidn/stringprep.c
index 6041e3937a..f5c9fae073 100644
--- a/libidn/stringprep.c
+++ b/libidn/stringprep.c
@@ -366,8 +366,7 @@ stringprep (char *in,
 
   do
     {
-      if (ucs4)
-	free (ucs4);
+      free (ucs4);
       ucs4 = stringprep_utf8_to_ucs4 (in, -1, &ucs4len);
       maxucs4len = ucs4len + adducs4len;
       uint32_t *newp = realloc (ucs4, maxucs4len * sizeof (uint32_t));
@@ -449,8 +448,7 @@ stringprep_profile (const char *in,
 
   do
     {
-      if (str)
-	free (str);
+      free (str);
       str = (char *) malloc (len);
       if (str == NULL)
 	return STRINGPREP_MALLOC_ERROR;
diff --git a/libio/genops.c b/libio/genops.c
index 7005fdbd96..481fbc52b0 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -300,8 +300,7 @@ save_for_backup (fp, end_p)
 	memcpy (new_buffer + avail,
 		fp->_IO_read_base + least_mark,
 		needed_size);
-      if (fp->_IO_save_base)
-	free (fp->_IO_save_base);
+      free (fp->_IO_save_base);
       fp->_IO_save_base = new_buffer;
       fp->_IO_save_end = new_buffer + avail + needed_size;
     }
diff --git a/libio/wgenops.c b/libio/wgenops.c
index 760a413dc3..e2adedd6d4 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -553,8 +553,7 @@ save_for_wbackup (fp, end_p)
 		  needed_size * sizeof (wchar_t));
 #endif
 	}
-      if (fp->_wide_data->_IO_save_base)
-	free (fp->_wide_data->_IO_save_base);
+      free (fp->_wide_data->_IO_save_base);
       fp->_wide_data->_IO_save_base = new_buffer;
       fp->_wide_data->_IO_save_end = new_buffer + avail + needed_size;
     }
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 227e764a6c..f72516c87b 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -2963,10 +2963,8 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
 		col_elem_free:
 		  if (symbol != NULL)
 		    free ((char *) symbol);
-		  if (arg->val.str.startmb != NULL)
-		    free (arg->val.str.startmb);
-		  if (arg->val.str.startwc != NULL)
-		    free (arg->val.str.startwc);
+		  free (arg->val.str.startmb);
+		  free (arg->val.str.startwc);
 		}
 	      lr_ignore_rest (ldfile, 1);
 	    }
@@ -3112,10 +3110,8 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
 	      else
 		{
 		col_sym_free:
-		  if (symbol != NULL)
-		    free (symbol);
-		  if (endsymbol != NULL)
-		    free (endsymbol);
+		  free (symbol);
+		  free (endsymbol);
 		}
 	    }
 	  break;
diff --git a/locale/programs/linereader.c b/locale/programs/linereader.c
index 8a04e32276..2e20e5d778 100644
--- a/locale/programs/linereader.c
+++ b/locale/programs/linereader.c
@@ -859,8 +859,7 @@ non-symbolic character value should not be used"));
       if (illegal_string)
 	{
 	  free (buf);
-	  if (buf2 != NULL)
-	    free (buf2);
+	  free (buf2);
 	  lr->token.val.str.startmb = NULL;
 	  lr->token.val.str.lenmb = 0;
 	  lr->token.val.str.startwc = NULL;
diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c
index df8f91eea0..669522f21a 100644
--- a/nis/nss_compat/compat-pwd.c
+++ b/nis/nss_compat/compat-pwd.c
@@ -116,16 +116,11 @@ init_nss_interface (void)
 static void
 give_pwd_free (struct passwd *pwd)
 {
-  if (pwd->pw_name != NULL)
-    free (pwd->pw_name);
-  if (pwd->pw_passwd != NULL)
-    free (pwd->pw_passwd);
-  if (pwd->pw_gecos != NULL)
-    free (pwd->pw_gecos);
-  if (pwd->pw_dir != NULL)
-    free (pwd->pw_dir);
-  if (pwd->pw_shell != NULL)
-    free (pwd->pw_shell);
+  free (pwd->pw_name);
+  free (pwd->pw_passwd);
+  free (pwd->pw_gecos);
+  free (pwd->pw_dir);
+  free (pwd->pw_shell);
 
   memset (pwd, '\0', sizeof (struct passwd));
 }
diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c
index a5977681f2..95f7355945 100644
--- a/nis/nss_compat/compat-spwd.c
+++ b/nis/nss_compat/compat-spwd.c
@@ -113,10 +113,8 @@ init_nss_interface (void)
 static void
 give_spwd_free (struct spwd *pwd)
 {
-  if (pwd->sp_namp != NULL)
-    free (pwd->sp_namp);
-  if (pwd->sp_pwdp != NULL)
-    free (pwd->sp_pwdp);
+  free (pwd->sp_namp);
+  free (pwd->sp_pwdp);
 
   memset (pwd, '\0', sizeof (struct spwd));
   pwd->sp_warn = -1;
diff --git a/resolv/res_debug.c b/resolv/res_debug.c
index d9f1607df6..cd69d4f4d4 100644
--- a/resolv/res_debug.c
+++ b/resolv/res_debug.c
@@ -204,8 +204,7 @@ do_section(const res_state statp,
 		rrnum++;
 	}
  cleanup:
-	if (buf != NULL)
-		free(buf);
+	free(buf);
 }
 
 /*
diff --git a/sunrpc/xdr_sizeof.c b/sunrpc/xdr_sizeof.c
index aaf25e9699..dc3e19ebe3 100644
--- a/sunrpc/xdr_sizeof.c
+++ b/sunrpc/xdr_sizeof.c
@@ -86,8 +86,7 @@ x_inline (XDR *xdrs, u_int len)
   else
     {
       /* Free the earlier space and allocate new area */
-      if (xdrs->x_private)
-	free (xdrs->x_private);
+      free (xdrs->x_private);
       if ((xdrs->x_private = (caddr_t) malloc (len)) == NULL)
 	{
 	  xdrs->x_base = 0;
@@ -157,7 +156,6 @@ xdr_sizeof (xdrproc_t func, void *data)
   x.x_base = (caddr_t) 0;
 
   stat = func (&x, data);
-  if (x.x_private)
-    free (x.x_private);
+  free (x.x_private);
   return stat == TRUE ? x.x_handy : 0;
 }
diff --git a/sysdeps/mach/hurd/if_index.c b/sysdeps/mach/hurd/if_index.c
index 664a3a1ef3..4ecda2298c 100644
--- a/sysdeps/mach/hurd/if_index.c
+++ b/sysdeps/mach/hurd/if_index.c
@@ -59,8 +59,7 @@ if_freenameindex (struct if_nameindex *ifn)
   struct if_nameindex *ptr = ifn;
   while (ptr->if_name || ptr->if_index)
     {
-      if (ptr->if_name)
-        free (ptr->if_name);
+      free (ptr->if_name);
       ++ptr;
     }
   free (ifn);
diff --git a/sysdeps/posix/sprofil.c b/sysdeps/posix/sprofil.c
index 853038d078..6ffce4d783 100644
--- a/sysdeps/posix/sprofil.c
+++ b/sysdeps/posix/sprofil.c
@@ -322,8 +322,7 @@ __sprofil (struct prof *profp, int profcnt, struct timeval *tvp,
   for (i = 0; i < profcnt; ++i)
     if (add_region (p[i], (flags & PROF_UINT) != 0) < 0)
       {
-	if (prof_info.region)
-	  free (prof_info.region);
+	free (prof_info.region);
 	prof_info.num_regions = 0;
 	prof_info.region = NULL;
 	return -1;
diff --git a/time/lc-time-cleanup.c b/time/lc-time-cleanup.c
index 7972700686..6777f487a2 100644
--- a/time/lc-time-cleanup.c
+++ b/time/lc-time-cleanup.c
@@ -29,12 +29,9 @@ _nl_cleanup_time (struct locale_data *locale)
       locale->private.time = NULL;
       locale->private.cleanup = NULL;
 
-      if (data->eras != NULL)
-	free (data->eras);
-      if (data->alt_digits != NULL)
-	free (data->alt_digits);
-      if (data->walt_digits != NULL)
-	free (data->walt_digits);
+      free (data->eras);
+      free (data->alt_digits);
+      free (data->walt_digits);
 
       free (data);
     }
diff --git a/time/tzset.c b/time/tzset.c
index 0d54202185..a6fed4abc1 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -414,8 +414,7 @@ tzset_internal (always, explicit)
   tz_rules[1].name = NULL;
 
   /* Save the value of `tz'.  */
-  if (old_tz != NULL)
-    free (old_tz);
+  free (old_tz);
   old_tz = tz ? __strdup (tz) : NULL;
 
   /* Try to read a data file.  */