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

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

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

View File

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

View File

@ -282,28 +282,28 @@ mc_pread_stream (mc_pipe_stream_t * ps, const fd_set * fds)
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
char *
get_owner (int uid)
const char *
get_owner (uid_t uid)
{
struct passwd *pwd;
char *name;
static int uid_last;
static uid_t uid_last;
name = i_cache_match (uid, uid_cache, UID_CACHE_SIZE);
name = i_cache_match ((int) uid, uid_cache, UID_CACHE_SIZE);
if (name != NULL)
return name;
pwd = getpwuid (uid);
if (pwd != NULL)
{
i_cache_add (uid, uid_cache, UID_CACHE_SIZE, pwd->pw_name, &uid_last);
i_cache_add ((int) uid, uid_cache, UID_CACHE_SIZE, pwd->pw_name, (int *) &uid_last);
return pwd->pw_name;
}
else
{
static char ibuf[10];
g_snprintf (ibuf, sizeof (ibuf), "%d", uid);
g_snprintf (ibuf, sizeof (ibuf), "%d", (int) uid);
return ibuf;
}
}