gcc 4.5: Sequence point warning fixes
[openafs.git] / src / afs / afs_user.c
index 228c8b7..d99f3a0 100644 (file)
  * Implements:
  */
 #include <afsconfig.h>
-#include "../afs/param.h"
+#include "afs/param.h"
 
-RCSID("$Header$");
 
-#include "../afs/stds.h"
-#include "../afs/sysincludes.h"        /* Standard vendor system headers */
+#include "afs/stds.h"
+#include "afs/sysincludes.h"   /* Standard vendor system headers */
 
 #if !defined(UKERNEL)
+#if !defined(AFS_LINUX20_ENV)
 #include <net/if.h>
+#endif
 #include <netinet/in.h>
 
 #ifdef AFS_SGI62_ENV
-#include "../h/hashing.h"
+#include "h/hashing.h"
 #endif
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV)
 #include <netinet/in_var.h>
 #endif /* ! AFS_HPUX110_ENV */
 #endif /* !defined(UKERNEL) */
 
-#include "../afs/afsincludes.h"        /* Afs-based standard headers */
-#include "../afs/afs_stats.h"   /* afs statistics */
+#include "afsincludes.h"       /* Afs-based standard headers */
+#include "afs/afs_stats.h"     /* afs statistics */
 
 #if    defined(AFS_SUN56_ENV)
 #include <inet/led.h>
@@ -48,6 +49,7 @@ afs_rwlock_t afs_xuser;
 struct unixuser *afs_users[NUSERS];
 
 
+#ifndef AFS_PAG_MANAGER
 /* Forward declarations */
 void afs_ResetAccessCache(afs_int32 uid, int alock);
 
@@ -55,17 +57,18 @@ void afs_ResetAccessCache(afs_int32 uid, int alock);
  * Called with afs_xuser, afs_xserver and afs_xconn locks held, to delete
  * appropriate conn structures for au
  */
-static void RemoveUserConns(register struct unixuser *au)
+static void
+RemoveUserConns(register struct unixuser *au)
 {
     register int i;
     register struct server *ts;
     register struct srvAddr *sa;
-    register struct conn *tc, **lc;
+    register struct afs_conn *tc, **lc;
 
     AFS_STATCNT(RemoveUserConns);
-    for (i=0;i<NSERVERS;i++) {
-       for (ts = afs_servers[i]; ts; ts=ts->next) {
-           for (sa = ts->addr; sa; sa = sa->next_sa) { 
+    for (i = 0; i < NSERVERS; i++) {
+       for (ts = afs_servers[i]; ts; ts = ts->next) {
+           for (sa = ts->addr; sa; sa = sa->next_sa) {
                lc = &sa->conns;
                for (tc = *lc; tc; lc = &tc->next, tc = *lc) {
                    if (tc->user == au && tc->refCount == 0) {
@@ -73,15 +76,16 @@ static void RemoveUserConns(register struct unixuser *au)
                        AFS_GUNLOCK();
                        rx_DestroyConnection(tc->id);
                        AFS_GLOCK();
-                       afs_osi_Free(tc, sizeof(struct conn));
-                       break;  /* at most one instance per server */
-                   } /*Found unreferenced connection for user*/
-               } /*For each connection on the server*/
+                       afs_osi_Free(tc, sizeof(struct afs_conn));
+                       break;  /* at most one instance per server */
+                   }           /*Found unreferenced connection for user */
+               }               /*For each connection on the server */
            }
-       } /*For each server on chain*/
-    } /*For each chain*/
+       }                       /*For each server on chain */
+    }                          /*For each chain */
 
-} /*RemoveUserConns*/
+}                              /*RemoveUserConns */
+#endif /* !AFS_PAG_MANAGER */
 
 
 /* Called from afs_Daemon to garbage collect unixusers no longer using system,
@@ -91,7 +95,8 @@ static void RemoveUserConns(register struct unixuser *au)
  * other epochs as soon as possible (old file servers act bizarrely when they
  * see epoch changes).
  */
