Unix CM: Catch ICL initialisation failures
[openafs.git] / src / afs / afs_icl.c
index 54ce04e..60520e1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #ifdef AFS_SGI62_ENV
 #include "h/hashing.h"
 #endif
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN60_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_DARWIN_ENV)
 #include "netinet/in_var.h"
 #endif
 #endif /* !defined(UKERNEL) */
-#ifdef AFS_LINUX22_ENV
-#include "h/smp_lock.h"
-#endif
 
 
 struct afs_icl_set *afs_iclSetp = (struct afs_icl_set *)0;
 struct afs_icl_set *afs_iclLongTermSetp = (struct afs_icl_set *)0;
 
-#if defined(AFS_OSF_ENV) || defined(AFS_SGI61_ENV)
-/* For SGI 6.2, this can is changed to 1 if it's a 32 bit kernel. */
-#if defined(AFS_SGI62_ENV) && defined(KERNEL) && !defined(_K64U64)
-int afs_icl_sizeofLong = 1;
-#else
-int afs_icl_sizeofLong = 2;
-#endif /* SGI62 */
-#else
-#if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
-int afs_icl_sizeofLong = 2;
+/* Matches below where ICL_APPENDLONG is 2 INT32s */
+#if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || defined(AFS_DARWIN_ENV) && defined(__amd64__)
+#define ICL_LONG 2
 #else
-int afs_icl_sizeofLong = 1;
-#endif
+#define ICL_LONG 1
 #endif
 
+int afs_icl_sizeofLong = ICL_LONG;
+
 int afs_icl_inited = 0;
 
 /* init function, called once, under afs_icl_lock */
@@ -57,6 +48,33 @@ afs_icl_Init(void)
     return 0;
 }
 
+/* Function called at shutdown - zap everything */
+void
+shutdown_icl(void)
+{
+    struct afs_icl_log *logp;
+    struct afs_icl_set *setp;
+
+    setp = afs_icl_FindSet("cm");
+    if (setp) {
+       /* Release the reference from Find, and the initial one */
+       afs_icl_SetFree(setp);
+       afs_icl_SetFree(setp);
+    }
+    setp = afs_icl_FindSet("cmlongterm");
+    if (setp) {
+       /* Release the reference from Find, and the initial one */
+       afs_icl_SetFree(setp);
+       afs_icl_SetFree(setp);
+    }
+    logp = afs_icl_FindLog("cmfx");
+    if (logp) {
+       /* Release the reference from Find, and the initial one */
+       afs_icl_LogFree(logp);
+       afs_icl_LogFree(logp);
+    }
+}
+
 int
 afs_icl_InitLogs(void)
 {
@@ -65,14 +83,17 @@ afs_icl_InitLogs(void)
 
     /* initialize the ICL system */
     code = afs_icl_CreateLog("cmfx", 60 * 1024, &logp);
-    if (code == 0)
-       code =
-           afs_icl_CreateSetWithFlags("cm", logp, NULL,
-                                      ICL_CRSET_FLAG_DEFAULT_OFF,
-                                      &afs_iclSetp);
-    code =
-       afs_icl_CreateSet("cmlongterm", logp, NULL,
-                         &afs_iclLongTermSetp);
+    if (code)
+       return code;
+
+    code = afs_icl_CreateSetWithFlags("cm", logp, NULL,
+                                     ICL_CRSET_FLAG_DEFAULT_OFF,
+                                     &afs_iclSetp);
+    if (code)
+       return code;
+
+    code = afs_icl_CreateSet("cmlongterm", logp, NULL,
+                            &afs_iclLongTermSetp);
     return code;
 }
 
