commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 49/75: fix compiler warnings in hurd/nfs and hurd/nfsd


From: Samuel Thibault
Subject: [hurd] 49/75: fix compiler warnings in hurd/nfs and hurd/nfsd
Date: Thu, 14 Jan 2016 01:04:09 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch dde
in repository hurd.

commit d73d717ecac42457f12a2d843454ecda3aa7b004
Author: Flavio Cruz <address@hidden>
Date:   Tue Dec 29 23:10:44 2015 +0100

    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.
---
 nfs/ops.c    |  2 +-
 nfsd/cache.c | 23 ++++++++++++-----------
 nfsd/nfsd.h  |  7 ++++++-
 nfsd/ops.c   | 14 +++++++-------
 4 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/nfs/ops.c b/nfs/ops.c
index a4d6ac7..79cd3a6 100644
--- a/nfs/ops.c
+++ b/nfs/ops.c
@@ -1819,7 +1819,7 @@ netfs_get_dirents (struct iouser *cred, struct node *np,
                   mach_msg_type_number_t *datacnt,
                   vm_size_t bufsiz, int *amt)
 {
-  void *buf;
+  void *buf = NULL;
   size_t our_bufsiz, allocsize;
   void *bp;
   char *userdp;
diff --git a/nfsd/cache.c b/nfsd/cache.c
index 778f557..1b2b6ee 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 4afff06..4ab558c 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 6e2cbb1..aa37c4a 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;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]