gcc42-integer-overflow-fix-20071007
[openafs.git] / src / dir / dir.c
index 80cbe52..c32f149 100644 (file)
@@ -25,55 +25,24 @@ RCSID
 #include "h/errno.h"
 #endif
 #include "h/time.h"
-#if defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV)
+#if defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX20_ENV)
 #include "h/errno.h"
 #else
 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
 #include "h/kernel.h"
 #endif
 #endif
-#if    defined(AFS_SUN56_ENV) || defined(AFS_HPUX_ENV)
+#if    defined(AFS_SUN56_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_DARWIN80_ENV)
 #include "afs/sysincludes.h"
 #endif
-#if defined(AFS_FBSD_ENV)
-#include "h/libkern.h"
-#include "h/lock.h"
-#include "vm/vm.h"
-#include "vm/vm_extern.h"
-#include "vm/pmap.h"
-#include "vm/vm_map.h"
-#endif /* AFS_FBSD_ENV */
 #if !defined(AFS_SGI64_ENV) && !defined(AFS_DARWIN60_ENV)
 #include "h/user.h"
 #endif /* AFS_SGI64_ENV */
 #include "h/uio.h"
-#ifdef AFS_DEC_ENV
-#include "afs/gfs_vfs.h"
-#include "afs/gfs_vnode.h"
-#else
-#ifdef AFS_MACH_ENV
-#ifdef  NeXT
-#include <sys/vfs.h>
-#include <sys/vnode.h>
-#include <ufs/inode.h>
-#else
-#include <vfs/vfs.h>
-#include <vfs/vnode.h>
-#include <sys/inode.h>
-#endif /* NeXT */
-#else /* AFS_MACH_ENV */
 #ifdef AFS_OSF_ENV
 #include <sys/mount.h>
 #include <sys/vnode.h>
 #include <ufs/inode.h>
-#else /* AFS_OSF_ENV */
-#ifdef AFS_SUN5_ENV
-#else
-#if !defined(AFS_SGI_ENV)
-#endif
-#endif /* AFS_OSF_ENV */
-#endif /* AFS_MACH_ENV */
-#endif
 #endif
 #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_HPUX110_ENV)
 #include "h/mbuf.h"
@@ -82,18 +51,25 @@ RCSID
 #include "netinet/in.h"
 #endif
 
-/* Irix needs this */
-struct DirEntry *DRead();
+/* afs_buffer.c */
+/* These are needed because afs_prototypes.h is not included here */
+extern void *DRead();
+extern void *DNew();
 
 #else /* !defined(UKERNEL) */
 #include "afs/stds.h"
 #include "afs/sysincludes.h"
+
+/* afs_buffer.c */
+/* These are needed because afs_prototypes.h is not included here */
+extern void *DRead();
+extern void *DNew();
+
 #endif /* !defined(UKERNEL) */
 #include "afs/afs_osi.h"
 
 #include "afs/dir.h"
 
-#include "afs/longc_procs.h"
 #ifdef AFS_LINUX20_ENV
 #include "h/string.h"
 #endif
@@ -501,7 +477,7 @@ DirHash(register char *string)
 {
     /* Hash a string to a number between 0 and NHASHENT. */
     register unsigned char tc;
-    register int hval;
+    unsigned int hval;
     register int tval;
     hval = 0;
     while ((tc = (*string++))) {
@@ -511,7 +487,7 @@ DirHash(register char *string)
     tval = hval & (NHASHENT - 1);
     if (tval == 0)
        return tval;
-    else if (hval < 0)
+    else if (hval >= 1<<31)
        tval = NHASHENT - tval;
     return tval;
 }