-void afs_GCUserData(int aforce)
+void
+afs_GCUserData(int aforce)
 {
     register struct unixuser *tu, **lu, *nu;
     register int i;
@@ -99,11 +104,13 @@ void afs_GCUserData(int aforce)
 
     AFS_STATCNT(afs_GCUserData);
     /* Obtain locks in valid order */
-    ObtainWriteLock(&afs_xuser,95);
+    ObtainWriteLock(&afs_xuser, 95);
+#ifndef AFS_PAG_MANAGER
     ObtainReadLock(&afs_xserver);
-    ObtainWriteLock(&afs_xconn,96);
+    ObtainWriteLock(&afs_xconn, 96);
+#endif
     now = osi_Time();
-    for (i=0;i<NUSERS;i++) {
+    for (i = 0; i < NUSERS; i++) {
        for (lu = &afs_users[i], tu = *lu; tu; tu = nu) {
            delFlag = 0;        /* should we delete this dude? */
            /* Don't garbage collect users in use now (refCount) */
@@ -115,8 +122,7 @@ void afs_GCUserData(int aforce)
                     */
                    if (tu->ct.EndTimestamp < now - NOTOKTIMEOUT)
                        delFlag = 1;
-               }
-               else {
+               } else {
                    if (aforce || (tu->tokenTime < now - NOTOKTIMEOUT))
                        delFlag = 1;
                }
@@ -124,43 +130,49 @@ void afs_GCUserData(int aforce)
            nu = tu->next;
            if (delFlag) {
                *lu = tu->next;
+#ifndef AFS_PAG_MANAGER
                RemoveUserConns(tu);
+#endif
                if (tu->stp)
                    afs_osi_Free(tu->stp, tu->stLen);
                if (tu->exporter)
                    EXP_RELE(tu->exporter);
                afs_osi_Free(tu, sizeof(struct unixuser));
-           }
-           else {
+           } else {
                lu = &tu->next;
            }
        }
     }
+#ifndef AFS_PAG_MANAGER
     ReleaseWriteLock(&afs_xconn);
-    ReleaseWriteLock(&afs_xuser);
+#endif
+#ifndef AFS_PAG_MANAGER
     ReleaseReadLock(&afs_xserver);
+#endif
+    ReleaseWriteLock(&afs_xuser);
 
-} /*afs_GCUserData*/
+}                              /*afs_GCUserData */
 
 
+#ifndef AFS_PAG_MANAGER
 /*
  * Check for unixusers who encountered bad tokens, and reset the access
  * cache for these guys.  Can't do this when token expiration detected,
  * since too many locks are set then.
  */
