1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

* grp/initgroups.c (internal_getgrouplist): Remove unnecessary

test introduced in patch for bz #661.
	(getgrouplist): Simplify code a bit.
This commit is contained in:
Ulrich Drepper
2006-08-03 15:26:02 +00:00
parent 9c06eb66b5
commit 6c215a8d6c
3 changed files with 19 additions and 18 deletions

View File

@ -1,5 +1,9 @@
2006-08-03 Ulrich Drepper <drepper@redhat.com> 2006-08-03 Ulrich Drepper <drepper@redhat.com>
* grp/initgroups.c (internal_getgrouplist): Remove unnecessary
test introduced in patch for bz #661.
(getgrouplist): Simplify code a bit.
[BZ #2908] [BZ #2908]
* stdio-common/printf_fphex.c (__printf_fphex): When rounding up * stdio-common/printf_fphex.c (__printf_fphex): When rounding up
'f', use '1' as leading digit not '\1'. 'f', use '1' as leading digit not '\1'.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1989,91,93,1996-2003, 2004, 2005 Free Software Foundation, Inc. /* Copyright (C) 1989,91,93,1996-2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -74,8 +74,8 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
long int start = 1; long int start = 1;
/* Never store more than the starting *SIZE number of elements. */ /* Never store more than the starting *SIZE number of elements. */
if (*size > 0) assert (*size > 0);
(*groupsp)[0] = group; (*groupsp)[0] = group;
if (__nss_group_database != NULL) if (__nss_group_database != NULL)
{ {
@ -142,11 +142,9 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
int int
getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups) getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups)
{ {
gid_t *newgroups;
long int size = MAX (1, *ngroups); long int size = MAX (1, *ngroups);
int result;
newgroups = (gid_t *) malloc ((size + 1) * sizeof (gid_t)); gid_t *newgroups = (gid_t *) malloc ((size + 1) * sizeof (gid_t));
if (__builtin_expect (newgroups == NULL, 0)) if (__builtin_expect (newgroups == NULL, 0))
/* No more memory. */ /* No more memory. */
// XXX This is wrong. The user provided memory, we have to use // XXX This is wrong. The user provided memory, we have to use
@ -155,20 +153,16 @@ getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups)
// XXX too small. For initgroups a flag could say: increase size. // XXX too small. For initgroups a flag could say: increase size.
return -1; return -1;
result = internal_getgrouplist (user, group, &size, &newgroups, -1); int total = internal_getgrouplist (user, group, &size, &newgroups, -1);
memcpy (groups, newgroups, MIN (*ngroups, result) * sizeof (gid_t)); memcpy (groups, newgroups, MIN (*ngroups, total) * sizeof (gid_t));
if (result > *ngroups)
{
*ngroups = result;
result = -1;
}
else
*ngroups = result;
free (newgroups); free (newgroups);
return result;
int retval = total > *ngroups ? -1 : total;
*ngroups = total;
return retval;
} }
static_link_warning (getgrouplist) static_link_warning (getgrouplist)

View File

@ -404,7 +404,10 @@ __printf_fphex (FILE *fp,
{ {
exponent -= 4; exponent -= 4;
if (exponent <= 0) if (exponent <= 0)
expnegative = 0; {
exponent = -exponent;
expnegative = 0;
}
} }
else else
exponent += 4; exponent += 4;