@@ -105,10 +126,10 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
 #endif
 {
     afs_int32 *lp, elts, flags;
-    register afs_int32 code;
+    afs_int32 code;
     struct afs_icl_log *logp;
     struct afs_icl_set *setp;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
     size_t temp;
 #else /* AFS_SGI61_ENV */
 #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
@@ -156,12 +177,11 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
        AFS_COPYIN(AFSKPTR(p4), (char *)&startCookie, sizeof(afs_int32), code);
        if (code)
            return code;
-       afs_warn("looking for log %s\n", tname);
        logp = afs_icl_FindLog(tname);
        if (!logp)
            return ENOENT;
 #define        BUFFERSIZE      AFS_LRALLOCSIZ
-       lp = (afs_int32 *) osi_AllocLargeSpace(AFS_LRALLOCSIZ);
+       lp = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
        elts = BUFFERSIZE / sizeof(afs_int32);
        if (p3 < elts)
            elts = p3;
@@ -227,12 +247,12 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
        temp = strlen(tlp->name) + 1;
        if (temp > p4)
            return EINVAL;
-       AFS_COPYOUT(tlp->name, (char *)p3, temp, code);
+       AFS_COPYOUT(tlp->name, AFSKPTR(p3), temp, code);
        break;
 
     case ICL_OP_CLRLOG:        /* clear specified log */
        /* zero out the specified log: p1=logname */
-       AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
+       AFS_COPYINSTR(AFSKPTR(p1), tname, sizeof(tname), &temp, code);
        if (code)
            return code;
        logp = afs_icl_FindLog(tname);
@@ -244,7 +264,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
 
     case ICL_OP_CLRSET:        /* clear specified set */
        /* zero out the specified set: p1=setname */
-       AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
+       AFS_COPYINSTR(AFSKPTR(p1), tname, sizeof(tname), &temp, code);
        if (code)
            return code;
        setp = afs_icl_FindSet(tname);
@@ -286,15 +306,15 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
        temp = strlen(setp->name) + 1;
        if (temp > p3)
            return EINVAL;
-       AFS_COPYOUT(setp->name, (char *)p2, temp, code);
+       AFS_COPYOUT(setp->name, AFSKPTR(p2), temp, code);
        if (!code)              /* copy out size of log */
-           AFS_COPYOUT((char *)&setp->states, (char *)p4, sizeof(afs_int32),
+           AFS_COPYOUT((char *)&setp->states, AFSKPTR(p4), sizeof(afs_int32),
                        code);
        break;
 
     case ICL_OP_SETSTAT:       /* set status on a set */
        /* activate the specified set: p1=setname, p2=op */
-       AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
+       AFS_COPYINSTR(AFSKPTR(p1), tname, sizeof(tname), &temp, code);
        if (code)
            return code;
        setp = afs_icl_FindSet(tname);
@@ -325,7 +345,7 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
 
     case ICL_OP_SETLOGSIZE:    /* set size of log */
        /* set the size of the specified log: p1=logname, p2=size (in words) */
-       AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
+       AFS_COPYINSTR(AFSKPTR(p1), tname, sizeof(tname), &temp, code);
        if (code)
            return code;
        logp = afs_icl_FindLog(tname);
@@ -337,30 +357,30 @@ Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval)
 
     case ICL_OP_GETLOGINFO:    /* get size of log */
        /* zero out the specified log: p1=logname, p2=&logSize, p3=&allocated */
-       AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
+       AFS_COPYINSTR(AFSKPTR(p1), tname, sizeof(tname), &temp, code);
        if (code)
            return code;
        logp = afs_icl_FindLog(tname);
        if (!logp)
            return ENOENT;
        allocated = !!logp->datap;
-       AFS_COPYOUT((char *)&logp->logSize, (char *)p2, sizeof(afs_int32),
+       AFS_COPYOUT((char *)&logp->logSize, AFSKPTR(p2), sizeof(afs_int32),
                    code);
        if (!code)
-           AFS_COPYOUT((char *)&allocated, (char *)p3, sizeof(afs_int32),
+           AFS_COPYOUT((char *)&allocated, AFSKPTR(p3), sizeof(afs_int32),
                        code);
        afs_icl_LogRele(logp);
        break;
 
     case ICL_OP_GETSETINFO:    /* get state of set */
        /* zero out the specified set: p1=setname, p2=&state */
-       AFS_COPYINSTR((char *)p1, tname, sizeof(tname), &temp, code);
+       AFS_COPYINSTR(AFSKPTR(p1), tname, sizeof(tname), &temp, code);
        if (code)
            return code;
        setp = afs_icl_FindSet(tname);
        if (!setp)
            return ENOENT;
-       AFS_COPYOUT((char *)&setp->states, (char *)p2, sizeof(afs_int32),
+       AFS_COPYOUT((char *)&setp->states, AFSKPTR(p2), sizeof(afs_int32),
                    code);
        afs_icl_SetRele(setp);
        break;
@@ -377,12 +397,12 @@ afs_lock_t afs_icl_lock;
 
 /* exported routine: a 4 parameter event */
 int
-afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
+afs_icl_Event4(struct afs_icl_set *setp, afs_int32 eventID,
               afs_int32 lAndT, long p1, long p2, long p3, long p4)
 {
     afs_int32 mask;
-    register int i;
-    register afs_int32 tmask;
+    int i;
+    afs_int32 tmask;
     int ix;
 
     /* If things aren't init'ed yet (or the set is inactive), don't panic */
@@ -390,6 +410,7 @@ afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
        return 0;
 
     AFS_ASSERT_GLOCK();
+    afs_icl_SetHold(setp);
     mask = lAndT >> 24 & 0xff; /* mask of which logs to log to */
     ix = ICL_EVENTBYTE(eventID);
     ObtainReadLock(&setp->lock);
@@ -405,6 +426,7 @@ afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
        }
     }
     ReleaseReadLock(&setp->lock);
+    afs_icl_SetRele(setp);
     return 0;
 }
 
@@ -413,21 +435,21 @@ afs_icl_Event4(register struct afs_icl_set *setp, afs_int32 eventID,
  * Otherwise, could call afs_icl_Event4 directly.
  */
 int
-afs_icl_Event3(register struct afs_icl_set *setp, afs_int32 eventID,
+afs_icl_Event3(struct afs_icl_set *setp, afs_int32 eventID,
               afs_int32 lAndT, long p1, long p2, long p3)
 {
     return afs_icl_Event4(setp, eventID, lAndT, p1, p2, p3, (long)0);
 }
 
 int
-afs_icl_Event2(register struct afs_icl_set *setp, afs_int32 eventID,
+afs_icl_Event2(struct afs_icl_set *setp, afs_int32 eventID,
               afs_int32 lAndT, long p1, long p2)
 {
     return afs_icl_Event4(setp, eventID, lAndT, p1, p2, (long)0, (long)0);
 }
 
 int
-afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID,
+afs_icl_Event1(struct afs_icl_set *setp, afs_int32 eventID,
               afs_int32 lAndT, long p1)
 {
     return afs_icl_Event4(setp, eventID, lAndT, p1, (long)0, (long)0,
@@ -435,7 +457,7 @@ afs_icl_Event1(register struct afs_icl_set *setp, afs_int32 eventID,
 }
 
 int
-afs_icl_Event0(register struct afs_icl_set *setp, afs_int32 eventID,
+afs_icl_Event0(struct afs_icl_set *setp, afs_int32 eventID,
               afs_int32 lAndT)
 {
     return afs_icl_Event4(setp, eventID, lAndT, (long)0, (long)0, (long)0,
@@ -451,9 +473,9 @@ struct afs_icl_log *afs_icl_allLogs = 0;
  * Log must be write-locked.
  */
 static void
-afs_icl_GetLogSpace(register struct afs_icl_log *logp, afs_int32 minSpace)
+afs_icl_GetLogSpace(struct afs_icl_log *logp, afs_int32 minSpace)
 {
-    register unsigned int tsize;
+    unsigned int tsize;
 
     while (logp->logSize - logp->logElements <= minSpace) {
        /* eat a record */
@@ -476,7 +498,7 @@ afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
 {
     char *op;                  /* ptr to char to write */
     int tc;
-    register int bib;          /* bytes in buffer */
+    int bib;           /* bytes in buffer */
 
     bib = 0;
     op = (char *)&(logp->datap[logp->firstFree]);
@@ -514,16 +536,16 @@ afs_icl_AppendString(struct afs_icl_log *logp, char *astr)
         (lp)->logElements++; \
     MACRO_END
 
-#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if ICL_LONG == 2
 #define ICL_APPENDLONG(lp, x) \
     MACRO_BEGIN \
        ICL_APPENDINT32((lp), ((x) >> 32) & 0xffffffffL); \
        ICL_APPENDINT32((lp), (x) & 0xffffffffL); \
     MACRO_END
 
-#else /* AFS_OSF_ENV */
+#else
 #define ICL_APPENDLONG(lp, x) ICL_APPENDINT32((lp), (x))
-#endif /* AFS_OSF_ENV */
+#endif
 
 /* routine to tell whether we're dealing with the address or the
  * object itself
@@ -538,17 +560,62 @@ afs_icl_UseAddr(int type)
        return 0;
 }
 
+void
+afs_icl_AppendOne(struct afs_icl_log *logp, int type, long parm)
+{
+    if (type) {
+       /* marshall parameter 3 now */
+       if (type == ICL_TYPE_STRING)
+           afs_icl_AppendString(logp, (char *)parm);
+       else if (type == ICL_TYPE_HYPER) {
+           ICL_APPENDINT32(logp,
+                           (afs_int32) ((struct afs_hyper_t *)parm)->high);
+           ICL_APPENDINT32(logp,
+                           (afs_int32) ((struct afs_hyper_t *)parm)->low);
+       } else if (type == ICL_TYPE_INT64) {
+#ifndef WORDS_BIGENDIAN
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[1]);
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[0]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) parm);
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+#endif /* AFS_64BIT_CLIENT */
+#else /* AFSLITTLE_ENDIAN */
+#ifdef AFS_64BIT_CLIENT
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[0]);
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[1]);
+#else /* AFS_64BIT_CLIENT */
+           ICL_APPENDINT32(logp, (afs_int32) 0);
+           ICL_APPENDINT32(logp, (afs_int32) parm);
+#endif /* AFS_64BIT_CLIENT */
+#endif /* AFSLITTLE_ENDIAN */
+       } else if (type == ICL_TYPE_FID) {
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[0]);
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[1]);
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[2]);
+           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) parm)[3]);
+       }
+#if ICL_LONG == 2
+       else if (type == ICL_TYPE_INT32)
+           ICL_APPENDINT32(logp, (afs_int32) parm);
+#endif
+       else
+           ICL_APPENDLONG(logp, parm);
+    }
+}
+
 /* Function to append a record to the log.  Written for speed
  * since we know that we're going to have to make this work fast
  * pretty soon, anyway.  The log must be unlocked.
  */
 
 void
-afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
+afs_icl_AppendRecord(struct afs_icl_log *logp, afs_int32 op,
                     afs_int32 types, long p1, long p2, long p3, long p4)
 {
     int rsize;                 /* record size in longs */
-    register int tsize;                /* temp size */
+    int tsize;         /* temp size */
     osi_timeval_t tv;
     int t1, t2, t3, t4;
 
@@ -588,30 +655,30 @@ afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
        logp->lastTS = tv.tv_sec;
     }
 
-    rsize = 4;                 /* base case */
+    rsize = 4;                 /* base case: see 4 items below */
     if (t1) {
        /* compute size of parameter p1.  Only tricky case is string.
         * In that case, we have to call strlen to get the string length.
         */
-       ICL_SIZEHACK(t1, p1);
+       ICL_SIZEHACK(t1, p1, tsize, rsize);
     }
     if (t2) {
        /* compute size of parameter p2.  Only tricky case is string.
         * In that case, we have to call strlen to get the string length.
         */
-       ICL_SIZEHACK(t2, p2);
+       ICL_SIZEHACK(t2, p2, tsize, rsize);
     }
     if (t3) {
        /* compute size of parameter p3.  Only tricky case is string.
         * In that case, we have to call strlen to get the string length.
         */
-       ICL_SIZEHACK(t3, p3);
+       ICL_SIZEHACK(t3, p3, tsize, rsize);
     }
     if (t4) {
        /* compute size of parameter p4.  Only tricky case is string.
         * In that case, we have to call strlen to get the string length.
         */
-       ICL_SIZEHACK(t4, p4);
+       ICL_SIZEHACK(t4, p4, tsize, rsize);
     }
 
     /* At this point, we've computed all of the parameter sizes, and
@@ -635,166 +702,10 @@ afs_icl_AppendRecord(register struct afs_icl_log *logp, afs_int32 op,
     ICL_APPENDINT32(logp,
                    (afs_int32) (tv.tv_sec & 0x3ff) * 1000000 + tv.tv_usec);
 
-    if (t1) {
-       /* marshall parameter 1 now */
-       if (t1 == ICL_TYPE_STRING) {
-           afs_icl_AppendString(logp, (char *)p1);
-       } else if (t1 == ICL_TYPE_HYPER) {
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p1)->high);
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p1)->low);
-       } else if (t1 == ICL_TYPE_INT64) {
-#ifndef WORDS_BIGENDIAN
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) p1);
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-#endif /* AFS_64BIT_CLIENT */
-#else /* AFSLITTLE_ENDIAN */
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-           ICL_APPENDINT32(logp, (afs_int32) p1);
-#endif /* AFS_64BIT_CLIENT */
-#endif /* AFSLITTLE_ENDIAN */
-       } else if (t1 == ICL_TYPE_FID) {
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[2]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p1)[3]);
-       }
-#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
-       else if (t1 == ICL_TYPE_INT32)
-           ICL_APPENDINT32(logp, (afs_int32) p1);
-#endif /* AFS_OSF_ENV */
-       else
-           ICL_APPENDLONG(logp, p1);
-    }
-    if (t2) {
-       /* marshall parameter 2 now */
-       if (t2 == ICL_TYPE_STRING)
-           afs_icl_AppendString(logp, (char *)p2);
-       else if (t2 == ICL_TYPE_HYPER) {
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p2)->high);
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p2)->low);
-       } else if (t2 == ICL_TYPE_INT64) {
-#ifndef WORDS_BIGENDIAN
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) p2);
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-#endif /* AFS_64BIT_CLIENT */
-#else /* AFSLITTLE_ENDIAN */
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-           ICL_APPENDINT32(logp, (afs_int32) p2);
-#endif /* AFS_64BIT_CLIENT */
-#endif /* AFSLITTLE_ENDIAN */
-       } else if (t2 == ICL_TYPE_FID) {
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[2]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p2)[3]);
-       }
-#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
-       else if (t2 == ICL_TYPE_INT32)
-           ICL_APPENDINT32(logp, (afs_int32) p2);
-#endif /* AFS_OSF_ENV */
-       else
-           ICL_APPENDLONG(logp, p2);
-    }
-    if (t3) {
-       /* marshall parameter 3 now */
-       if (t3 == ICL_TYPE_STRING)
-           afs_icl_AppendString(logp, (char *)p3);
-       else if (t3 == ICL_TYPE_HYPER) {
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p3)->high);
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p3)->low);
-       } else if (t3 == ICL_TYPE_INT64) {
-#ifndef WORDS_BIGENDIAN
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) p3);
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-#endif /* AFS_64BIT_CLIENT */
-#else /* AFSLITTLE_ENDIAN */
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-           ICL_APPENDINT32(logp, (afs_int32) p3);
-#endif /* AFS_64BIT_CLIENT */
-#endif /* AFSLITTLE_ENDIAN */
-       } else if (t3 == ICL_TYPE_FID) {
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[2]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p3)[3]);
-       }
-#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
-       else if (t3 == ICL_TYPE_INT32)
-           ICL_APPENDINT32(logp, (afs_int32) p3);
-#endif /* AFS_OSF_ENV */
-       else
-           ICL_APPENDLONG(logp, p3);
-    }
-    if (t4) {
-       /* marshall parameter 4 now */
-       if (t4 == ICL_TYPE_STRING)
-           afs_icl_AppendString(logp, (char *)p4);
-       else if (t4 == ICL_TYPE_HYPER) {
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p4)->high);
-           ICL_APPENDINT32(logp,
-                           (afs_int32) ((struct afs_hyper_t *)p4)->low);
-       } else if (t4 == ICL_TYPE_INT64) {
-#ifndef WORDS_BIGENDIAN
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) p4);
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-#endif /* AFS_64BIT_CLIENT */
-#else /* AFSLITTLE_ENDIAN */
-#ifdef AFS_64BIT_CLIENT
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
-#else /* AFS_64BIT_CLIENT */
-           ICL_APPENDINT32(logp, (afs_int32) 0);
-           ICL_APPENDINT32(logp, (afs_int32) p4);
-#endif /* AFS_64BIT_CLIENT */
-#endif /* AFSLITTLE_ENDIAN */
-       } else if (t4 == ICL_TYPE_FID) {
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[0]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[1]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[2]);
-           ICL_APPENDINT32(logp, (afs_int32) ((afs_int32 *) p4)[3]);
-       }
-#if defined(AFS_OSF_ENV) || (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
-       else if (t4 == ICL_TYPE_INT32)
-           ICL_APPENDINT32(logp, (afs_int32) p4);
-#endif /* AFS_OSF_ENV */
-       else
-           ICL_APPENDLONG(logp, p4);
-    }
+    afs_icl_AppendOne(logp, t1, p1);
+    afs_icl_AppendOne(logp, t2, p2);
+    afs_icl_AppendOne(logp, t3, p3);
+    afs_icl_AppendOne(logp, t4, p4);
     ReleaseWriteLock(&logp->lock);
 }
 