-void afs_CheckTokenCache(void)
+void
+afs_CheckTokenCache(void)
 {
     register int i;
     register struct unixuser *tu;
     afs_int32 now;
-    register struct cell *tcell;
 
     AFS_STATCNT(afs_CheckCacheResets);
     ObtainReadLock(&afs_xvcache);
     ObtainReadLock(&afs_xuser);
     now = osi_Time();
-    for (i=0;i<NUSERS;i++) {
-       for (tu=afs_users[i]; tu; tu=tu->next) {
+    for (i = 0; i < NUSERS; i++) {
+       for (tu = afs_users[i]; tu; tu = tu->next) {
            register afs_int32 uid;
 
            /*
@@ -174,10 +186,10 @@ void afs_CheckTokenCache(void)
                     * cache.
                     */
 #ifdef notdef
-                   tcell = afs_GetCell(tu->cell);
                    /* I really hate this message - MLK */
-                   afs_warn("afs: Tokens for user of AFS id %d for cell %s expired now\n",
-                          tu->vid, tcell->cellName);
+                   afs_warn
+                       ("afs: Tokens for user of AFS id %d for cell %s expired now\n",
+                        tu->vid, afs_GetCell(tu->cell)->cellName);
 #endif
                    tu->states |= (UTokensBad | UNeedsReset);
                }
@@ -192,55 +204,56 @@ void afs_CheckTokenCache(void)
     ReleaseReadLock(&afs_xuser);
     ReleaseReadLock(&afs_xvcache);
 
-} /*afs_CheckTokenCache*/
+}                              /*afs_CheckTokenCache */
 
 
-void afs_ResetAccessCache(afs_int32 uid, int alock)
+void
+afs_ResetAccessCache(afs_int32 uid, int alock)
 {
-    register int i, j;
+    register int i;
     register struct vcache *tvc;
     struct axscache *ac;
 
     AFS_STATCNT(afs_ResetAccessCache);
     if (alock)
        ObtainReadLock(&afs_xvcache);
-    for(i=0;i<VCSIZE;i++) {
-       for(tvc=afs_vhashT[i]; tvc; tvc=tvc->hnext) {
-         /* really should do this under cache write lock, but that.
-            is hard to under locking hierarchy */
-         if (tvc->Access && (ac = afs_FindAxs(tvc->Access, uid))) {
-            afs_RemoveAxs (&tvc->Access, ac);
-          }
+    for (i = 0; i < VCSIZE; i++) {
+       for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
+           /* really should do this under cache write lock, but that.
+            * is hard to under locking hierarchy */
+           if (tvc->Access && (ac = afs_FindAxs(tvc->Access, uid))) {
+               afs_RemoveAxs(&tvc->Access, ac);
+           }
        }
     }
     if (alock)
        ReleaseReadLock(&afs_xvcache);
 
-} /*afs_ResetAccessCache*/
+}                              /*afs_ResetAccessCache */
 
 
 /*
  * Ensure all connections make use of new tokens.  Discard incorrectly-cached
  * access info.
  */
-void afs_ResetUserConns (register struct unixuser *auser)
+void
+afs_ResetUserConns(register struct unixuser *auser)
 {
     int i;
-    struct server *ts;
     struct srvAddr *sa;
-    struct conn *tc;
-    
+    struct afs_conn *tc;
+
     AFS_STATCNT(afs_ResetUserConns);
     ObtainReadLock(&afs_xsrvAddr);
-    ObtainWriteLock(&afs_xconn,98);
+    ObtainWriteLock(&afs_xconn, 98);
 
-    for (i=0;i<NSERVERS;i++) {
-       for (sa = afs_srvAddrs[i]; sa; sa=sa->next_bkt) {
-               for (tc = sa->conns; tc; tc=tc->next) {
-                   if (tc->user == auser) {
-                       tc->forceConnectFS = 1;
-                   }
+    for (i = 0; i < NSERVERS; i++) {
+       for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
+           for (tc = sa->conns; tc; tc = tc->next) {
+               if (tc->user == auser) {
+                   tc->forceConnectFS = 1;
                }
+           }
        }
     }
 
@@ -248,18 +261,20 @@ void afs_ResetUserConns (register struct unixuser *auser)
     ReleaseReadLock(&afs_xsrvAddr);
     afs_ResetAccessCache(auser->uid, 1);
     auser->states &= ~UNeedsReset;
-} /*afs_ResetUserConns*/
+}                              /*afs_ResetUserConns */
+#endif /* !AFS_PAG_MANAGER */
 
 
-struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktype)
+struct unixuser *
+afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktype)
 {
     register struct unixuser *tu;
     register afs_int32 i;
 
     AFS_STATCNT(afs_FindUser);
     i = UHash(auid);
-    ObtainWriteLock(&afs_xuser,99);
-    for(tu = afs_users[i]; tu; tu = tu->next) {
+    ObtainWriteLock(&afs_xuser, 99);
+    for (tu = afs_users[i]; tu; tu = tu->next) {
        if (tu->uid == auid && ((tu->cell == acell) || (acell == -1))) {
            tu->refCount++;
            ReleaseWriteLock(&afs_xuser);
@@ -269,7 +284,7 @@ struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktyp
     ReleaseWriteLock(&afs_xuser);
     return NULL;
 
-} /*afs_FindUser*/
+}                              /*afs_FindUser */
 
 
 /*------------------------------------------------------------------------
@@ -294,15 +309,16 @@ struct unixuser *afs_FindUser(afs_int32 auid, afs_int32 acell, afs_int32 locktyp
  *     As advertised.
  *------------------------------------------------------------------------*/
 
-void afs_ComputePAGStats(void)
+void
+afs_ComputePAGStats(void)
 {
-    register struct unixuser *currPAGP;                  /*Ptr to curr PAG*/
-    register struct unixuser *cmpPAGP;           /*Ptr to PAG being compared*/
-    register struct afs_stats_AuthentInfo *authP; /*Ptr to stats area*/
-    int curr_Record;                              /*Curr record */
-    int currChain;                               /*Curr hash chain*/
-    int currChainLen;                            /*Length of curr hash chain*/
-    int currPAGRecords;                                  /*# records in curr PAG*/
+    register struct unixuser *currPAGP;        /*Ptr to curr PAG */
+    register struct unixuser *cmpPAGP; /*Ptr to PAG being compared */
+    register struct afs_stats_AuthentInfo *authP;      /*Ptr to stats area */
+    int curr_Record;           /*Curr record */
+    int currChain;             /*Curr hash chain */
+    int currChainLen;          /*Length of curr hash chain */
+    int currPAGRecords;                /*# records in curr PAG */
 
     /*
      * Lock out everyone else from scribbling on the PAG entries.
@@ -316,18 +332,17 @@ void afs_ComputePAGStats(void)
      */
     curr_Record = 0;
     authP = &(afs_stats_cmfullperf.authent);
-    authP->curr_PAGs            = 0;
-    authP->curr_Records                 = 0;
-    authP->curr_AuthRecords     = 0;
-    authP->curr_UnauthRecords   = 0;
-    authP->curr_MaxRecordsInPAG         = 0;
-    authP->curr_LongestChain    = 0;
+    authP->curr_PAGs = 0;
+    authP->curr_Records = 0;
+    authP->curr_AuthRecords = 0;
+    authP->curr_UnauthRecords = 0;
+    authP->curr_MaxRecordsInPAG = 0;
+    authP->curr_LongestChain = 0;
 
     for (currChain = 0; currChain < NUSERS; currChain++) {
        currChainLen = 0;
        for (currPAGP = afs_users[currChain]; currPAGP;
-            currPAGP = currPAGP->next) 
-         {
+            currPAGP = currPAGP->next) {
            /*
             * Bump the number of records on this current chain, along with
             * the total number of records in existence.
@@ -345,14 +360,15 @@ void afs_ComputePAGStats(void)
             * If this PAG record has already been ``counted', namely
             * associated with a PAG and tallied, clear its bit and move on.
             */
-            (authP->curr_Records)++;
+           (authP->curr_Records)++;
            if (currPAGP->states & UPAGCounted) {
                currPAGP->states &= ~UPAGCounted;
                continue;
-           } /*We've counted this one already*/
+           }
 
 
 
+           /*We've counted this one already */
            /*
             * Jot initial info down, then sweep down the rest of the hash
             * chain, looking for matching PAG entries.  Note: to properly
@@ -371,13 +387,13 @@ void afs_ComputePAGStats(void)
                     */
                    cmpPAGP->states |= UPAGCounted;
                    currPAGRecords++;
-                   if ((cmpPAGP->states & UHasTokens) &&
-                       !(cmpPAGP->states & UTokensBad))
+                   if ((cmpPAGP->states & UHasTokens)
+                       && !(cmpPAGP->states & UTokensBad))
                        (authP->curr_AuthRecords)++;
                    else
                        (authP->curr_UnauthRecords)++;
-               } /*Records belong to same PAG*/
-           } /*Compare to rest of PAG records in chain*/
+               }               /*Records belong to same PAG */
+           }                   /*Compare to rest of PAG records in chain */
 
            /*
             * In the above comparisons, the current PAG record has been
@@ -397,7 +413,7 @@ void afs_ComputePAGStats(void)
                if (currPAGRecords > authP->HWM_MaxRecordsInPAG)
                    authP->HWM_MaxRecordsInPAG = currPAGRecords;
            }
-       } /*Sweep a hash chain*/
+       }                       /*Sweep a hash chain */
 
        /*
         * If the chain we just finished zipping through is the longest we've
@@ -409,7 +425,7 @@ void afs_ComputePAGStats(void)
                authP->HWM_LongestChain = currChainLen;
        }
 
-    } /*For each hash chain in afs_user*/
+    }                          /*For each hash chain in afs_user */
 
     /*
      * Now that we've counted everything up, we can consider all-time
@@ -425,19 +441,19 @@ void afs_ComputePAGStats(void)
      */
     ReleaseReadLock(&afs_xuser);
 
