summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Pisar <ppisar@redhat.com>2011-05-12 13:13:56 +0200
committerJan Kara <jack@suse.cz>2011-05-16 17:39:33 +0200
commit3ad0b3622cf92989584097787323f00bc7a36c48 (patch)
tree60f203a986e4f36d5ae7723258cec91ab277ad0c
parentc3a392437a2ec4793f2b1112058de0c3b459b6fe (diff)
downloadlinuxquota-3ad0b3622cf92989584097787323f00bc7a36c48.tar.gz
Make global symbols static as possible
There are some calls (e.g. getpwnam(3)) that can lead to dlopening other libraries that could jump to symbol with name clashing to one of global quota symbols. (e.g. Name server switch plug-in nss_db calls dirname(3) that's already defined in edquota.c and tht can cause segmentation fault.) Although it's not possible to solve all these problems, making as much as possible global objects and functions static is the best thing we can do to avoid name space polution. Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--convertquota.c10
-rw-r--r--edquota.c14
-rw-r--r--quot.c4
-rw-r--r--quota.c10
-rw-r--r--quota_nld.c6
-rw-r--r--quotacheck.c20
-rw-r--r--quotaon.c8
-rw-r--r--quotasync.c8
-rw-r--r--repquota.c10
-rw-r--r--rquota_client.c2
-rw-r--r--rquota_svc.c2
-rw-r--r--set_limits_example.c4
-rw-r--r--setquota.c10
13 files changed, 54 insertions, 54 deletions
diff --git a/convertquota.c b/convertquota.c
index 1e40804..483abf1 100644
--- a/convertquota.c
+++ b/convertquota.c
@@ -29,12 +29,12 @@
#define ACT_FORMAT 1 /* Convert format from old to new */
#define ACT_ENDIAN 2 /* Convert endianity */
-char *mntpoint;
+static char *mntpoint;
char *progname;
-int ucv, gcv;
-struct quota_handle *qn; /* Handle of new file */
-int action; /* Action to be performed */
-int infmt, outfmt;
+static int ucv, gcv;
+static struct quota_handle *qn; /* Handle of new file */
+static int action; /* Action to be performed */
+static int infmt, outfmt;
static void usage(void)
{
diff --git a/edquota.c b/edquota.c
index 4d247fa..ef9fc9b 100644
--- a/edquota.c
+++ b/edquota.c
@@ -66,12 +66,12 @@
char *progname;
-int flags, quotatype;
-int fmt = -1;
-char *protoname;
-char *dirname;
+static int flags, quotatype;
+static int fmt = -1;
+static char *protoname;
+static char *dirname;
-void usage(void)
+static void usage(void)
{
#if defined(RPC_SETQUOTA)
char *rpcflag = "[-rm] ";
@@ -102,7 +102,7 @@ void usage(void)
exit(1);
}
-int parse_options(int argc, char **argv)
+static int parse_options(int argc, char **argv)
{
int ret;
struct option long_opts[] = {
@@ -190,7 +190,7 @@ int parse_options(int argc, char **argv)
return optind;
}
-void copy_prototype(int argc, char **argv, struct quota_handle **handles)
+static void copy_prototype(int argc, char **argv, struct quota_handle **handles)
{
int ret, protoid, id;
struct dquot *protoprivs, *curprivs, *pprivs, *cprivs;
diff --git a/quot.c b/quot.c
index 3e1f8d8..d9114a4 100644
--- a/quot.c
+++ b/quot.c
@@ -56,8 +56,8 @@
#include "quotasys.h"
#define TSIZE 500
-__uint64_t sizes[TSIZE];
-__uint64_t overflow;
+static __uint64_t sizes[TSIZE];
+static __uint64_t overflow;
static int aflag;
static int cflag;
diff --git a/quota.c b/quota.c
index 5a2c23f..a154f21 100644
--- a/quota.c
+++ b/quota.c
@@ -76,10 +76,10 @@
#define FL_SHOW_MNTPOINT 16384
#define FL_SHOW_DEVICE 32768
-int flags, fmt = -1;
+static int flags, fmt = -1;
char *progname;
-void usage(void)
+static void usage(void)
{
errstr( "%s%s%s%s%s",
_("Usage: quota [-guqvswim] [-l | [-Q | -A]] [-F quotaformat]\n"),
@@ -112,7 +112,7 @@ void usage(void)
exit(1);
}
-void heading(int type, qid_t id, char *name, char *tag)
+static void heading(int type, qid_t id, char *name, char *tag)
{
char *spacehdr;
@@ -130,7 +130,7 @@ void heading(int type, qid_t id, char *name, char *tag)
}
}
-void print_fs_location(struct dquot *q)
+static void print_fs_location(struct dquot *q)
{
struct quota_handle *h = q->dq_h;
@@ -172,7 +172,7 @@ void print_fs_location(struct dquot *q)
}
}
-int showquotas(int type, qid_t id, int mntcnt, char **mnt)
+static int showquotas(int type, qid_t id, int mntcnt, char **mnt)
{
struct dquot *qlist, *q;
char *msgi, *msgb;
diff --git a/quota_nld.c b/quota_nld.c
index 538702d..de9504e 100644
--- a/quota_nld.c
+++ b/quota_nld.c
@@ -62,8 +62,8 @@ static struct nla_policy quota_nl_warn_cmd_policy[QUOTA_NL_A_MAX+1] = {
#define FL_NODAEMON 4
#define FL_PRINTBELOW 8
-int flags;
-DBusConnection *dhandle;
+static int flags;
+static DBusConnection *dhandle;
static const struct option options[] = {
{ "version", 0, NULL, 'V' },
@@ -75,7 +75,7 @@ static const struct option options[] = {
{ NULL, 0, NULL, 0 }
};
-void show_help(void)
+static void show_help(void)
{
errstr(_("Usage: %s [options]\nOptions are:\n\
-h --help shows this text\n\
diff --git a/quotacheck.c b/quotacheck.c
index 7ecf62d..e25e498 100644
--- a/quotacheck.c
+++ b/quotacheck.c
@@ -62,24 +62,24 @@ struct dirs {
#define BITS_SIZE 4 /* sizeof(bits) == 5 */
#define BLIT_RATIO 10 /* Blit in just 1/10 of blit() calls */
-dev_t cur_dev; /* Device we are working on */
-int files_done, dirs_done;
+static dev_t cur_dev; /* Device we are working on */
+static int files_done, dirs_done;
int flags, fmt = -1, cfmt; /* Options from command line; Quota format to use spec. by user; Actual format to check */
-int uwant, gwant, ucheck, gcheck; /* Does user want to check user/group quota; Do we check user/group quota? */
-char *mntpoint; /* Mountpoint to check */
+static int uwant, gwant, ucheck, gcheck; /* Does user want to check user/group quota; Do we check user/group quota? */
+static char *mntpoint; /* Mountpoint to check */
char *progname;
struct util_dqinfo old_info[MAXQUOTAS]; /* Loaded infos */
-char extensions[MAXQUOTAS + 2][20] = INITQFNAMES; /* Extensions depending on quota type */
-char *basenames[] = INITQFBASENAMES; /* Names of quota files */
+static char extensions[MAXQUOTAS + 2][20] = INITQFNAMES; /* Extensions depending on quota type */
+static char *basenames[] = INITQFBASENAMES; /* Names of quota files */
#ifdef DEBUG_MALLOC
-size_t malloc_mem = 0;
-size_t free_mem = 0;
+static size_t malloc_mem = 0;
+static size_t free_mem = 0;
#endif
-struct dquot *dquot_hash[MAXQUOTAS][DQUOTHASHSIZE];
-struct dlinks *links_hash[MAXQUOTAS][DQUOTHASHSIZE];
+static struct dquot *dquot_hash[MAXQUOTAS][DQUOTHASHSIZE];
+static struct dlinks *links_hash[MAXQUOTAS][DQUOTHASHSIZE];
/*
* Ok check each memory allocation.
diff --git a/quotaon.c b/quotaon.c
index e12c58d..ee9a02e 100644
--- a/quotaon.c
+++ b/quotaon.c
@@ -55,11 +55,11 @@
#define FL_STAT 16
#define FL_OFF 32
-int flags, fmt = -1;
+static int flags, fmt = -1;
char *progname;
-char **mntpoints;
-int mntcnt;
-char *xarg = NULL;
+static char **mntpoints;
+static int mntcnt;
+static char *xarg = NULL;
static void usage(void)
{
diff --git a/quotasync.c b/quotasync.c
index 0ce44c9..a9e2dda 100644
--- a/quotasync.c
+++ b/quotasync.c
@@ -15,9 +15,9 @@
#define FL_GROUP 2 /* sync group quotas */
#define FL_ALL 4 /* sync quotas on all filesystems */
-int flags, fmt = -1;
-char **mnt;
-int mntcnt;
+static int flags, fmt = -1;
+static char **mnt;
+static int mntcnt;
char *progname;
static void usage(void)
@@ -79,7 +79,7 @@ static int sync_one(int type, char *dev)
return quotactl(qcmd, dev, 0, NULL);
}
-int syncquotas(int type)
+static int syncquotas(int type)
{
struct quota_handle **handles, *h;
int i, ret = 0;
diff --git a/repquota.c b/repquota.c
index 17dd9e4..8436e66 100644
--- a/repquota.c
+++ b/repquota.c
@@ -38,11 +38,11 @@
#define FL_NOAUTOFS 256 /* Ignore autofs mountpoints */
#define FL_RAWGRACE 512 /* Print grace times in seconds since epoch */
-int flags, fmt = -1;
-char **mnt;
-int mntcnt;
-int cached_dquots;
-struct dquot dquot_cache[MAX_CACHE_DQUOTS];
+static int flags, fmt = -1;
+static char **mnt;
+static int mntcnt;
+static int cached_dquots;
+static struct dquot dquot_cache[MAX_CACHE_DQUOTS];
char *progname;
static void usage(void)
diff --git a/rquota_client.c b/rquota_client.c
index 53e0579..d67dd25 100644
--- a/rquota_client.c
+++ b/rquota_client.c
@@ -86,7 +86,7 @@ static inline void cliutil2netdqblk(struct sq_dqblk *n, struct util_dqblk *u)
}
/* Write appropriate error message */
-int rquota_err(int stat)
+static int rquota_err(int stat)
{
switch (stat) {
case -1:
diff --git a/rquota_svc.c b/rquota_svc.c
index 7ed8524..17a92f4 100644
--- a/rquota_svc.c
+++ b/rquota_svc.c
@@ -169,7 +169,7 @@ static void parse_options(int argc, char **argv)
* good_client checks if an quota client should be allowed to
* execute the requested rpc call.
*/
-int good_client(struct sockaddr_in *addr, ulong rq_proc)
+static int good_client(struct sockaddr_in *addr, ulong rq_proc)
{
#ifdef HOSTS_ACCESS
struct request_info req;
diff --git a/set_limits_example.c b/set_limits_example.c
index 755fb2f..4147bba 100644
--- a/set_limits_example.c
+++ b/set_limits_example.c
@@ -7,7 +7,7 @@
#include "pot.h"
-int copy_user_quota_limits(const char *block_device, uid_t from, uid_t to)
+static int copy_user_quota_limits(const char *block_device, uid_t from, uid_t to)
{
struct dqblk dq;
@@ -30,7 +30,7 @@ int copy_user_quota_limits(const char *block_device, uid_t from, uid_t to)
}
}
-int copy_group_quota_limits(const char *block_device, gid_t from, gid_t to)
+static int copy_group_quota_limits(const char *block_device, gid_t from, gid_t to)
{
struct dqblk dq;
diff --git a/setquota.c b/setquota.c
index c012908..57bd580 100644
--- a/setquota.c
+++ b/setquota.c
@@ -37,12 +37,12 @@
#define FL_NO_MIXED_PATHS 512
#define FL_CONTINUE_BATCH 1024
-int flags, fmt = -1;
-char **mnt;
+static int flags, fmt = -1;
+static char **mnt;
char *progname;
-int mntcnt;
-qid_t protoid, id;
-struct util_dqblk toset;
+static int mntcnt;
+static qid_t protoid, id;
+static struct util_dqblk toset;
/* Print usage information */
static void usage(void)