summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-02-18 14:12:07 +0100
committerJim Meyering <meyering@redhat.com>2008-03-02 17:23:38 +0100
commit7dd49d2811431dceac40473f3d65d13f6552cce4 (patch)
tree9a9dcfd8b3c8fb8e8406b9c4cdf6a2034aab1c06
parent2745af103fde56c389d4f46711d52d2a2d7b016e (diff)
downloadgnulib-7dd49d2811431dceac40473f3d65d13f6552cce4.tar.gz
Remove useless "if" tests before free. Deprecate "free" module.
* doc/posix-functions/free.texi: Mention that this module is no longer useful. * modules/free (Notice): Say this module is obsolete. * modules/readutmp (Depends-on): Remove free. * lib/save-cwd.c (free_cwd): Remove useless "if" before free. * lib/putenv.c (putenv): Likewise. * lib/gc-gnulib.c (gc_cipher_close): Likewise. * lib/getaddrinfo.c (freeaddrinfo): Likewise. * tests/test-c-strcasestr.c (main): Likewise. * tests/test-c-strstr.c (main): Likewise. * tests/test-mbscasestr1.c (main): Likewise. * tests/test-mbscasestr2.c (main): Likewise. * tests/test-mbsstr1.c (main): Likewise. * tests/test-mbsstr2.c (main): Likewise. * tests/test-memmem.c (main): Likewise. * tests/test-strcasestr.c (main): Likewise. * tests/test-striconv.c (main): Likewise. * tests/test-striconveh.c (main): Likewise. * tests/test-striconveha.c (main): Likewise. * tests/test-strstr.c (main): Likewise.
-rw-r--r--ChangeLog22
-rw-r--r--doc/posix-functions/free.texi5
-rw-r--r--lib/gc-gnulib.c3
-rw-r--r--lib/getaddrinfo.c2
-rw-r--r--lib/putenv.c5
-rw-r--r--lib/save-cwd.c3
-rw-r--r--modules/free4
-rw-r--r--modules/readutmp1
-rw-r--r--tests/test-c-strcasestr.c6
-rw-r--r--tests/test-c-strstr.c6
-rw-r--r--tests/test-mbscasestr1.c6
-rw-r--r--tests/test-mbscasestr2.c6
-rw-r--r--tests/test-mbsstr1.c6
-rw-r--r--tests/test-mbsstr2.c6
-rw-r--r--tests/test-memmem.c12
-rw-r--r--tests/test-strcasestr.c6
-rw-r--r--tests/test-striconv.c3
-rw-r--r--tests/test-striconveh.c6
-rw-r--r--tests/test-striconveha.c3
-rw-r--r--tests/test-strstr.c6
20 files changed, 58 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index 4876a38a3a..69e78c84f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2008-03-02 Jim Meyering <meyering@redhat.com>
+ Remove useless "if" tests before free. Deprecate "free" module.
+ * doc/posix-functions/free.texi: Mention that this
+ module is no longer useful.
+ * modules/free (Notice): Say this module is obsolete.
+ * modules/readutmp (Depends-on): Remove free.
+ * lib/save-cwd.c (free_cwd): Remove useless "if" before free.
+ * lib/putenv.c (putenv): Likewise.
+ * lib/gc-gnulib.c (gc_cipher_close): Likewise.
+ * lib/getaddrinfo.c (freeaddrinfo): Likewise.
+ * tests/test-c-strcasestr.c (main): Likewise.
+ * tests/test-c-strstr.c (main): Likewise.
+ * tests/test-mbscasestr1.c (main): Likewise.
+ * tests/test-mbscasestr2.c (main): Likewise.
+ * tests/test-mbsstr1.c (main): Likewise.
+ * tests/test-mbsstr2.c (main): Likewise.
+ * tests/test-memmem.c (main): Likewise.
+ * tests/test-strcasestr.c (main): Likewise.
+ * tests/test-striconv.c (main): Likewise.
+ * tests/test-striconveh.c (main): Likewise.
+ * tests/test-striconveha.c (main): Likewise.
+ * tests/test-strstr.c (main): Likewise.
+
* build-aux/git-version-gen: Adjust a comment and the Usage string.
bootstrap: sync from coreutils again
diff --git a/doc/posix-functions/free.texi b/doc/posix-functions/free.texi
index a407dc25eb..10d95cd0f9 100644
--- a/doc/posix-functions/free.texi
+++ b/doc/posix-functions/free.texi
@@ -9,7 +9,10 @@ Gnulib module: free
Portability problems fixed by Gnulib:
@itemize
@item
-On old platforms, @code{free (NULL)} is not allowed.
+On old platforms such as SunOS4, @code{free (NULL)} fails.
+However, since all such systems are so old as to no longer
+be considered ``reasonable portability targets,''
+this module is no longer useful.
@end itemize
Portability problems not fixed by Gnulib:
diff --git a/lib/gc-gnulib.c b/lib/gc-gnulib.c
index 94e08806c5..d535d032ec 100644
--- a/lib/gc-gnulib.c
+++ b/lib/gc-gnulib.c
@@ -546,8 +546,7 @@ gc_cipher_close (gc_cipher_handle handle)
{
_gc_cipher_ctx *ctx = handle;
- if (ctx)
- free (ctx);
+ free (ctx);
return GC_OK;
}
diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index aa07903445..c7a1ea9a7b 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -326,7 +326,7 @@ freeaddrinfo (struct addrinfo *ai)
cur = ai;
ai = ai->ai_next;
- if (cur->ai_canonname) free (cur->ai_canonname);
+ free (cur->ai_canonname);
free (cur);
}
}
diff --git a/lib/putenv.c b/lib/putenv.c
index 351b403606..d0573c69f1 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997, 1998, 2000, 2003, 2004, 2005, 2006, 2007
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2008
Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
@@ -122,8 +122,7 @@ putenv (char *string)
size * sizeof (char *));
new_environ[size] = (char *) string;
new_environ[size + 1] = NULL;
- if (last_environ != NULL)
- free (last_environ);
+ free (last_environ);
last_environ = new_environ;
environ = new_environ;
}
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index 7618f090dc..e158e8b6b2 100644
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -97,6 +97,5 @@ free_cwd (struct saved_cwd *cwd)
{
if (cwd->desc >= 0)
close (cwd->desc);
- if (cwd->name)
- free (cwd->name);
+ free (cwd->name);
}
diff --git a/modules/free b/modules/free
index 94b6a3a5ed..26ef70b115 100644
--- a/modules/free
+++ b/modules/free
@@ -1,6 +1,9 @@
Description:
Work around incompatibility on older systems where free (NULL) fails.
+Notice:
+This module is obsolete.
+
Files:
lib/free.c
m4/free.m4
@@ -20,4 +23,3 @@ GPL
Maintainer:
Paul Eggert
-
diff --git a/modules/readutmp b/modules/readutmp
index fd813be89c..4a778b8377 100644
--- a/modules/readutmp
+++ b/modules/readutmp
@@ -9,7 +9,6 @@ m4/readutmp.m4
Depends-on:
extensions
xalloc
-free
stdbool
configure.ac:
diff --git a/tests/test-c-strcasestr.c b/tests/test-c-strcasestr.c
index 012571d342..b511654d12 100644
--- a/tests/test-c-strcasestr.c
+++ b/tests/test-c-strcasestr.c
@@ -136,10 +136,8 @@ main ()
result = c_strcasestr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
return 0;
diff --git a/tests/test-c-strstr.c b/tests/test-c-strstr.c
index 75b8d5d553..a8682cbdd4 100644
--- a/tests/test-c-strstr.c
+++ b/tests/test-c-strstr.c
@@ -129,10 +129,8 @@ main ()
result = c_strstr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
return 0;
diff --git a/tests/test-mbscasestr1.c b/tests/test-mbscasestr1.c
index c8b18bbe6f..27abd116fd 100644
--- a/tests/test-mbscasestr1.c
+++ b/tests/test-mbscasestr1.c
@@ -131,10 +131,8 @@ main ()
result = mbscasestr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
return 0;
diff --git a/tests/test-mbscasestr2.c b/tests/test-mbscasestr2.c
index 1b9f1849c2..a4d0848cdb 100644
--- a/tests/test-mbscasestr2.c
+++ b/tests/test-mbscasestr2.c
@@ -143,10 +143,8 @@ main ()
result = mbscasestr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
return 0;
diff --git a/tests/test-mbsstr1.c b/tests/test-mbsstr1.c
index f2b1e1d13c..ff20485962 100644
--- a/tests/test-mbsstr1.c
+++ b/tests/test-mbsstr1.c
@@ -130,10 +130,8 @@ main ()
result = mbsstr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
return 0;
diff --git a/tests/test-mbsstr2.c b/tests/test-mbsstr2.c
index d8699ca291..014afed3c8 100644
--- a/tests/test-mbsstr2.c
+++ b/tests/test-mbsstr2.c
@@ -143,10 +143,8 @@ main ()
result = mbsstr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
return 0;
diff --git a/tests/test-memmem.c b/tests/test-memmem.c
index 58043cdcdc..656f3bbc30 100644
--- a/tests/test-memmem.c
+++ b/tests/test-memmem.c
@@ -152,10 +152,8 @@ main (int argc, char *argv[])
result = memmem (haystack, 2 * m + 1, needle, m + 1);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
/* Check that long needles not present in a haystack can be handled
@@ -179,10 +177,8 @@ main (int argc, char *argv[])
ASSERT (result == NULL);
}
}
- if (haystack != NULL)
- free (haystack);
- if (needle != NULL)
- free (needle);
+ free (haystack);
+ free (needle);
}
return 0;
diff --git a/tests/test-strcasestr.c b/tests/test-strcasestr.c
index 9db62f1750..a674719916 100644
--- a/tests/test-strcasestr.c
+++ b/tests/test-strcasestr.c
@@ -144,10 +144,8 @@ main ()
result = strcasestr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
return 0;
diff --git a/tests/test-striconv.c b/tests/test-striconv.c
index 5c97c4ae0b..b1252b09cc 100644
--- a/tests/test-striconv.c
+++ b/tests/test-striconv.c
@@ -102,8 +102,7 @@ main ()
&result, &length);
ASSERT (retval == 0);
ASSERT (length == 0);
- if (result != NULL)
- free (result);
+ free (result);
}
/* ------------------------- Test str_cd_iconv() ------------------------- */
diff --git a/tests/test-striconveh.c b/tests/test-striconveh.c
index 72e31b9f5b..459b0f197c 100644
--- a/tests/test-striconveh.c
+++ b/tests/test-striconveh.c
@@ -330,8 +330,7 @@ main ()
ASSERT (offsets[1] == MAGIC);
free (offsets);
}
- if (result != NULL)
- free (result);
+ free (result);
}
}
@@ -719,8 +718,7 @@ main ()
ASSERT (offsets[1] == MAGIC);
free (offsets);
}
- if (result != NULL)
- free (result);
+ free (result);
}
}
diff --git a/tests/test-striconveha.c b/tests/test-striconveha.c
index 488eec0f8e..8c87663843 100644
--- a/tests/test-striconveha.c
+++ b/tests/test-striconveha.c
@@ -313,8 +313,7 @@ main ()
ASSERT (offsets[1] == MAGIC);
free (offsets);
}
- if (result != NULL)
- free (result);
+ free (result);
}
}
diff --git a/tests/test-strstr.c b/tests/test-strstr.c
index b03fcf9061..be75a66981 100644
--- a/tests/test-strstr.c
+++ b/tests/test-strstr.c
@@ -142,10 +142,8 @@ main (int argc, char *argv[])
result = strstr (haystack, needle);
ASSERT (result == haystack + m);
}
- if (needle != NULL)
- free (needle);
- if (haystack != NULL)
- free (haystack);
+ free (needle);
+ free (haystack);
}
/* Sublinear speed is only possible in memmem; strstr must examine