-} /*afs_ComputePAGStats*/
+}                              /*afs_ComputePAGStats */
 
 
-struct unixuser *afs_GetUser(register afs_int32 auid, 
-       afs_int32 acell, afs_int32 locktype)
+struct unixuser *
+afs_GetUser(register afs_int32 auid, afs_int32 acell, afs_int32 locktype)
 {
-    register struct unixuser *tu, *pu=0;
+    register struct unixuser *tu, *pu = 0;
     register afs_int32 i;
     register afs_int32 RmtUser = 0;
 
     AFS_STATCNT(afs_GetUser);
     i = UHash(auid);
-    ObtainWriteLock(&afs_xuser,104);
+    ObtainWriteLock(&afs_xuser, 104);
     for (tu = afs_users[i]; tu; tu = tu->next) {
        if (tu->uid == auid) {
            RmtUser = 0;
@@ -452,19 +468,18 @@ struct unixuser *afs_GetUser(register afs_int32 auid,
                tu->refCount++;
                ReleaseWriteLock(&afs_xuser);
                return tu;
-           } else
-               if (tu->cell == acell || acell == -1) {
-                   tu->refCount++;
-                   ReleaseWriteLock(&afs_xuser);
-                   return tu;
-               }               
+           } else if (tu->cell == acell || acell == -1) {
+               tu->refCount++;
+               ReleaseWriteLock(&afs_xuser);
+               return tu;
+           }
        }
     }
