summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2012-10-30 14:02:24 -0400
committerSteve Dickson <steved@redhat.com>2012-10-30 15:30:08 -0400
commit7df8ca883bfd668eb559ea1b8da7c7b6e41d5b1a (patch)
tree8ac19398a9320d05e561e6ca5412dc67ae3cb623
parent6d9909afd0cf82332a0095aa201e515d1a159c97 (diff)
downloadnfs-utils-7df8ca883bfd668eb559ea1b8da7c7b6e41d5b1a.zip
nfs-utils-7df8ca883bfd668eb559ea1b8da7c7b6e41d5b1a.tar.gz
nfs-utils-7df8ca883bfd668eb559ea1b8da7c7b6e41d5b1a.tar.xz
mountd: Avoid unnecessary type conversions
Removed a number of Wconversion warnings in the mountd code. Took the opportunity to eliminate some code duplication. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--support/include/nfslib.h1
-rw-r--r--support/nfs/cacheio.c5
-rw-r--r--utils/mountd/cache.c10
3 files changed, 11 insertions, 5 deletions
diff --git a/support/include/nfslib.h b/support/include/nfslib.h
index 73f3c20..f210a06 100644
--- a/support/include/nfslib.h
+++ b/support/include/nfslib.h
@@ -164,6 +164,7 @@ void qword_adduint(char **bpp, int *lp, unsigned int n);
void qword_addeol(char **bpp, int *lp);
int qword_get_uint(char **bpp, unsigned int *anint);
void qword_printuint(FILE *f, unsigned int num);
+void qword_printtimefrom(FILE *f, unsigned int num);
void closeall(int min);
diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c
index 9bad8e6..e641c45 100644
--- a/support/nfs/cacheio.c
+++ b/support/nfs/cacheio.c
@@ -153,6 +153,11 @@ void qword_printuint(FILE *f, unsigned int num)
fprintf(f, "%u ", num);
}
+void qword_printtimefrom(FILE *f, unsigned int num)
+{
+ fprintf(f, "%lu ", time(0) + num);
+}
+
int qword_eol(FILE *f)
{
int err;
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 8280234..6de05f1 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -118,7 +118,7 @@ static void auth_unix_ip(FILE *f)
}
qword_print(f, "nfsd");
qword_print(f, ipaddr);
- qword_printuint(f, time(0) + DEFAULT_TTL);
+ qword_printtimefrom(f, DEFAULT_TTL);
if (use_ipaddr)
qword_print(f, ipaddr);
else if (client)
@@ -183,7 +183,7 @@ static void auth_unix_gid(FILE *f)
}
}
qword_printuint(f, uid);
- qword_printuint(f, time(0) + DEFAULT_TTL);
+ qword_printtimefrom(f, DEFAULT_TTL);
if (rv >= 0) {
qword_printuint(f, ngroups);
for (i=0; i<ngroups; i++)
@@ -730,7 +730,7 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex
int different_fs = strcmp(path, exp->e_path) != 0;
int flag_mask = different_fs ? ~NFSEXP_FSID : ~0;
- qword_printuint(f, time(0) + exp->e_ttl);
+ qword_printtimefrom(f, exp->e_ttl);
qword_printint(f, exp->e_flags & flag_mask);
qword_printint(f, exp->e_anonuid);
qword_printint(f, exp->e_anongid);
@@ -750,7 +750,7 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex
qword_printhex(f, u, 16);
}
} else
- qword_printuint(f, time(0) + DEFAULT_TTL);
+ qword_printtimefrom(f, DEFAULT_TTL);
return qword_eol(f);
}
@@ -1339,7 +1339,7 @@ int cache_export(nfs_export *exp, char *path)
qword_print(f, "nfsd");
qword_print(f,
host_ntop(get_addrlist(exp->m_client, 0), buf, sizeof(buf)));
- qword_printuint(f, time(0) + exp->m_export.e_ttl);
+ qword_printtimefrom(f, exp->m_export.e_ttl);
qword_print(f, exp->m_client->m_hostname);
err = qword_eol(f);