(get_group): change type of parameter and return value:

return value: from "char *" to "const char *";
parameter: from int to gid_t.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2015-06-24 16:09:58 +03:00 committed by Slava Zanko
parent 0516ccd325
commit a95320cb15
2 changed files with 7 additions and 7 deletions

View File

@ -178,7 +178,7 @@ void destroy_groups (void);
int get_user_permissions (struct stat *buf);
void init_uid_gid_cache (void);
char *get_group (int);
const char *get_group (gid_t gid);
char *get_owner (int);
/* Returns a copy of *s until a \n is found and is below top */

View File

@ -310,28 +310,28 @@ get_owner (int uid)
/* --------------------------------------------------------------------------------------------- */
char *
get_group (int gid)
const char *
get_group (gid_t gid)
{
struct group *grp;
char *name;
static int gid_last;
static gid_t gid_last;
name = i_cache_match (gid, gid_cache, GID_CACHE_SIZE);
name = i_cache_match ((int) gid, gid_cache, GID_CACHE_SIZE);
if (name != NULL)
return name;
grp = getgrgid (gid);
if (grp != NULL)
{
i_cache_add (gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, &gid_last);
i_cache_add ((int) gid, gid_cache, GID_CACHE_SIZE, grp->gr_name, (int *) &gid_last);
return grp->gr_name;
}
else
{
static char gbuf[10];
g_snprintf (gbuf, sizeof (gbuf), "%d", gid);
g_snprintf (gbuf, sizeof (gbuf), "%d", (int) gid);
return gbuf;
}
}