-    tu = (struct unixuser *) afs_osi_Alloc(sizeof(struct unixuser));
+    tu = (struct unixuser *)afs_osi_Alloc(sizeof(struct unixuser));
 #ifndef AFS_NOSTATS
     afs_stats_cmfullperf.authent.PAGCreations++;
 #endif /* AFS_NOSTATS */
-    memset((char *)tu, 0, sizeof(struct unixuser));
+    memset(tu, 0, sizeof(struct unixuser));
     tu->next = afs_users[i];
     afs_users[i] = tu;
     if (RmtUser) {
@@ -474,8 +489,9 @@ struct unixuser *afs_GetUser(register afs_int32 auid,
         * we simply rerecord relevant information from the original
         * structure
         */
-        if (pu && pu->exporter) {
-           (void) EXP_HOLD(tu->exporter = pu->exporter);
+       if (pu && pu->exporter) {
+           tu->exporter = pu->exporter;
+           (void)EXP_HOLD(tu->exporter);
        }
     }
     tu->uid = auid;
@@ -486,21 +502,23 @@ struct unixuser *afs_GetUser(register afs_int32 auid,
     ReleaseWriteLock(&afs_xuser);
     return tu;
 
-} /*afs_GetUser*/
+}                              /*afs_GetUser */
 
 
-void afs_PutUser(register struct unixuser *au, afs_int32 locktype)
+void
+afs_PutUser(register struct unixuser *au, afs_int32 locktype)
 {
     AFS_STATCNT(afs_PutUser);
     --au->refCount;
-} /*afs_PutUser*/
+}                              /*afs_PutUser */
 
 
 /*
  * Set the primary flag on a unixuser structure, ensuring that exactly one
  * dude has the flag set at any time for a particular unix uid.
  */
