From: Lennart Poettering Date: Sat, 30 Dec 2017 13:05:41 +0000 (+0100) Subject: user-util: minor updates of in_gid() X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5df6537480e6da41d19bf11013df3639843539be;p=elogind.git user-util: minor updates of in_gid() Let's use newa() and use the right type for storing sysconf() return values. --- diff --git a/src/basic/user-util.c b/src/basic/user-util.c index ee42b10cb..3f364b3b3 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -363,8 +363,9 @@ char* gid_to_name(gid_t gid) { #if 0 /// UNNEEDED by elogind int in_gid(gid_t gid) { + long ngroups_max; gid_t *gids; - int ngroups_max, r, i; + int r, i; if (getgid() == gid) return 1; @@ -378,7 +379,7 @@ int in_gid(gid_t gid) { ngroups_max = sysconf(_SC_NGROUPS_MAX); assert(ngroups_max > 0); - gids = alloca(sizeof(gid_t) * ngroups_max); + gids = newa(gid_t, ngroups_max); r = getgroups(ngroups_max, gids); if (r < 0)