aboutsummaryrefslogtreecommitdiff
path: root/grp/putgrent.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-04-21 16:15:11 +0000
committerUlrich Drepper <drepper@redhat.com>2000-04-21 16:15:11 +0000
commita711dd4ba8f2c71a260a3f7539c0e86175f97a21 (patch)
tree1bf9e3eb9a49f3b9cdcd0dee9515339486170f74 /grp/putgrent.c
parent761df3a7aa6eb65aa66c78e6c1da627e453de458 (diff)
downloadglibc-a711dd4ba8f2c71a260a3f7539c0e86175f97a21.zip
glibc-a711dd4ba8f2c71a260a3f7539c0e86175f97a21.tar.gz
glibc-a711dd4ba8f2c71a260a3f7539c0e86175f97a21.tar.bz2
Update.
2000-04-21 Ulrich Drepper <drepper@redhat.com> * iconv/iconv.c (iconv): Add __builtin_expect where useful. * iconv/iconv_close.c (iconv_close): Likewise. * iconv/iconv_open.c (iconv_open): Likewise. * grp/putgrent.c (putgrent): Unlock steam if fprintf failed. Add __builtin_expect where useful. * grp/initgroups.c (initgroups): Test for result of memory allocation and punt if it fails. * dirent/scandir.c (scandir): Add __builtin_expect where useful. * grp/fgetgrent.c (fgetfrent): Likewise. * grp/fgetgrent_r.c (__fgetgrent_r): Likewise.
Diffstat (limited to 'grp/putgrent.c')
-rw-r--r--grp/putgrent.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/grp/putgrent.c b/grp/putgrent.c
index a119ebe..11b64ec 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 96, 98, 99, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,7 +36,7 @@ putgrent (gr, stream)
{
int retval;
- if (gr == NULL || stream == NULL)
+ if (__builtin_expect (gr == NULL, 0) || __builtin_expect (stream == NULL, 0))
{
__set_errno (EINVAL);
return -1;
@@ -46,8 +46,11 @@ putgrent (gr, stream)
retval = fprintf (stream, "%s:%s:%u:",
gr->gr_name, _S (gr->gr_passwd), gr->gr_gid);
- if (retval < 0)
- return -1;
+ if (__builtin_expect (retval, 0) < 0)
+ {
+ funlockfile (stream);
+ return -1;
+ }
if (gr->gr_mem != NULL)
{