-void afs_SetPrimary(register struct unixuser *au, register int aflag)
+void
+afs_SetPrimary(register struct unixuser *au, register int aflag)
 {
     register struct unixuser *tu;
     register int i;
@@ -509,12 +527,12 @@ void afs_SetPrimary(register struct unixuser *au, register int aflag)
     AFS_STATCNT(afs_SetPrimary);
     i = UHash(au->uid);
     pu = NULL;
-    ObtainWriteLock(&afs_xuser,105);
+    ObtainWriteLock(&afs_xuser, 105);
     /*
      * See if anyone is this uid's primary cell yet; recording in pu the
      * corresponding user
      */
-    for (tu=afs_users[i]; tu; tu=tu->next) {
+    for (tu = afs_users[i]; tu; tu = tu->next) {
        if (tu->uid == au->uid && (tu->states & UPrimary)) {
            pu = tu;
        }
@@ -530,21 +548,51 @@ void afs_SetPrimary(register struct unixuser *au, register int aflag)
     }
     if (aflag == 1) {
        /* setting au to be primary */
-       if (pu) pu->states &= ~UPrimary;
+       if (pu)
+           pu->states &= ~UPrimary;
        au->states |= UPrimary;
-    }
-    else
-       if (aflag == 0) {
-           /* we don't know if we're supposed to be primary or not */
-           if (!pu || au == pu) {
-               au->states |= UPrimary;
-           }
-           else
-               au->states &= ~UPrimary;
+    } else if (aflag == 0) {
+       /* we don't know if we're supposed to be primary or not */
+       if (!pu || au == pu) {
+           au->states |= UPrimary;
+       } else
+           au->states &= ~UPrimary;
     }
     ReleaseWriteLock(&afs_xuser);
 
-} /*afs_SetPrimary*/
+}                              /*afs_SetPrimary */
+
+void
+afs_NotifyUser(struct unixuser *auser, int event)
+{
+#ifdef AFS_DARWIN_ENV
+    darwin_notify_perms(auser, event);
+#endif
+}
+
+/**
+ * Mark all of the unixuser records held for a particular PAG as
+ * expired
+ *
+ * @param[in] pag
+ *     PAG to expire records for
+ */
+void
+afs_MarkUserExpired(afs_int32 pag)
+{
+    afs_int32 i;
+    struct unixuser *tu;
+
+    i = UHash(pag);
+    ObtainWriteLock(&afs_xuser, 9);
+    for (tu = afs_users[i]; tu; tu = tu->next) {
+       if (tu->uid == pag) {
+           tu->ct.EndTimestamp = 0;
+           tu->tokenTime = 0;
+       }
+    }
+    ReleaseWriteLock(&afs_xuser);
+}
 
 
 #if AFS_GCPAGS
@@ -562,7 +610,7 @@ void afs_SetPrimary(register struct unixuser *au, register int aflag)
  * the per process loop in GCPAGs doesn't have to
  * check processes without pags against the afs_users table.
  */
-static afs_int32 afs_GCPAGs_UIDBaseTokenCount=0;
+static afs_int32 afs_GCPAGs_UIDBaseTokenCount = 0;
 
 /*
  * These variables keep track of the number of times
@@ -570,50 +618,54 @@ static afs_int32 afs_GCPAGs_UIDBaseTokenCount=0;
  * walking the process table, there is something wrong and we should not
  * prematurely expire any tokens.
  */
-static size_t afs_GCPAGs_perproc_count=0;
-static size_t afs_GCPAGs_cred_count=0;
+static size_t afs_GCPAGs_perproc_count = 0;
+static size_t afs_GCPAGs_cred_count = 0;
 
 /*
  * LOCKS: afs_GCPAGs_perproc_func requires write lock on afs_xuser
  */
-void afs_GCPAGs_perproc_func(AFS_PROC *pproc)
+#if !defined(LINUX_KEYRING_SUPPORT) && (!defined(STRUCT_TASK_STRUCT_HAS_CRED) || defined(HAVE_LINUX_RCU_READ_LOCK))
+void
+afs_GCPAGs_perproc_func(afs_proc_t * pproc)
 {
     afs_int32 pag, hash, uid;
-    const struct AFS_UCRED *pcred;
+    const afs_ucred_t *pcred;
 
     afs_GCPAGs_perproc_count++;
 
     pcred = afs_osi_proc2cred(pproc);
-    if(!pcred) 
+    if (!pcred)
        return;
 
     afs_GCPAGs_cred_count++;
 
     pag = PagInCred(pcred);
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD40_ENV)
-    uid = (pag != NOPAG ? pag : pcred->cr_uid);
+#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_LINUX22_ENV)
+    uid = (pag != NOPAG ? pag : afs_cr_uid(pcred));
+#elif defined(AFS_SUN510_ENV)
+    uid = (pag != NOPAG ? pag : crgetruid(pcred));
 #else
