From a95320cb153b7f124f3e04bd4760e55318cc87f0 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 24 Jun 2015 16:09:58 +0300 Subject: [PATCH] (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 --- lib/util.h | 2 +- lib/utilunix.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/util.h b/lib/util.h index dd2e697d9..4724a5f3b 100644 --- a/lib/util.h +++ b/lib/util.h @@ -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 */ diff --git a/lib/utilunix.c b/lib/utilunix.c index fed8c087f..6b8089668 100644 --- a/lib/utilunix.c +++ b/lib/utilunix.c @@ -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; } }