From: Theodore Ts'o <tytso@mit.edu>
To: jack@suse.cz
Cc: Linux Filesystem Development List <linux-fsdevel@vger.kernel.org>,
Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 3/5] Use NGROUPS_MAX instead of NGROUPS
Date: Tue, 29 Mar 2016 20:48:05 -0400 [thread overview]
Message-ID: <1459298887-21519-4-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1459298887-21519-1-git-send-email-tytso@mit.edu>
NGRROUPS_MAX is what is defined by SuSv3; NGROUPS is not guaranteed by
any standard, but is just an ancient BSD'ism. Since Android's bionic
libc has the former but not the latter, let's use NGROUPS_MAX instead.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
quota.c | 5 +++--
quotaops.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/quota.c b/quota.c
index d3ab800..da66a46 100644
--- a/quota.c
+++ b/quota.c
@@ -48,6 +48,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <limits.h>
#ifdef RPC
#include <rpc/rpc.h>
#include "rquota.h"
@@ -298,7 +299,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
int main(int argc, char **argv)
{
int ngroups;
- gid_t gidset[NGROUPS], *gidsetp;
+ gid_t gidset[NGROUPS_MAX], *gidsetp;
int i, ret, type = 0;
struct option long_opts[] = {
{ "help", 0, NULL, 'h' },
@@ -411,7 +412,7 @@ int main(int argc, char **argv)
ret |= showquotas(USRQUOTA, getuid(), argc, argv);
if (flags & FL_GROUP) {
ngroups = sysconf(_SC_NGROUPS_MAX);
- if (ngroups > NGROUPS) {
+ if (ngroups > NGROUPS_MAX) {
gidsetp = malloc(ngroups * sizeof(gid_t));
if (!gidsetp)
die(1, _("Gid set allocation (%d): %s\n"), ngroups, strerror(errno));
diff --git a/quotaops.c b/quotaops.c
index 136aec3..590dc1b 100644
--- a/quotaops.c
+++ b/quotaops.c
@@ -51,6 +51,7 @@
#include <unistd.h>
#include <time.h>
#include <ctype.h>
+#include <limits.h>
#if defined(RPC)
#include "rquota.h"
@@ -97,7 +98,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
#if defined(BSD_BEHAVIOUR)
int j, ngroups;
uid_t euid;
- gid_t gidset[NGROUPS], *gidsetp;
+ gid_t gidset[NGROUPS_MAX], *gidsetp;
#endif
for (i = 0; handles[i]; i++) {
@@ -115,7 +116,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
if (geteuid() == 0)
break;
ngroups = sysconf(_SC_NGROUPS_MAX);
- if (ngroups > NGROUPS) {
+ if (ngroups > NGROUPS_MAX) {
gidsetp = malloc(ngroups * sizeof(gid_t));
if (!gidsetp) {
gid2group(id, name);
--
2.5.0
next prev parent reply other threads:[~2016-03-30 0:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 0:48 [PATCH 0/5] Misc. cleanup and portability patches for quota-tools Theodore Ts'o
2016-03-30 0:48 ` [PATCH 1/5] Update the gitignore file to ignore additional generated files Theodore Ts'o
2016-03-30 0:48 ` [PATCH 2/5] Allow building on systems that do not have rpc header files Theodore Ts'o
2016-03-30 0:48 ` Theodore Ts'o [this message]
2016-03-30 0:48 ` [PATCH 4/5] Provide fallback definitions for MNTTYPE_NFS and MNTTYPE_NOAUTO Theodore Ts'o
2016-03-30 0:48 ` [PATCH 5/5] Support systems which do not have nl_langinfo() Theodore Ts'o
2016-03-30 8:29 ` [PATCH 0/5] Misc. cleanup and portability patches for quota-tools Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459298887-21519-4-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).