-    uid = (pag != NOPAG ? pag : pcred->cr_ruid);
+    uid = (pag != NOPAG ? pag : afs_cr_ruid(pcred));
 #endif
     hash = UHash(uid);
 
     /* if this token is PAG based, or it's UID based and 
-       UID-based tokens exist */
-    if((pag != NOPAG) || (afs_GCPAGs_UIDBaseTokenCount)) {
+     * UID-based tokens exist */
+    if ((pag != NOPAG) || (afs_GCPAGs_UIDBaseTokenCount)) {
        /* find the entries for this uid in all cells and clear the not
         * referenced flag.  Can't use afs_FindUser, because it just returns
-         * the specific cell asked for, or the first one found. 
-         */
+        * the specific cell asked for, or the first one found. 
+        */
        struct unixuser *pu;
-       for(pu = afs_users[hash]; pu; pu = pu->next) {
+       for (pu = afs_users[hash]; pu; pu = pu->next) {
            if (pu->uid == uid) {
-               if(pu->states & TMP_UPAGNotReferenced) {
+               if (pu->states & TMP_UPAGNotReferenced) {
                    /* clear the 'deleteme' flag for this entry */
                    pu->states &= ~TMP_UPAGNotReferenced;
-                   if(pag == NOPAG) {
+                   if (pag == NOPAG) {
                        /* This is a uid based token that hadn't 
-                          previously been cleared, so decrement the
-                          outstanding uid based token count */
+                        * previously been cleared, so decrement the
+                        * outstanding uid based token count */
                        afs_GCPAGs_UIDBaseTokenCount--;
                    }
                }
@@ -621,6 +673,7 @@ void afs_GCPAGs_perproc_func(AFS_PROC *pproc)
        }
     }
 }
+#endif
 
 /*
  * Go through the process table, find all unused PAGs 
@@ -635,7 +688,8 @@ void afs_GCPAGs_perproc_func(AFS_PROC *pproc)
  * an entry in the login cache, so this routine is not needed.
  */
 
-afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount)
+afs_int32
+afs_GCPAGs(afs_int32 * ReleasedCount)
 {
     struct unixuser *pu;
     int i;
@@ -647,10 +701,10 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount)
     *ReleasedCount = 0;
 
     /* first, loop through afs_users, setting the temporary 'deleteme' flag */
-    ObtainWriteLock(&afs_xuser,419);
-    afs_GCPAGs_UIDBaseTokenCount=0;
-    for(i=0; i < NUSERS; i++) {
-       for(pu = afs_users[i]; pu; pu = pu->next) {
+    ObtainWriteLock(&afs_xuser, 419);
+    afs_GCPAGs_UIDBaseTokenCount = 0;
+    for (i = 0; i < NUSERS; i++) {
+       for (pu = afs_users[i]; pu; pu = pu->next) {
            pu->states |= TMP_UPAGNotReferenced;
            if (((pu->uid >> 24) & 0xff) != 'A') {
                /* this is a uid-based token, */
@@ -664,8 +718,8 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount)
      * for each process, mark it's PAGs (if any) in use.
      * i.e. clear the temporary deleteme flag.
      */
-    afs_GCPAGs_perproc_count=0;
-    afs_GCPAGs_cred_count=0;
+    afs_GCPAGs_perproc_count = 0;
+    afs_GCPAGs_cred_count = 0;
 
     afs_osi_TraverseProcTable();
 
@@ -685,24 +739,24 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount)
      * (temp deleteme flag still set) will be marked for later deletion,
      * by setting their expire times to 0.
      */
-    for(i=0; i < NUSERS; i++) {
-       for(pu = afs_users[i]; pu; pu = pu->next) {
-           if(pu->states & TMP_UPAGNotReferenced) {
-               
+    for (i = 0; i < NUSERS; i++) {
+       for (pu = afs_users[i]; pu; pu = pu->next) {
+           if (pu->states & TMP_UPAGNotReferenced) {
+
                /* clear the temp flag */
                pu->states &= ~TMP_UPAGNotReferenced;
-               
+
                /* Is this entry on behalf of a 'remote' user ?
                 * i.e. nfs translator, etc.
                 */
-               if(!pu->exporter && afs_gcpags == AFS_GCPAGS_OK) {
+               if (!pu->exporter && afs_gcpags == AFS_GCPAGS_OK) {
                    /* set the expire times to 0, causes 
                     * afs_GCUserData to remove this entry 
                     */
                    pu->ct.EndTimestamp = 0;
                    pu->tokenTime = 0;
-                   
-                   (*ReleasedCount)++;   /* remember how many we marked (info only) */
+
+                   (*ReleasedCount)++; /* remember how many we marked (info only) */
                }
            }
        }
@@ -713,4 +767,4 @@ afs_int32 afs_GCPAGs(afs_int32 *ReleasedCount)
     return 0;
 }
 
-#endif /* AFS_GCPAGS */
+#endif /* AFS_GCPAGS */