diff options
author | david m. richter <richterd@citi.umich.edu> | 2007-08-13 15:15:48 -0400 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2007-08-16 09:10:38 +1000 |
commit | 7e5b51dff2c0a949fbef595d296d10c1bda81899 (patch) | |
tree | bc26f2f9c2eae6096fa3be9ae30368d646f83cfe /utils | |
parent | ed6ecd11fc1a13f76289319248a54c1b5ce5c886 (diff) | |
download | nfs-utils-7e5b51dff2c0a949fbef595d296d10c1bda81899.tar.gz nfs-utils-7e5b51dff2c0a949fbef595d296d10c1bda81899.tar.xz nfs-utils-7e5b51dff2c0a949fbef595d296d10c1bda81899.zip |
nfsstat: Remove some pointer comparisons against global statinfos.
Pass-in an "is_srv" arg instead of doing pointer comparisons
against the static statinfo arrays themselves.
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/nfsstat/nfsstat.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c index 6201f28..087d102 100644 --- a/utils/nfsstat/nfsstat.c +++ b/utils/nfsstat/nfsstat.c @@ -162,9 +162,10 @@ static statinfo *get_stat_info(const char *, struct statinfo *); static int mounts(const char *); -static void get_stats(const char *, statinfo *, int *, int, const char *); +static void get_stats(const char *, struct statinfo *, int *, int, + int); static int has_stats(const unsigned int *); -static void diff_stats(statinfo *, statinfo *); +static void diff_stats(struct statinfo *, struct statinfo *, int); static void unpause(int); static time_t starttime; @@ -353,9 +354,9 @@ main(int argc, char **argv) } if (opt_srv) - get_stats(NFSSRVSTAT, serverinfo, &opt_srv, opt_clt, "Server"); + get_stats(NFSSRVSTAT, serverinfo, &opt_srv, opt_clt, 1); if (opt_clt) - get_stats(NFSCLTSTAT, clientinfo, &opt_clt, opt_srv, "Client"); + get_stats(NFSCLTSTAT, clientinfo, &opt_clt, opt_srv, 0); /* save stat snapshots; wait for signal; then diff current and saved stats */ if (opt_sleep) { @@ -367,12 +368,12 @@ main(int argc, char **argv) } pause(); if (opt_srv) { - get_stats(NFSSRVSTAT, serverinfo_tmp, &opt_srv, opt_clt, "Server"); - diff_stats(serverinfo_tmp, serverinfo); + get_stats(NFSSRVSTAT, serverinfo_tmp, &opt_srv, opt_clt, 1); + diff_stats(serverinfo_tmp, serverinfo, 1); } if (opt_clt) { - get_stats(NFSCLTSTAT, clientinfo_tmp, &opt_clt, opt_srv, "Client"); - diff_stats(clientinfo_tmp, clientinfo); + get_stats(NFSCLTSTAT, clientinfo_tmp, &opt_clt, opt_srv, 0); + diff_stats(clientinfo_tmp, clientinfo, 0); } } @@ -634,8 +635,11 @@ mounts(const char *name) } static void -get_stats(const char *file, statinfo *info, int *opt, int other_opt, const char *label) +get_stats(const char *file, struct statinfo *info, int *opt, int other_opt, + int is_srv) { + const char *label = is_srv ? "Server" : "Client"; + if (!parse_statfile(file, info)) { if (!other_opt) { fprintf(stderr, "Warning: No %s Stats (%s: %m). \n", label, file); @@ -662,9 +666,9 @@ has_stats(const unsigned int *info) * and store the results back into 'new' */ static void -diff_stats(struct statinfo *new, struct statinfo *old) +diff_stats(struct statinfo *new, struct statinfo *old, int is_srv) { - int i, j, is_srv, nodiff_first_index, should_diff; + int i, j, nodiff_first_index, should_diff; /* * Different stat types have different formats in the /proc @@ -675,7 +679,6 @@ diff_stats(struct statinfo *new, struct statinfo *old) * procX types ("i" < 2 for clt, < 4 for srv), or if it's not * the first entry ("j" > 0). */ - is_srv = (new == srvinfo); nodiff_first_index = 2 + (2 * is_srv); for (i = 0; old[i].tag; i++) { |