@@ -815,7 +726,7 @@ int
 afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
                           struct afs_icl_log **outLogpp)
 {
-    register struct afs_icl_log *logp;
+    struct afs_icl_log *logp;
 
     /* add into global list under lock */
     ObtainWriteLock(&afs_icl_lock, 183);
@@ -837,8 +748,7 @@ afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
        }
     }
 
-    logp = (struct afs_icl_log *)
-       osi_AllocSmallSpace(sizeof(struct afs_icl_log));
+    logp = osi_AllocSmallSpace(sizeof(struct afs_icl_log));
     memset((caddr_t) logp, 0, sizeof(*logp));
 
     logp->refCount = 1;
@@ -866,7 +776,7 @@ afs_icl_CreateLogWithFlags(char *name, afs_int32 logSize, afs_uint32 flags,
  * find the record with cookie value cookie.
  */
 int
-afs_icl_CopyOut(register struct afs_icl_log *logp, afs_int32 * bufferp,
+afs_icl_CopyOut(struct afs_icl_log *logp, afs_int32 * bufferp,
                afs_int32 * bufSizep, afs_uint32 * cookiep,
                afs_int32 * flagsp)
 {
@@ -996,7 +906,7 @@ afs_icl_GetLogParms(struct afs_icl_log *logp, afs_int32 * maxSizep,
 
 /* hold and release logs */
 int
-afs_icl_LogHold(register struct afs_icl_log *logp)
+afs_icl_LogHold(struct afs_icl_log *logp)
 {
     ObtainWriteLock(&afs_icl_lock, 187);
     logp->refCount++;
@@ -1006,7 +916,7 @@ afs_icl_LogHold(register struct afs_icl_log *logp)
 
 /* hold and release logs, called with lock already held */
 int
-afs_icl_LogHoldNL(register struct afs_icl_log *logp)
+afs_icl_LogHoldNL(struct afs_icl_log *logp)
 {
     logp->refCount++;
     return 0;
@@ -1014,7 +924,7 @@ afs_icl_LogHoldNL(register struct afs_icl_log *logp)
 
 /* keep track of how many sets believe the log itself is allocated */
 int
-afs_icl_LogUse(register struct afs_icl_log *logp)
+afs_icl_LogUse(struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock, 188);
     if (logp->setCount == 0) {
@@ -1023,8 +933,8 @@ afs_icl_LogUse(register struct afs_icl_log *logp)
            /* we weren't passed in a hint and it wasn't set */
            logp->logSize = ICL_DEFAULT_LOGSIZE;
        }
-       logp->datap =
-           (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
+       logp->datap = afs_osi_Alloc(sizeof(afs_int32) * logp->logSize);
+       osi_Assert(logp->datap != NULL);
 #ifdef KERNEL_HAVE_PIN
        pin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
@@ -1036,7 +946,7 @@ afs_icl_LogUse(register struct afs_icl_log *logp)
 
 /* decrement the number of real users of the log, free if possible */
 int
-afs_icl_LogFreeUse(register struct afs_icl_log *logp)
+afs_icl_LogFreeUse(struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock, 189);
     if (--logp->setCount == 0) {
@@ -1055,7 +965,7 @@ afs_icl_LogFreeUse(register struct afs_icl_log *logp)
 
 /* set the size of the log to 'logSize' */
 int
-afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
+afs_icl_LogSetSize(struct afs_icl_log *logp, afs_int32 logSize)
 {
     ObtainWriteLock(&logp->lock, 190);
     if (!logp->datap) {
@@ -1071,8 +981,8 @@ afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
 #ifdef KERNEL_HAVE_PIN
        unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
 #endif
-       logp->datap =
-           (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
+       logp->datap = afs_osi_Alloc(sizeof(afs_int32) * logSize);
+       osi_Assert(logp->datap != NULL);
 #ifdef KERNEL_HAVE_PIN
        pin((char *)logp->datap, sizeof(afs_int32) * logSize);
 #endif
@@ -1085,9 +995,9 @@ afs_icl_LogSetSize(register struct afs_icl_log *logp, afs_int32 logSize)
 
 /* free a log.  Called with afs_icl_lock locked. */
 int
-afs_icl_ZapLog(register struct afs_icl_log *logp)
+afs_icl_ZapLog(struct afs_icl_log *logp)
 {
-    register struct afs_icl_log **lpp, *tp;
+    struct afs_icl_log **lpp, *tp;
 
     for (lpp = &afs_icl_allLogs, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
        if (tp == logp) {
@@ -1107,7 +1017,7 @@ afs_icl_ZapLog(register struct afs_icl_log *logp)
 
 /* do the release, watching for deleted entries */
 int
-afs_icl_LogRele(register struct afs_icl_log *logp)
+afs_icl_LogRele(struct afs_icl_log *logp)
 {
     ObtainWriteLock(&afs_icl_lock, 191);
     if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
@@ -1119,7 +1029,7 @@ afs_icl_LogRele(register struct afs_icl_log *logp)
 
 /* do the release, watching for deleted entries, log already held */
 int
-afs_icl_LogReleNL(register struct afs_icl_log *logp)
+afs_icl_LogReleNL(struct afs_icl_log *logp)
 {
     if (--logp->refCount == 0 && (logp->states & ICL_LOGF_DELETED)) {
        afs_icl_ZapLog(logp);   /* destroys logp's lock! */
@@ -1129,7 +1039,7 @@ afs_icl_LogReleNL(register struct afs_icl_log *logp)
 
 /* zero out the log */
 int
-afs_icl_ZeroLog(register struct afs_icl_log *logp)
+afs_icl_ZeroLog(struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock, 192);
     logp->firstUsed = logp->firstFree = 0;
@@ -1141,7 +1051,7 @@ afs_icl_ZeroLog(register struct afs_icl_log *logp)
 
 /* free a log entry, and drop its reference count */
 int
-afs_icl_LogFree(register struct afs_icl_log *logp)
+afs_icl_LogFree(struct afs_icl_log *logp)
 {
     ObtainWriteLock(&logp->lock, 193);
     logp->states |= ICL_LOGF_DELETED;
@@ -1154,7 +1064,7 @@ afs_icl_LogFree(register struct afs_icl_log *logp)
 struct afs_icl_log *
 afs_icl_FindLog(char *name)
 {
-    register struct afs_icl_log *tp;
+    struct afs_icl_log *tp;
     ObtainWriteLock(&afs_icl_lock, 194);
     for (tp = afs_icl_allLogs; tp; tp = tp->nextp) {
        if (strcmp(tp->name, name) == 0) {
@@ -1172,8 +1082,8 @@ afs_icl_EnumerateLogs(int (*aproc)
                        (char *name, char *arock, struct afs_icl_log * tp),
                      char *arock)
 {
-    register struct afs_icl_log *tp;
-    register afs_int32 code;
+    struct afs_icl_log *tp;
+    afs_int32 code;
 
     code = 0;
     ObtainWriteLock(&afs_icl_lock, 195);
@@ -1215,8 +1125,8 @@ afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
                           struct afs_icl_log *fatalLogp, afs_uint32 flags,
                           struct afs_icl_set **outSetpp)
 {
-    register struct afs_icl_set *setp;
-    register int i;
+    struct afs_icl_set *setp;
+    int i;
     afs_int32 states = ICL_DEFAULT_SET_STATES;
 
     ObtainWriteLock(&afs_icl_lock, 197);
@@ -1245,7 +1155,7 @@ afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
     if (flags & ICL_CRSET_FLAG_PERSISTENT)
        states |= ICL_SETF_PERSISTENT;
 
-    setp = (struct afs_icl_set *)afs_osi_Alloc(sizeof(struct afs_icl_set));
+    setp = osi_AllocSmallSpace(sizeof(struct afs_icl_set));
     memset((caddr_t) setp, 0, sizeof(*setp));
     setp->refCount = 1;
     if (states & ICL_SETF_FREED)
@@ -1262,6 +1172,7 @@ afs_icl_CreateSetWithFlags(char *name, struct afs_icl_log *baseLogp,
     strcpy(setp->name, name);
     setp->nevents = ICL_DEFAULTEVENTS;
     setp->eventFlags = afs_osi_Alloc(ICL_DEFAULTEVENTS);
+    osi_Assert(setp->eventFlags != NULL);
 #ifdef KERNEL_HAVE_PIN
     pin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
 #endif
@@ -1334,7 +1245,7 @@ afs_icl_GetEnable(struct afs_icl_set *setp, afs_int32 eventID, int *getValuep)
 
 /* hold and release event sets */
 int
-afs_icl_SetHold(register struct afs_icl_set *setp)
+afs_icl_SetHold(struct afs_icl_set *setp)
 {
     ObtainWriteLock(&afs_icl_lock, 201);
     setp->refCount++;
@@ -1344,11 +1255,11 @@ afs_icl_SetHold(register struct afs_icl_set *setp)
 
 /* free a set.  Called with afs_icl_lock locked */
 int
-afs_icl_ZapSet(register struct afs_icl_set *setp)
+afs_icl_ZapSet(struct afs_icl_set *setp)
 {
-    register struct afs_icl_set **lpp, *tp;
+    struct afs_icl_set **lpp, *tp;
     int i;
-    register struct afs_icl_log *tlp;
+    struct afs_icl_log *tlp;
 
     for (lpp = &afs_icl_allSets, tp = *lpp; tp; lpp = &tp->nextp, tp = *lpp) {
        if (tp == setp) {
@@ -1372,7 +1283,7 @@ afs_icl_ZapSet(register struct afs_icl_set *setp)
 
 /* do the release, watching for deleted entries */
 int
-afs_icl_SetRele(register struct afs_icl_set *setp)
+afs_icl_SetRele(struct afs_icl_set *setp)
 {
     ObtainWriteLock(&afs_icl_lock, 202);
     if (--setp->refCount == 0 && (setp->states & ICL_SETF_DELETED)) {
@@ -1384,7 +1295,7 @@ afs_icl_SetRele(register struct afs_icl_set *setp)
 
 /* free a set entry, dropping its reference count */
 int
-afs_icl_SetFree(register struct afs_icl_set *setp)
+afs_icl_SetFree(struct afs_icl_set *setp)
 {
     ObtainWriteLock(&setp->lock, 203);
     setp->states |= ICL_SETF_DELETED;
@@ -1397,7 +1308,7 @@ afs_icl_SetFree(register struct afs_icl_set *setp)
 struct afs_icl_set *
 afs_icl_FindSet(char *name)
 {
-    register struct afs_icl_set *tp;
+    struct afs_icl_set *tp;
     ObtainWriteLock(&afs_icl_lock, 204);
     for (tp = afs_icl_allSets; tp; tp = tp->nextp) {
        if (strcmp(tp->name, name) == 0) {
@@ -1414,7 +1325,7 @@ afs_icl_FindSet(char *name)
 int
 afs_icl_ZeroSet(struct afs_icl_set *setp)
 {
-    register int i;
+    int i;
     int code = 0;
     int tcode;
     struct afs_icl_log *logp;
@@ -1439,8 +1350,8 @@ afs_icl_EnumerateSets(int (*aproc)
                        (char *name, char *arock, struct afs_icl_log * tp),
                      char *arock)
 {
-    register struct afs_icl_set *tp, *np;
-    register afs_int32 code;
+    struct afs_icl_set *tp, *np;
+    afs_int32 code;
 
     code = 0;
     ObtainWriteLock(&afs_icl_lock, 205);
@@ -1462,7 +1373,7 @@ afs_icl_EnumerateSets(int (*aproc)
 int
 afs_icl_AddLogToSet(struct afs_icl_set *setp, struct afs_icl_log *newlogp)
 {
-    register int i;
+    int i;
     int code = -1;
 
     ObtainWriteLock(&setp->lock, 207);
@@ -1522,7 +1433,7 @@ afs_icl_SetSetStat(struct afs_icl_set *setp, int op)
        break;
 
     case ICL_OP_SS_FREE:       /* deassert design for log */
-       /* 
+       /*
         * if we are already in this state, do nothing; otherwise
         * deassert desire for log
         */