summaryrefslogtreecommitdiff
path: root/nfsd
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2015-12-29 23:10:44 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2015-12-29 23:17:16 +0100
commitd73d717ecac42457f12a2d843454ecda3aa7b004 (patch)
tree2e023dd0c558be020b9dda9098977b9f4d49fe28 /nfsd
parent8c49801c8f7e3f800cabedf8fca8ccec3cf35a22 (diff)
fix compiler warnings in hurd/nfs and hurd/nfsd
nfs: Fix compiler warnings. * nfs/ops.c (netfs_get_dirents): Initialize buf. * nfsd/nfsd.h: Define cache_handle_array union. * nfsd/cache.c: Use new cache_handle_array union. * nfds/ops.c: Likewise.
Diffstat (limited to 'nfsd')
-rw-r--r--nfsd/cache.c23
-rw-r--r--nfsd/nfsd.h7
-rw-r--r--nfsd/ops.c14
3 files changed, 25 insertions, 19 deletions
diff --git a/nfsd/cache.c b/nfsd/cache.c
index 778f5570..1b2b6ee9 100644
--- a/nfsd/cache.c
+++ b/nfsd/cache.c
@@ -279,7 +279,7 @@ lookup_cache_handle (int *p, struct cache_handle **cp, struct idspec *i)
hash = fh_hash ((char *)p, i);
pthread_mutex_lock (&fhhashlock);
for (c = fhhashtable[hash]; c; c = c->next)
- if (c->ids == i && ! bcmp (c->handle, p, NFS2_FHSIZE))
+ if (c->ids == i && ! bcmp (c->handle.array, p, NFS2_FHSIZE))
{
if (c->references == 0)
nfreefh--;
@@ -303,7 +303,7 @@ lookup_cache_handle (int *p, struct cache_handle **cp, struct idspec *i)
}
c = malloc (sizeof (struct cache_handle));
- memcpy (c->handle, p, NFS2_FHSIZE);
+ memcpy (c->handle.array, p, NFS2_FHSIZE);
cred_ref (i);
c->ids = i;
c->port = port;
@@ -381,11 +381,11 @@ scan_fhs ()
struct cache_handle *
create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
{
- char fhandle[NFS2_FHSIZE];
+ union cache_handle_array fhandle;
error_t err;
struct cache_handle *c;
int hash;
- char *bp = fhandle + sizeof (int);
+ char *bp = fhandle.array + sizeof (int);
size_t handlelen = NFS2_FHSIZE - sizeof (int);
mach_port_t newport, ref;
@@ -405,22 +405,23 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
mach_port_destroy (mach_task_self (), ref);
/* Fetch the file handle. */
- *(int *)fhandle = fs;
+ fhandle.fs = fs;
err = file_getfh (newport, &bp, &handlelen);
mach_port_deallocate (mach_task_self (), newport);
if (err || handlelen != NFS2_FHSIZE - sizeof (int))
return 0;
- if (bp != fhandle + sizeof (int))
+ if (bp != fhandle.array + sizeof (int))
{
- memcpy (fhandle + sizeof (int), bp, NFS2_FHSIZE - sizeof (int));
+ memcpy (fhandle.array + sizeof (int), bp, NFS2_FHSIZE - sizeof (int));
munmap (bp, handlelen);
}
/* Cache it. */
- hash = fh_hash (fhandle, credc->ids);
+ hash = fh_hash (fhandle.array, credc->ids);
pthread_mutex_lock (&fhhashlock);
for (c = fhhashtable[hash]; c; c = c->next)
- if (c->ids == credc->ids && ! bcmp (fhandle, c->handle, NFS2_FHSIZE))
+ if (c->ids == credc->ids &&
+ ! bcmp (fhandle.array, c->handle.array, NFS2_FHSIZE))
{
/* Return this one. */
if (c->references == 0)
@@ -436,7 +437,7 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
err = fsys_getfile (lookup_filesystem (fs),
credc->ids->uids, credc->ids->nuids,
credc->ids->gids, credc->ids->ngids,
- fhandle + sizeof (int), NFS2_FHSIZE - sizeof (int),
+ fhandle.array + sizeof (int), NFS2_FHSIZE - sizeof (int),
&newport);
if (err)
{
@@ -446,7 +447,7 @@ create_cached_handle (int fs, struct cache_handle *credc, file_t userport)
/* Create it anew. */
c = malloc (sizeof (struct cache_handle));
- memcpy (c->handle, fhandle, NFS2_FHSIZE);
+ memcpy (c->handle.array, fhandle.array, NFS2_FHSIZE);
cred_ref (credc->ids);
c->ids = credc->ids;
c->port = newport;
diff --git a/nfsd/nfsd.h b/nfsd/nfsd.h
index 4afff061..4ab558c4 100644
--- a/nfsd/nfsd.h
+++ b/nfsd/nfsd.h
@@ -42,10 +42,15 @@ struct idspec
int references;
};
+union cache_handle_array {
+ char array[NFS2_FHSIZE];
+ int fs;
+};
+
struct cache_handle
{
struct cache_handle *next, **prevp;
- char handle[NFS2_FHSIZE];
+ union cache_handle_array handle;
struct idspec *ids;
file_t port;
time_t lastuse;
diff --git a/nfsd/ops.c b/nfsd/ops.c
index 6e2cbb15..aa37c4a4 100644
--- a/nfsd/ops.c
+++ b/nfsd/ops.c
@@ -181,10 +181,10 @@ op_lookup (struct cache_handle *c,
if (err)
return err;
- newc = create_cached_handle (*(int *)c->handle, c, newport);
+ newc = create_cached_handle (c->handle.fs, c, newport);
if (!newc)
return ESTALE;
- *reply = encode_fhandle (*reply, newc->handle);
+ *reply = encode_fhandle (*reply, newc->handle.array);
*reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -375,11 +375,11 @@ op_create (struct cache_handle *c,
}
free (name);
- newc = create_cached_handle (*(int *)c->handle, c, newport);
+ newc = create_cached_handle (c->handle.fs, c, newport);
if (!newc)
return ESTALE;
- *reply = encode_fhandle (*reply, newc->handle);
+ *reply = encode_fhandle (*reply, newc->handle.array);
*reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -533,10 +533,10 @@ op_mkdir (struct cache_handle *c,
if (err)
return err;
- newc = create_cached_handle (*(int *)c->handle, c, newport);
+ newc = create_cached_handle (c->handle.fs, c, newport);
if (!newc)
return ESTALE;
- *reply = encode_fhandle (*reply, newc->handle);
+ *reply = encode_fhandle (*reply, newc->handle.array);
*reply = encode_fattr (*reply, &st, version);
return 0;
}
@@ -666,7 +666,7 @@ op_mnt (struct cache_handle *c,
free (name);
if (!newc)
return ESTALE;
- *reply = encode_fhandle (*reply, newc->handle);
+ *reply = encode_fhandle (*reply, newc->handle.array);
return 0;
}