summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/getcwd.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-16 04:35:55 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-16 04:35:55 +0000
commit9ff9add9a5812f6677d22c7d6bb17471cfc9025b (patch)
tree948d5f982e1eca31f9accea7919e78984cc54094 /sysdeps/unix/sysv/linux/getcwd.c
parente993e9cc1c6b0dbe4c3d12ab7fe45678e3e39e27 (diff)
Update.
2000-07-15 Ulrich Drepper <drepper@redhat.com> * sysdeps/unix/sysv/linux/getcwd.c: Correct last patch. Patch by Greg McGary <greg@mcgary.org>. * io/Makefile (tests): Add tst-getcwd. * io/tst-getcwd.c: New file.
Diffstat (limited to 'sysdeps/unix/sysv/linux/getcwd.c')
-rw-r--r--sysdeps/unix/sysv/linux/getcwd.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c
index b819f948fd..da42f48239 100644
--- a/sysdeps/unix/sysv/linux/getcwd.c
+++ b/sysdeps/unix/sysv/linux/getcwd.c
@@ -104,13 +104,14 @@ __getcwd (char *buf, size_t size)
if (retval >= 0)
{
if (buf == NULL && size == 0)
- {
- /* Ensure that the buffer is only as large as necessary. */
- buf = realloc (path, (size_t) retval);
- if (buf == NULL)
- /* `realloc' failed but we still have the original string. */
- buf = path;
- }
+ /* Ensure that the buffer is only as large as necessary. */
+ buf = realloc (path, (size_t) retval);
+
+ if (buf == NULL)
+ /* Either buf was NULL all along, or `realloc' failed but
+ we still have the original string. */
+ buf = path;
+
return buf;
}
@@ -156,13 +157,13 @@ __getcwd (char *buf, size_t size)
path[n] = '\0';
if (buf == NULL && size == 0)
- {
- /* Ensure that the buffer is only as large as necessary. */
- buf = realloc (path, (size_t) n + 1);
- if (buf == NULL)
- /* `relloc' failed but we still have the original string. */
- buf = path;
- }
+ /* Ensure that the buffer is only as large as necessary. */
+ buf = realloc (path, (size_t) n + 1);
+ if (buf == NULL)
+ /* Either buf was NULL all along, or `realloc' failed but
+ we still have the original string. */
+ buf = path;
+
return buf;
}
#ifndef have_new_dcache