From 771f8f764cf472fba73b2abfd594e7e9f0171963 Mon Sep 17 00:00:00 2001 From: Nickolai Zeldovich Date: Wed, 25 Aug 2004 08:09:32 +0000 Subject: [PATCH] STABLE14-fix-indent-bug-with-lock-macros-part-three-20040818 Add trailing semicolons to more macros and re-indent. (cherry picked from commit 06478aeaae1e7812230f31c63e9cae8b7cc1b643) --- src/afs/IRIX/osi_idbg.c | 4 +- src/afs/IRIX/osi_machdep.h | 6 +- src/afs/IRIX/osi_vfsops.c | 20 +- src/afs/IRIX/osi_vnodeops.c | 32 +-- src/afs/UKERNEL/osi_vfsops.c | 4 +- src/afs/VNOPS/afs_vnop_access.c | 8 +- src/afs/VNOPS/afs_vnop_attrs.c | 20 +- src/afs/VNOPS/afs_vnop_create.c | 5 +- src/afs/VNOPS/afs_vnop_dirops.c | 14 +- src/afs/VNOPS/afs_vnop_fid.c | 6 +- src/afs/VNOPS/afs_vnop_flock.c | 6 +- src/afs/VNOPS/afs_vnop_link.c | 7 +- src/afs/VNOPS/afs_vnop_lookup.c | 133 +++++------ src/afs/VNOPS/afs_vnop_readdir.c | 18 +- src/afs/VNOPS/afs_vnop_remove.c | 28 +-- src/afs/VNOPS/afs_vnop_rename.c | 11 +- src/afs/VNOPS/afs_vnop_symlink.c | 8 +- src/afs/VNOPS/afs_vnop_write.c | 10 +- src/afs/afs_dcache.c | 4 +- src/afs/afs_segments.c | 6 +- src/afs/afs_vcache.c | 146 ++++++------ src/auth/authcon.c | 21 +- src/auth/cellconfig.c | 264 ++++++++++++--------- src/auth/ktc.c | 125 ++++++---- src/auth/ktc_nt.c | 236 +++++++++---------- src/auth/userok.c | 88 ++++--- src/auth/writeconfig.c | 27 ++- src/comerr/error_msg.c | 33 +-- src/des/des.c | 31 +-- src/des/key_sched.c | 7 +- src/des/new_rnd_key.c | 45 ++-- src/des/stats.h | 4 +- src/kauth/authclient.c | 165 ++++++++----- src/kauth/client.c | 29 ++- src/kauth/kadatabase.c | 11 +- src/kauth/kalocalcell.c | 41 ++-- src/kauth/kaprocs.c | 6 +- src/kauth/kpasswd.c | 8 +- src/kauth/prot.h | 8 +- src/kauth/token.c | 104 ++++++--- src/kauth/user.c | 2 +- src/kauth/user_nt.c | 2 +- src/libadmin/adminutil/afs_utilAdmin.c | 6 +- src/libadmin/client/afs_clientAdmin.c | 7 +- src/lwp/lock.h | 52 ++--- src/rx/rx.c | 78 ++++--- src/rx/rx_clock_nt.c | 4 +- src/rx/rx_conncache.c | 26 ++- src/rx/rx_event.c | 22 +- src/rx/rx_kcommon.c | 17 +- src/rx/rx_misc.c | 16 +- src/rx/rx_packet.c | 9 +- src/rx/rx_pthread.c | 2 +- src/rx/rx_user.c | 77 ++++--- src/rx/rx_user.h | 4 +- src/rx/rx_xmit_nt.c | 18 +- src/rx/rxdebug.c | 2 +- src/rx/xdr_int64.c | 8 +- src/rxkad/bg-fcrypt.c | 28 ++- src/rxkad/hash.h | 2 +- src/rxkad/md4.c | 238 +++++++++---------- src/rxkad/md4.h | 12 +- src/rxkad/md5.c | 306 ++++++++++++------------- src/rxkad/md5.h | 12 +- src/rxkad/rxkad.p.h | 12 +- src/rxkad/rxkad_client.c | 31 ++- src/rxkad/rxkad_common.c | 102 +++++---- src/rxkad/rxkad_prototypes.h | 30 ++- src/rxkad/rxkad_server.c | 44 ++-- src/rxkad/ticket5.c | 42 ++-- src/ubik/beacon.c | 4 +- src/ubik/remote.c | 2 +- src/ubik/ubik.p.h | 7 +- src/ubik/ubikclient.c | 71 +++--- src/util/pthread_glock.h | 4 +- 75 files changed, 1706 insertions(+), 1342 deletions(-) diff --git a/src/afs/IRIX/osi_idbg.c b/src/afs/IRIX/osi_idbg.c index 126d674212..03f0ed767c 100644 --- a/src/afs/IRIX/osi_idbg.c +++ b/src/afs/IRIX/osi_idbg.c @@ -55,9 +55,9 @@ char *tab_vcache[] = { int idbg_prafsnode(OSI_VC_DECL(avc)) { - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - AFS_GLOCK(); + AFS_GLOCK(); qprintf(" Len %d DV %d Date %d Own %d Grp %d Mode 0%o Lnk %d\n", avc->m.Length, avc->m.DataVersion, avc->m.Date, avc->m.Owner, avc->m.Group, avc->m.Mode, avc->m.LinkCount); diff --git a/src/afs/IRIX/osi_machdep.h b/src/afs/IRIX/osi_machdep.h index c17eeb1585..c069b3617a 100644 --- a/src/afs/IRIX/osi_machdep.h +++ b/src/afs/IRIX/osi_machdep.h @@ -374,19 +374,19 @@ extern long afs_global_owner; #undef OSI_VN_DECL #define OSI_VN_DECL(V) bhv_desc_t *bhv_##V #undef OSI_VN_CONVERT -#define OSI_VN_CONVERT(V) struct vnode * V = (struct vnode*)BHV_TO_VNODE(bhv_##V); +#define OSI_VN_CONVERT(V) struct vnode * V = (struct vnode*)BHV_TO_VNODE(bhv_##V) #undef OSI_VC_ARG #define OSI_VC_ARG(V) bhv_##V #undef OSI_VC_DECL #define OSI_VC_DECL(V) bhv_desc_t *bhv_##V #undef OSI_VC_CONVERT -#define OSI_VC_CONVERT(V) struct vcache * V = VTOAFS(BHV_TO_VNODE(bhv_##V)); +#define OSI_VC_CONVERT(V) struct vcache * V = VTOAFS(BHV_TO_VNODE(bhv_##V)) #undef OSI_VFS_ARG #define OSI_VFS_ARG(V) bhv_##V #undef OSI_VFS_DECL #define OSI_VFS_DECL(V) bhv_desc_t *bhv_##V #undef OSI_VFS_CONVERT -#define OSI_VFS_CONVERT(V) struct vfs * V = (struct vfs*)bhvtovfs(bhv_##V); +#define OSI_VFS_CONVERT(V) struct vfs * V = (struct vfs*)bhvtovfs(bhv_##V) #endif /* AFS_SGI64_ENV */ diff --git a/src/afs/IRIX/osi_vfsops.c b/src/afs/IRIX/osi_vfsops.c index 6ddae6609b..c1e29ebd6d 100644 --- a/src/afs/IRIX/osi_vfsops.c +++ b/src/afs/IRIX/osi_vfsops.c @@ -213,9 +213,9 @@ afs_unmount(OSI_VFS_ARG(afsp), flags, cr) register struct afs_q *tq; struct afs_q *uq; int error, fv_slept; - OSI_VFS_CONVERT(afsp) + OSI_VFS_CONVERT(afsp); - AFS_STATCNT(afs_unmount); + AFS_STATCNT(afs_unmount); if (!suser()) return EPERM; @@ -272,9 +272,9 @@ afs_root(OSI_VFS_ARG(afsp), avpp) register afs_int32 code = 0; struct vrequest treq; register struct vcache *tvp = 0; - OSI_VFS_CONVERT(afsp) + OSI_VFS_CONVERT(afsp); - AFS_STATCNT(afs_root); + AFS_STATCNT(afs_root); if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { @@ -314,9 +314,9 @@ afs_statfs(OSI_VFS_ARG(afsp), abp, avp) struct statvfs *abp; struct vnode *avp; /* unused */ { - OSI_VFS_CONVERT(afsp) + OSI_VFS_CONVERT(afsp); - AFS_STATCNT(afs_statfs); + AFS_STATCNT(afs_statfs); abp->f_bsize = afsp->vfs_bsize; abp->f_frsize = afsp->vfs_bsize; /* Fake a high number below to satisfy programs that use the statfs @@ -379,9 +379,9 @@ afs_sync(OSI_VFS_DECL(afsp), register struct afs_q *tq; struct afs_q *uq; int s; - OSI_VFS_CONVERT(afsp) + OSI_VFS_CONVERT(afsp); - error = lasterr = 0; + error = lasterr = 0; /* * if not interested in vnodes, skip all this */ @@ -528,9 +528,9 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t ** avcp, struct fid * fidp) afs_fid2_t *afid2; #endif - OSI_VFS_CONVERT(afsp) + OSI_VFS_CONVERT(afsp); - AFS_STATCNT(afs_vget); + AFS_STATCNT(afs_vget); *avcp = NULL; diff --git a/src/afs/IRIX/osi_vnodeops.c b/src/afs/IRIX/osi_vnodeops.c index d7722bf141..f5cc4d96a9 100644 --- a/src/afs/IRIX/osi_vnodeops.c +++ b/src/afs/IRIX/osi_vnodeops.c @@ -158,7 +158,7 @@ afs_frlock(OSI_VN_DECL(vp), int cmd, struct flock *lfp, int flag, cred_t * cr) { int error; - OSI_VN_CONVERT(vp) + OSI_VN_CONVERT(vp); #ifdef AFS_SGI65_ENV struct flid flid; int pid; @@ -276,9 +276,9 @@ OSI_VC_DECL(avc); struct cred *cr; { int code; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - osi_Assert(avc->v.v_count > 0); + osi_Assert(avc->v.v_count > 0); if (avc->v.v_type != VREG) return EISDIR; @@ -313,9 +313,9 @@ OSI_VC_DECL(avc); struct cred *cr; { int code; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - osi_Assert(avc->v.v_count > 0); + osi_Assert(avc->v.v_count > 0); if (avc->v.v_type != VREG) return EISDIR; @@ -712,9 +712,9 @@ OSI_VC_DECL(avc); int bsize; /* server's block size in bytes */ off_t off; size_t rem, cnt; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - bsize = AFSBSIZE; + bsize = AFSBSIZE; off = offset % bsize; /* offset into block */ bmv->bn = BTOBBT(offset - off); bmv->offset = bmv->bn; @@ -765,7 +765,7 @@ OSI_VC_DECL(avc); iovec_t aiovec; int error; struct cred *cr; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); vnode_t *vp = (vnode_t *) avc; /* @@ -892,7 +892,7 @@ OSI_VC_DECL(avc); u_int flags; struct cred *cr; { - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); struct vnode *vp = AFSTOV(avc); if (vp->v_flag & VNOMAP) @@ -923,7 +923,7 @@ OSI_VC_DECL(avc); u_int flags; struct cred *acred; { - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); struct vnode *vp = AFSTOV(avc); register struct brequest *tb; struct vrequest treq; @@ -1019,7 +1019,7 @@ OSI_VC_DECL(avc); struct cred *cr; #endif { - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); struct vnode *vp = AFSTOV(avc); struct vrequest treq; int error; @@ -1077,7 +1077,7 @@ OSI_VC_DECL(avc); struct ucred *acred; { int s; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); vnode_t *vp = (vnode_t *) avc; int mapcnt = avc->mapcnt; /* We just clear off this many. */ @@ -1217,7 +1217,7 @@ afs_reclaim(OSI_VC_DECL(avc), int flag) void afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) { - OSI_VN_CONVERT(vp) + OSI_VN_CONVERT(vp); struct vcache *avc = VTOAFS(vp); if (OSI_GET_LOCKID() == avc->vc_rwlockid) { @@ -1233,7 +1233,7 @@ afs_rwlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) void afs_rwunlock(OSI_VN_DECL(vp), AFS_RWLOCK_T flag) { - OSI_VN_CONVERT(vp) + OSI_VN_CONVERT(vp); struct vcache *avc = VTOAFS(vp); AFS_ASSERT_GLOCK(); @@ -1275,9 +1275,9 @@ afs_fid2(OSI_VC_DECL(avc), struct fid *fidp) { struct cell *tcell; afs_fid2_t *afid = (afs_fid2_t *) fidp; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - osi_Assert(sizeof(fid_t) >= sizeof(afs_fid2_t)); + osi_Assert(sizeof(fid_t) >= sizeof(afs_fid2_t)); afid->af_len = sizeof(afs_fid2_t) - sizeof(afid->af_len); tcell = afs_GetCell(avc->fid.Cell, READ_LOCK); diff --git a/src/afs/UKERNEL/osi_vfsops.c b/src/afs/UKERNEL/osi_vfsops.c index 7a89f9b430..b9e95e93c2 100644 --- a/src/afs/UKERNEL/osi_vfsops.c +++ b/src/afs/UKERNEL/osi_vfsops.c @@ -75,9 +75,9 @@ afs_root(OSI_VFS_ARG(afsp), avpp) register afs_int32 code = 0; struct vrequest treq; register struct vcache *tvp = 0; - OSI_VFS_CONVERT(afsp) + OSI_VFS_CONVERT(afsp); - AFS_STATCNT(afs_root); + AFS_STATCNT(afs_root); if (afs_globalVp && (afs_globalVp->states & CStatd)) { tvp = afs_globalVp; } else { diff --git a/src/afs/VNOPS/afs_vnop_access.c b/src/afs/VNOPS/afs_vnop_access.c index afd6c9c644..e21d757a93 100644 --- a/src/afs/VNOPS/afs_vnop_access.c +++ b/src/afs/VNOPS/afs_vnop_access.c @@ -189,9 +189,9 @@ afs_access(OSI_VC_DECL(avc), register afs_int32 amode, register afs_int32 code; struct vrequest treq; struct afs_fakestat_state fakestate; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - AFS_STATCNT(afs_access); + AFS_STATCNT(afs_access); afs_Trace3(afs_iclSetp, CM_TRACE_ACCESS, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, amode, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); @@ -314,9 +314,9 @@ afs_getRights(OSI_VC_DECL(avc), register afs_int32 arights, { register afs_int32 code; struct vrequest treq; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - if (code = afs_InitReq(&treq, acred)) + if (code = afs_InitReq(&treq, acred)) return code; code = afs_VerifyVCache(avc, &treq); diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c index c669955b24..f027618e1c 100644 --- a/src/afs/VNOPS/afs_vnop_attrs.c +++ b/src/afs/VNOPS/afs_vnop_attrs.c @@ -71,7 +71,7 @@ afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) } #if defined(AFS_DARWIN_ENV) { - extern u_int32_t afs_darwin_realmodes; + extern u_int32_t afs_darwin_realmodes; if (!afs_darwin_realmodes) { /* Mac OS X uses the mode bits to determine whether a file or * directory is accessible, and believes them, even though under @@ -80,13 +80,13 @@ afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) * conservatively. */ if (S_ISDIR(attrs->va_mode)) { - /* all access bits need to be set for directories, since even + /* all access bits need to be set for directories, since even * a mode 0 directory can still be used normally. */ - attrs->va_mode |= ACCESSPERMS; + attrs->va_mode |= ACCESSPERMS; } else { - /* for other files, replicate the user bits to group and other */ - mode_t ubits = (attrs->va_mode & S_IRWXU) >> 6; + /* for other files, replicate the user bits to group and other */ + mode_t ubits = (attrs->va_mode & S_IRWXU) >> 6; attrs->va_mode |= ubits | (ubits << 3); } } @@ -105,7 +105,7 @@ afs_CopyOutAttrs(register struct vcache *avc, register struct vattr *attrs) attrs->va_fsid = avc->v.v_mount->m_stat.f_fsid.val[0]; #else #ifdef AFS_DARWIN70_ENV - attrs->va_fsid = avc->v.v_mount->mnt_stat.f_fsid.val[0]; + attrs->va_fsid = avc->v.v_mount->mnt_stat.f_fsid.val[0]; #else /* ! AFS_DARWIN70_ENV */ attrs->va_fsid = 1; #endif /* AFS_DARWIN70_ENV */ @@ -242,9 +242,9 @@ afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, struct AFS_UCRED *acred) extern struct unixuser *afs_FindUser(); struct unixuser *au; int inited = 0; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - AFS_STATCNT(afs_getattr); + AFS_STATCNT(afs_getattr); afs_Trace2(afs_iclSetp, CM_TRACE_GETATTR, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); @@ -474,9 +474,9 @@ afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs, struct AFSStoreStatus astat; register afs_int32 code; struct afs_fakestat_state fakestate; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - AFS_STATCNT(afs_setattr); + AFS_STATCNT(afs_setattr); #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV) afs_Trace4(afs_iclSetp, CM_TRACE_SETATTR, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, attrs->va_mask, ICL_TYPE_OFFSET, diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index c79a7b50cf..ad0f0e0c8d 100644 --- a/src/afs/VNOPS/afs_vnop_create.c +++ b/src/afs/VNOPS/afs_vnop_create.c @@ -71,10 +71,11 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, struct vcache *tvc; struct volume *volp = 0; struct afs_fakestat_state fakestate; - XSTATS_DECLS OSI_VC_CONVERT(adp) + XSTATS_DECLS; + OSI_VC_CONVERT(adp); - AFS_STATCNT(afs_create); + AFS_STATCNT(afs_create); if ((code = afs_InitReq(&treq, acred))) goto done2; diff --git a/src/afs/VNOPS/afs_vnop_dirops.c b/src/afs/VNOPS/afs_vnop_dirops.c index f96e7ffaf7..8f71cd1368 100644 --- a/src/afs/VNOPS/afs_vnop_dirops.c +++ b/src/afs/VNOPS/afs_vnop_dirops.c @@ -47,7 +47,7 @@ afs_mkdir(ndp, attrs) struct ucred *acred = ndp->ni_cred; #else /* AFS_OSF_ENV */ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred) - OSI_VC_DECL(adp); + OSI_VC_DECL(adp); register struct vcache **avcp; char *aname; struct vattr *attrs; @@ -67,9 +67,10 @@ afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred) struct AFSVolSync tsync; afs_int32 now; struct afs_fakestat_state fakestate; - XSTATS_DECLS OSI_VC_CONVERT(adp) + XSTATS_DECLS; + OSI_VC_CONVERT(adp); - AFS_STATCNT(afs_mkdir); + AFS_STATCNT(afs_mkdir); afs_Trace2(afs_iclSetp, CM_TRACE_MKDIR, ICL_TYPE_POINTER, adp, ICL_TYPE_STRING, aname); @@ -194,7 +195,7 @@ afs_rmdir(OSI_VC_ARG(adp), aname, cdirp, acred) #else afs_rmdir(adp, aname, acred) #endif - OSI_VC_DECL(adp); + OSI_VC_DECL(adp); char *aname; struct AFS_UCRED *acred; { @@ -208,9 +209,10 @@ afs_rmdir(adp, aname, acred) struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state fakestate; - XSTATS_DECLS OSI_VC_CONVERT(adp) + XSTATS_DECLS; + OSI_VC_CONVERT(adp); - AFS_STATCNT(afs_rmdir); + AFS_STATCNT(afs_rmdir); afs_Trace2(afs_iclSetp, CM_TRACE_RMDIR, ICL_TYPE_POINTER, adp, ICL_TYPE_STRING, aname); diff --git a/src/afs/VNOPS/afs_vnop_fid.c b/src/afs/VNOPS/afs_vnop_fid.c index 3eb414b9c0..69bfa19693 100644 --- a/src/afs/VNOPS/afs_vnop_fid.c +++ b/src/afs/VNOPS/afs_vnop_fid.c @@ -75,7 +75,7 @@ afs_fid(OSI_VC_ARG(avc), fidpp, credp) #else afs_fid(OSI_VC_ARG(avc), fidpp) #endif /* AFS_AIX41_ENV */ -OSI_VC_DECL(avc); + OSI_VC_DECL(avc); #if defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV) struct fid *fidpp; #else @@ -88,9 +88,9 @@ OSI_VC_DECL(avc); extern struct vcache *afs_globalVp; int SizeOfSmallFid = SIZEOF_SMALLFID; int rootvp = 0; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - AFS_STATCNT(afs_fid); + AFS_STATCNT(afs_fid); if (afs_shuttingdown) return EIO; diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index 8b3c0e99a4..90190ae45d 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -226,7 +226,8 @@ HandleFlock(register struct vcache *avc, int acom, struct vrequest *areq, struct AFSVolSync tsync; afs_int32 lockType; struct AFS_FLOCK flock; - XSTATS_DECLS AFS_STATCNT(HandleFlock); + XSTATS_DECLS; + AFS_STATCNT(HandleFlock); code = 0; /* default when we don't make any network calls */ lockIdSet(&flock, NULL, clid); @@ -804,7 +805,8 @@ GetFlockCount(struct vcache *avc, struct vrequest *areq) struct AFSCallBack CallBack; struct AFSVolSync tsync; int temp; - XSTATS_DECLS temp = areq->flags & O_NONBLOCK; + XSTATS_DECLS; + temp = areq->flags & O_NONBLOCK; areq->flags |= O_NONBLOCK; do { diff --git a/src/afs/VNOPS/afs_vnop_link.c b/src/afs/VNOPS/afs_vnop_link.c index 8f9146d137..e48ca78316 100644 --- a/src/afs/VNOPS/afs_vnop_link.c +++ b/src/afs/VNOPS/afs_vnop_link.c @@ -46,7 +46,7 @@ afs_link(OSI_VC_ARG(adp), avc, aname, acred) #else afs_link(avc, OSI_VC_ARG(adp), aname, acred) #endif - OSI_VC_DECL(adp); + OSI_VC_DECL(adp); struct vcache *avc; char *aname; struct AFS_UCRED *acred; @@ -60,9 +60,10 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) struct AFSFetchStatus OutFidStatus, OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state vfakestate, dfakestate; - XSTATS_DECLS OSI_VC_CONVERT(adp) + XSTATS_DECLS; + OSI_VC_CONVERT(adp); - AFS_STATCNT(afs_link); + AFS_STATCNT(afs_link); afs_Trace3(afs_iclSetp, CM_TRACE_LINK, ICL_TYPE_POINTER, adp, ICL_TYPE_POINTER, avc, ICL_TYPE_STRING, aname); /* create a hard link; new entry is aname in dir adp */ diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index f1581ca1c9..c2a413a325 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -402,7 +402,7 @@ afs_ENameOK(register char *aname) static int afs_getsysname(register struct vrequest *areq, register struct vcache *adp, - register char *bufp, int *num, char **sysnamelist[]) + register char *bufp, int *num, char **sysnamelist[]) { register struct unixuser *au; register afs_int32 error; @@ -411,29 +411,29 @@ afs_getsysname(register struct vrequest *areq, register struct vcache *adp, *sysnamelist = afs_sysnamelist; - if (!afs_nfsexporter) - strcpy(bufp, (*sysnamelist)[0]); + if (!afs_nfsexporter) + strcpy(bufp, (*sysnamelist)[0]); else { - au = afs_GetUser(areq->uid, adp->fid.Cell, 0); - if (au->exporter) { - error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num); - if (error) { - strcpy(bufp, "@sys"); - afs_PutUser(au, 0); - return -1; - } else { - strcpy(bufp, (*sysnamelist)[0]); - } - } else - strcpy(bufp, afs_sysname); - afs_PutUser(au, 0); + au = afs_GetUser(areq->uid, adp->fid.Cell, 0); + if (au->exporter) { + error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num); + if (error) { + strcpy(bufp, "@sys"); + afs_PutUser(au, 0); + return -1; + } else { + strcpy(bufp, (*sysnamelist)[0]); + } + } else + strcpy(bufp, afs_sysname); + afs_PutUser(au, 0); } return 0; } void -Check_AtSys(register struct vcache *avc, char *aname, - struct sysname_info *state, struct vrequest *areq) +Check_AtSys(register struct vcache *avc, char *aname, + struct sysname_info *state, struct vrequest *areq) { int num = 0; char **sysnamelist[MAXSYSNAME]; @@ -442,7 +442,8 @@ Check_AtSys(register struct vcache *avc, char *aname, state->offset = 0; state->name = (char *)osi_AllocLargeSpace(AFS_SMALLOCSIZ); state->allocked = 1; - state->index = afs_getsysname(areq, avc, state->name, &num, sysnamelist); + state->index = + afs_getsysname(areq, avc, state->name, &num, sysnamelist); } else { state->offset = -1; state->allocked = 0; @@ -453,54 +454,56 @@ Check_AtSys(register struct vcache *avc, char *aname, int Next_AtSys(register struct vcache *avc, struct vrequest *areq, - struct sysname_info *state) + struct sysname_info *state) { int num = afs_sysnamecount; char **sysnamelist[MAXSYSNAME]; if (state->index == -1) - return 0; /* No list */ + return 0; /* No list */ - /* Check for the initial state of aname != "@sys" in Check_AtSys*/ + /* Check for the initial state of aname != "@sys" in Check_AtSys */ if (state->offset == -1 && state->allocked == 0) { - register char *tname; + register char *tname; - /* Check for .*@sys */ - for (tname=state->name; *tname; tname++) - /*Move to the end of the string*/; + /* Check for .*@sys */ + for (tname = state->name; *tname; tname++) + /*Move to the end of the string */ ; - if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname-4))) { - state->offset = (tname - 4) - state->name; - tname = (char *) osi_AllocLargeSpace(AFS_LRALLOCSIZ); - strncpy(tname, state->name, state->offset); - state->name = tname; - state->allocked = 1; - num = 0; - state->index = afs_getsysname(areq, avc, state->name+state->offset, - &num, sysnamelist); - return 1; - } else - return 0; /* .*@sys doesn't match either */ + if ((tname > state->name + 4) && (AFS_EQ_ATSYS(tname - 4))) { + state->offset = (tname - 4) - state->name; + tname = (char *)osi_AllocLargeSpace(AFS_LRALLOCSIZ); + strncpy(tname, state->name, state->offset); + state->name = tname; + state->allocked = 1; + num = 0; + state->index = + afs_getsysname(areq, avc, state->name + state->offset, &num, + sysnamelist); + return 1; + } else + return 0; /* .*@sys doesn't match either */ } else { - register struct unixuser *au; - register afs_int32 error; - - *sysnamelist = afs_sysnamelist; + register struct unixuser *au; + register afs_int32 error; - if (afs_nfsexporter) { - au = afs_GetUser(areq->uid, avc->fid.Cell, 0); - if (au->exporter) { - error = EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num); - if (error) { - return 0; - } - } - afs_PutUser(au, 0); - } - if (++(state->index) >= num || !(*sysnamelist)[state->index]) - return 0; /* end of list */ + *sysnamelist = afs_sysnamelist; + + if (afs_nfsexporter) { + au = afs_GetUser(areq->uid, avc->fid.Cell, 0); + if (au->exporter) { + error = + EXP_SYSNAME(au->exporter, (char *)0, sysnamelist, num); + if (error) { + return 0; + } + } + afs_PutUser(au, 0); + } + if (++(state->index) >= num || !(*sysnamelist)[state->index]) + return 0; /* end of list */ } - strcpy(state->name+state->offset, (*sysnamelist)[state->index]); + strcpy(state->name + state->offset, (*sysnamelist)[state->index]); return 1; } @@ -509,7 +512,7 @@ extern int BlobScan(ino64_t * afile, afs_int32 ablob); #else #if defined(AFS_HPUX1123_ENV) /* DEE should use the new afs_inode_t for all */ -extern int BlobScan(ino_t *afile, afs_int32 ablob); +extern int BlobScan(ino_t * afile, afs_int32 ablob); #else #if defined AFS_LINUX_64BIT_KERNEL extern int BlobScan(long *afile, afs_int32 ablob); @@ -577,13 +580,13 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) struct VenusFid dotdot; int flagIndex; /* First file with bulk fetch flag set */ int inlinebulk = 0; /* Did we use InlineBulk RPC or not? */ - XSTATS_DECLS - /* first compute some basic parameters. We dont want to prefetch more - * than a fraction of the cache in any given call, and we want to preserve - * a portion of the LRU queue in any event, so as to avoid thrashing - * the entire stat cache (we will at least leave some of it alone). - * presently dont stat more than 1/8 the cache in any one call. */ - nentries = afs_cacheStats / 8; + XSTATS_DECLS; + /* first compute some basic parameters. We dont want to prefetch more + * than a fraction of the cache in any given call, and we want to preserve + * a portion of the LRU queue in any event, so as to avoid thrashing + * the entire stat cache (we will at least leave some of it alone). + * presently dont stat more than 1/8 the cache in any one call. */ + nentries = afs_cacheStats / 8; /* dont bother prefetching more than one calls worth of info */ if (nentries > AFSCBMAX) @@ -1111,7 +1114,7 @@ afs_lookup(adp, aname, avcp, acred, flags) afs_lookup(adp, aname, avcp, acred) #endif /* UKERNEL */ #endif /* SUN5 || SGI */ -OSI_VC_DECL(adp); + OSI_VC_DECL(adp); struct vcache **avcp; char *aname; struct AFS_UCRED *acred; @@ -1125,7 +1128,7 @@ OSI_VC_DECL(adp); int pass = 0, hit = 0; long dirCookie; extern afs_int32 afs_mariner; /*Writing activity to log? */ - OSI_VC_CONVERT(adp) + OSI_VC_CONVERT(adp); afs_hyper_t versionNo; int no_read_access = 0; struct sysname_info sysState; /* used only for @sys checking */ diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c index 9d6bca136d..c681c136a5 100644 --- a/src/afs/VNOPS/afs_vnop_readdir.c +++ b/src/afs/VNOPS/afs_vnop_readdir.c @@ -72,8 +72,8 @@ BlobScan(ino64_t * afile, afs_int32 ablob) #else #if defined(AFS_HPUX1123_ENV) /*DEE should use afs_inode_t for all */ -int -BlobScan(ino_t *afile, afs_int32 ablob) +int +BlobScan(ino_t * afile, afs_int32 ablob) #else #ifdef AFS_LINUX_64BIT_KERNEL int @@ -509,7 +509,7 @@ afs_readdir2(OSI_VC_ARG(avc), auio, acred) afs_readdir(OSI_VC_ARG(avc), auio, acred) #endif #endif - OSI_VC_DECL(avc); + OSI_VC_DECL(avc); struct uio *auio; struct AFS_UCRED *acred; { @@ -525,13 +525,13 @@ afs_readdir(OSI_VC_ARG(avc), auio, acred) #if defined(AFS_SGI53_ENV) afs_int32 use64BitDirent, dirsiz; #endif /* defined(AFS_SGI53_ENV) */ - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); #ifdef AFS_HPUX_ENV - /* - * XXX All the hacks for alloced sdirEntry and inlining of afs_readdir_move instead of calling - * it is necessary for hpux due to stack problems that seem to occur when coming thru the nfs - * translator side XXX - */ + /* + * XXX All the hacks for alloced sdirEntry and inlining of afs_readdir_move instead of calling + * it is necessary for hpux due to stack problems that seem to occur when coming thru the nfs + * translator side XXX + */ struct min_direct *sdirEntry = (struct min_direct *)osi_AllocSmallSpace(sizeof(struct min_direct)); afs_int32 rlen; diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c index 447bb18ba5..7b25833102 100644 --- a/src/afs/VNOPS/afs_vnop_remove.c +++ b/src/afs/VNOPS/afs_vnop_remove.c @@ -110,7 +110,7 @@ afsremove(register struct vcache *adp, register struct dcache *tdc, register struct conn *tc; struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; - XSTATS_DECLS + XSTATS_DECLS; do { tc = afs_Conn(&adp->fid, treqp, SHARED_LOCK); if (tc) { @@ -228,7 +228,7 @@ afs_remove(ndp) struct ucred *acred = ndp->ni_cred; #else /* AFS_OSF_ENV */ afs_remove(OSI_VC_ARG(adp), aname, acred) -OSI_VC_DECL(adp); + OSI_VC_DECL(adp); char *aname; struct AFS_UCRED *acred; { @@ -240,9 +240,9 @@ OSI_VC_DECL(adp); register struct vcache *tvc; afs_size_t offset, len; struct afs_fakestat_state fakestate; - OSI_VC_CONVERT(adp) + OSI_VC_CONVERT(adp); - AFS_STATCNT(afs_remove); + AFS_STATCNT(afs_remove); afs_Trace2(afs_iclSetp, CM_TRACE_REMOVE, ICL_TYPE_POINTER, adp, ICL_TYPE_STRING, aname); @@ -279,12 +279,11 @@ OSI_VC_DECL(adp); #endif return code; } - #if 0 if (adp->mvstat == 2) { afs_PutFakeStat(&fakestate); #ifdef AFS_OSF_ENV - afs_PutVCache(adp); + afs_PutVCache(adp); afs_PutVCache(tvc); #endif return EISDIR; @@ -402,13 +401,14 @@ OSI_VC_DECL(adp); Ttvcr = VREFCOUNT(tvc); #ifdef AFS_AIX_ENV if (tvc && (VREFCOUNT(tvc) > 2) && tvc->opens > 0 - && !(tvc->states & CUnlinked)) + && !(tvc->states & CUnlinked)) #else #ifdef AFS_DARWIN14_ENV - if (tvc && (VREFCOUNT(tvc) > 1 + DARWIN_REFBASE) && tvc->opens > 0 && !(tvc->states & CUnlinked)) + if (tvc && (VREFCOUNT(tvc) > 1 + DARWIN_REFBASE) && tvc->opens > 0 + && !(tvc->states & CUnlinked)) #else if (tvc && (VREFCOUNT(tvc) > 1) && tvc->opens > 0 - && !(tvc->states & CUnlinked)) + && !(tvc->states & CUnlinked)) #endif #endif { @@ -495,10 +495,10 @@ afs_remunlink(register struct vcache *avc, register int doit) avc->states &= ~(CUnlinked | CUnlinkedDel); #ifdef AFS_DARWIN14_ENV - if (VREFCOUNT(avc) < 4) { - oldref = 4 - VREFCOUNT(avc); - VREFCOUNT_SET(avc, 4); - } + if (VREFCOUNT(avc) < 4) { + oldref = 4 - VREFCOUNT(avc); + VREFCOUNT_SET(avc, 4); + } #endif ReleaseWriteLock(&avc->lock); @@ -529,7 +529,7 @@ afs_remunlink(register struct vcache *avc, register int doit) VREFCOUNT_SET(avc, 0); #else if (oldref) { - int newref = VREFCOUNT(avc) - oldref; + int newref = VREFCOUNT(avc) - oldref; VREFCOUNT_SET(avc, newref); } #endif diff --git a/src/afs/VNOPS/afs_vnop_rename.c b/src/afs/VNOPS/afs_vnop_rename.c index 3fa86a72f2..cd71a798fe 100644 --- a/src/afs/VNOPS/afs_vnop_rename.c +++ b/src/afs/VNOPS/afs_vnop_rename.c @@ -46,7 +46,8 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, struct dcache *tdc1, *tdc2; struct AFSFetchStatus OutOldDirStatus, OutNewDirStatus; struct AFSVolSync tsync; - XSTATS_DECLS AFS_STATCNT(afs_rename); + XSTATS_DECLS; + AFS_STATCNT(afs_rename); afs_Trace4(afs_iclSetp, CM_TRACE_RENAME, ICL_TYPE_POINTER, aodp, ICL_TYPE_STRING, aname1, ICL_TYPE_POINTER, andp, ICL_TYPE_STRING, aname2); @@ -370,11 +371,11 @@ afs_rename(fndp, tndp) #else /* AFS_OSF_ENV */ #if defined(AFS_SGI_ENV) afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, npnp, acred) - struct pathname *npnp; + struct pathname *npnp; #else afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, acred) #endif - OSI_VC_DECL(aodp); + OSI_VC_DECL(aodp); struct vcache *andp; char *aname1, *aname2; struct AFS_UCRED *acred; @@ -384,9 +385,9 @@ afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, acred) struct afs_fakestat_state ofakestate; struct afs_fakestat_state nfakestate; struct vrequest treq; - OSI_VC_CONVERT(aodp) + OSI_VC_CONVERT(aodp); - code = afs_InitReq(&treq, acred); + code = afs_InitReq(&treq, acred); if (code) return code; afs_InitFakeStat(&ofakestate); diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c index b7d8d02909..b33f970b4b 100644 --- a/src/afs/VNOPS/afs_vnop_symlink.c +++ b/src/afs/VNOPS/afs_vnop_symlink.c @@ -41,8 +41,7 @@ extern afs_rwlock_t afs_xcbhash; /* don't set CDirty in here because RPC is called synchronously */ -int -afs_symlink +int afs_symlink #ifdef AFS_OSF_ENV (ndp, attrs, atargetName) struct nameidata *ndp; @@ -77,7 +76,8 @@ afs_symlink struct AFSVolSync tsync; struct volume *volp = 0; struct afs_fakestat_state fakestate; - XSTATS_DECLS OSI_VC_CONVERT(adp) + XSTATS_DECLS; + OSI_VC_CONVERT(adp); AFS_STATCNT(afs_symlink); afs_Trace2(afs_iclSetp, CM_TRACE_SYMLINK, ICL_TYPE_POINTER, adp, @@ -355,7 +355,7 @@ afs_readlink(OSI_VC_ARG(avc), auio, acred) struct vrequest treq; register char *tp; struct afs_fakestat_state fakestat; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); AFS_STATCNT(afs_readlink); afs_Trace1(afs_iclSetp, CM_TRACE_READLINK, ICL_TYPE_POINTER, avc); diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c index af43787bb2..93b72fac02 100644 --- a/src/afs/VNOPS/afs_vnop_write.c +++ b/src/afs/VNOPS/afs_vnop_write.c @@ -824,7 +824,7 @@ afs_close(OSI_VC_ARG(avc), aflags, count, acred) #else afs_close(OSI_VC_ARG(avc), aflags, acred) #endif -OSI_VC_DECL(avc); + OSI_VC_DECL(avc); afs_int32 aflags; struct AFS_UCRED *acred; { @@ -835,9 +835,9 @@ OSI_VC_DECL(avc); struct flid flid; #endif struct afs_fakestat_state fakestat; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - AFS_STATCNT(afs_close); + AFS_STATCNT(afs_close); afs_Trace2(afs_iclSetp, CM_TRACE_CLOSE, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, aflags); code = afs_InitReq(&treq, acred); @@ -1018,9 +1018,9 @@ OSI_VC_DECL(avc); { register afs_int32 code; struct vrequest treq; - OSI_VC_CONVERT(avc) + OSI_VC_CONVERT(avc); - if (avc->vc_error) + if (avc->vc_error) return avc->vc_error; #if defined(AFS_SUN5_ENV) diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 4b5c69fdd4..f8f4b48452 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -1535,7 +1535,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, int doReallyAdjustSize = 0; int overWriteWholeChunk = 0; - XSTATS_DECLS + XSTATS_DECLS; #ifndef AFS_NOSTATS struct afs_stats_xferData *xferP; /* Ptr to this op's xfer struct */ osi_timeval_t xferStartTime, /*FS xfer start time */ @@ -2618,7 +2618,7 @@ afs_WriteThroughDSlots(void) #define DQTODC(q) ((struct dcache *)(((char *) (q)) - sizeof(struct afs_q))) for (tq = DirtyQ.prev; tq != &DirtyQ; tq = QPrev(tq)) { - tdc = DQTODC(tq); + tdc = DQTODC(tq); if (tdc->dflags & DFEntryMod) { int wrLock; diff --git a/src/afs/afs_segments.c b/src/afs/afs_segments.c index 72f51cc7c7..f9d5b80680 100644 --- a/src/afs/afs_segments.c +++ b/src/afs/afs_segments.c @@ -47,7 +47,8 @@ afs_StoreMini(register struct vcache *avc, struct vrequest *areq) register afs_int32 code; register struct rx_call *tcall; afs_size_t tlen, xlen = 0; - XSTATS_DECLS AFS_STATCNT(afs_StoreMini); + XSTATS_DECLS; + AFS_STATCNT(afs_StoreMini); afs_Trace2(afs_iclSetp, CM_TRACE_STOREMINI, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, avc->m.Length); tlen = avc->m.Length; @@ -305,7 +306,8 @@ afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, struct conn *tc; struct osi_file *tfile; struct rx_call *tcall; - XSTATS_DECLS for (bytes = 0, j = 0; !code && j <= high; j++) { + XSTATS_DECLS; + for (bytes = 0, j = 0; !code && j <= high; j++) { if (dcList[j]) { ObtainSharedLock(&(dcList[j]->lock), 629); if (!bytes) diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 0c86e81a1f..1b0acb6eac 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -82,7 +82,8 @@ static afs_int32 afs_QueueVCB(struct vcache *avc); * Generate an index into the hash table for a given Fid. */ static int -afs_HashCBRFid(struct AFSFid *fid) { +afs_HashCBRFid(struct AFSFid *fid) +{ return (fid->Volume + fid->Vnode + fid->Unique) % CBRSIZE; } @@ -93,7 +94,8 @@ afs_HashCBRFid(struct AFSFid *fid) { * Must be called with afs_xvcb held. */ static void -afs_InsertHashCBR(struct afs_cbr *cbr) { +afs_InsertHashCBR(struct afs_cbr *cbr) +{ int slot = afs_HashCBRFid(&cbr->fid); cbr->hash_next = afs_cbrHashT[slot]; @@ -371,7 +373,8 @@ afs_FlushVCBs(afs_int32 lockit) struct vrequest treq; struct conn *tc; int safety1, safety2, safety3; - XSTATS_DECLS if ((code = afs_InitReq(&treq, afs_osi_credp))) + XSTATS_DECLS; + if ((code = afs_InitReq(&treq, afs_osi_credp))) return code; treq.flags |= O_NONBLOCK; tfids = afs_osi_Alloc(sizeof(struct AFSFid) * AFS_MAXCBRSCALL); @@ -545,7 +548,7 @@ afs_RemoveVCB(struct VenusFid *afid) ncbr = cbr->hash_next; if (afid->Fid.Volume == cbr->fid.Volume && - afid->Fid.Vnode == cbr->fid.Vnode && + afid->Fid.Vnode == cbr->fid.Vnode && afid->Fid.Unique == cbr->fid.Unique) { afs_FreeCBR(cbr); } @@ -826,14 +829,15 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp) refpanic("VLRU inconsistent"); } #ifdef AFS_DARWIN_ENV - if ((VREFCOUNT(tvc) < DARWIN_REFBASE) || - (VREFCOUNT(tvc) < 1+DARWIN_REFBASE && + if ((VREFCOUNT(tvc) < DARWIN_REFBASE) || + (VREFCOUNT(tvc) < 1 + DARWIN_REFBASE && UBCINFOEXISTS(&tvc->v))) { - VREFCOUNT_SET(tvc, - DARWIN_REFBASE + (UBCINFOEXISTS(&tvc->v) ? 1 : 0)); + VREFCOUNT_SET(tvc, + DARWIN_REFBASE + + (UBCINFOEXISTS(&tvc->v) ? 1 : 0)); } if (tvc->opens == 0 && ((tvc->states & CUnlinkedDel) == 0) - && VREFCOUNT(tvc) == DARWIN_REFBASE+1 + && VREFCOUNT(tvc) == DARWIN_REFBASE + 1 && UBCINFOEXISTS(&tvc->v)) { osi_VM_TryReclaim(tvc, &fv_slept); if (fv_slept) { @@ -854,14 +858,13 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp) } #endif - if (VREFCOUNT(tvc) == + if (VREFCOUNT(tvc) == #ifdef AFS_DARWIN_ENV DARWIN_REFBASE #else - 0 + 0 #endif - && tvc->opens == 0 - && (tvc->states & CUnlinkedDel) == 0) { + && tvc->opens == 0 && (tvc->states & CUnlinkedDel) == 0) { #if defined(AFS_XBSD_ENV) /* * vgone() reclaims the vnode, which calls afs_FlushVCache(), @@ -972,14 +975,14 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp) AFS_GLOCK(); if (tvc->v != NULL) { /* I'd like to know if this ever happens... - We don't drop global for the rest of this function, - so if we do lose the race, the other thread should - have found the same vnode and finished initializing - the vcache entry. Is it conceivable that this vcache - entry could be recycled during this interval? If so, - then there probably needs to be some sort of additional - mutual exclusion (an Embryonic flag would suffice). - -GAW */ + * We don't drop global for the rest of this function, + * so if we do lose the race, the other thread should + * have found the same vnode and finished initializing + * the vcache entry. Is it conceivable that this vcache + * entry could be recycled during this interval? If so, + * then there probably needs to be some sort of additional + * mutual exclusion (an Embryonic flag would suffice). + * -GAW */ printf("afs_NewVCache: lost the race\n"); return (tvc); } @@ -1009,75 +1012,75 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp) tvc->truncPos = AFS_NOTRUNC; /* don't truncate until we need to */ hzero(tvc->m.DataVersion); /* in case we copy it into flushDV */ #if defined(AFS_LINUX22_ENV) -{ - struct inode *ip = AFSTOI(tvc); - struct address_space *mapping = &ip->i_data; + { + struct inode *ip = AFSTOI(tvc); + struct address_space *mapping = &ip->i_data; #if defined(AFS_LINUX26_ENV) - inode_init_once(ip); + inode_init_once(ip); #else - sema_init(&ip->i_sem, 1); - INIT_LIST_HEAD(&ip->i_hash); - INIT_LIST_HEAD(&ip->i_dentry); + sema_init(&ip->i_sem, 1); + INIT_LIST_HEAD(&ip->i_hash); + INIT_LIST_HEAD(&ip->i_dentry); #if defined(AFS_LINUX24_ENV) - sema_init(&ip->i_zombie, 1); - init_waitqueue_head(&ip->i_wait); - spin_lock_init(&ip->i_data.i_shared_lock); + sema_init(&ip->i_zombie, 1); + init_waitqueue_head(&ip->i_wait); + spin_lock_init(&ip->i_data.i_shared_lock); #ifdef STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK - spin_lock_init(&ip->i_data.page_lock); + spin_lock_init(&ip->i_data.page_lock); #endif - INIT_LIST_HEAD(&ip->i_data.clean_pages); - INIT_LIST_HEAD(&ip->i_data.dirty_pages); - INIT_LIST_HEAD(&ip->i_data.locked_pages); - INIT_LIST_HEAD(&ip->i_dirty_buffers); + INIT_LIST_HEAD(&ip->i_data.clean_pages); + INIT_LIST_HEAD(&ip->i_data.dirty_pages); + INIT_LIST_HEAD(&ip->i_data.locked_pages); + INIT_LIST_HEAD(&ip->i_dirty_buffers); #ifdef STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS - INIT_LIST_HEAD(&ip->i_dirty_data_buffers); + INIT_LIST_HEAD(&ip->i_dirty_data_buffers); #endif #ifdef STRUCT_INODE_HAS_I_DEVICES - INIT_LIST_HEAD(&ip->i_devices); + INIT_LIST_HEAD(&ip->i_devices); #endif #ifdef STRUCT_INODE_HAS_I_TRUNCATE_SEM - init_rwsem(&ip->i_truncate_sem); + init_rwsem(&ip->i_truncate_sem); #endif #ifdef STRUCT_INODE_HAS_I_ALLOC_SEM - init_rwsem(&ip->i_alloc_sem); -#endif + init_rwsem(&ip->i_alloc_sem); +#endif #else /* AFS_LINUX22_ENV */ - sema_init(&ip->i_atomic_write, 1); - init_waitqueue(&ip->i_wait); + sema_init(&ip->i_atomic_write, 1); + init_waitqueue(&ip->i_wait); #endif #endif #if defined(AFS_LINUX24_ENV) - mapping->host = ip; - ip->i_mapping = mapping; + mapping->host = ip; + ip->i_mapping = mapping; #ifdef STRUCT_ADDRESS_SPACE_HAS_GFP_MASK - ip->i_data.gfp_mask = GFP_HIGHUSER; + ip->i_data.gfp_mask = GFP_HIGHUSER; #endif #if defined(AFS_LINUX26_ENV) - mapping_set_gfp_mask(mapping, GFP_HIGHUSER); -{ - extern struct backing_dev_info afs_backing_dev_info; + mapping_set_gfp_mask(mapping, GFP_HIGHUSER); + { + extern struct backing_dev_info afs_backing_dev_info; - mapping->backing_dev_info = &afs_backing_dev_info; -} + mapping->backing_dev_info = &afs_backing_dev_info; + } #endif #endif #if !defined(AFS_LINUX26_ENV) - if (afs_globalVFS) - ip->i_dev = afs_globalVFS->s_dev; + if (afs_globalVFS) + ip->i_dev = afs_globalVFS->s_dev; #else #ifdef STRUCT_INODE_HAS_I_SECURITY - ip->i_security = NULL; - if (security_inode_alloc(ip)) - panic("Cannot allocate inode security"); + ip->i_security = NULL; + if (security_inode_alloc(ip)) + panic("Cannot allocate inode security"); #endif #endif - ip->i_sb = afs_globalVFS; - put_inode_on_dummy_list(ip); -} + ip->i_sb = afs_globalVFS; + put_inode_on_dummy_list(ip); + } #endif #ifdef AFS_OSF_ENV @@ -1165,7 +1168,7 @@ afs_NewVCache(struct VenusFid *afid, struct server *serverp) /* VLISTNONE(&tvc->v); */ tvc->v.v_freelist.tqe_next = 0; tvc->v.v_freelist.tqe_prev = (struct vnode **)0xdeadb; - tvc->vrefCount+=DARWIN_REFBASE; + tvc->vrefCount += DARWIN_REFBASE; #endif /* * The proper value for mvstat (for root fids) is setup by the caller. @@ -1266,7 +1269,8 @@ afs_FlushActiveVcaches(register afs_int32 doflocks) struct vrequest treq, ureq; struct AFSVolSync tsync; int didCore; - XSTATS_DECLS AFS_STATCNT(afs_FlushActiveVcaches); + XSTATS_DECLS; + AFS_STATCNT(afs_FlushActiveVcaches); ObtainReadLock(&afs_xvcache); for (i = 0; i < VCSIZE; i++) { for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { @@ -1378,7 +1382,7 @@ afs_FlushActiveVcaches(register afs_int32 doflocks) } } #ifdef AFS_DARWIN_ENV - if (VREFCOUNT(tvc) == 1+DARWIN_REFBASE + if (VREFCOUNT(tvc) == 1 + DARWIN_REFBASE && UBCINFOEXISTS(&tvc->v)) { if (tvc->opens) panic("flushactive open, hasubc, but refcnt 1"); @@ -1579,7 +1583,8 @@ afs_WriteVCache(register struct vcache *avc, struct conn *tc; struct AFSFetchStatus OutStatus; struct AFSVolSync tsync; - XSTATS_DECLS AFS_STATCNT(afs_WriteVCache); + XSTATS_DECLS; + AFS_STATCNT(afs_WriteVCache); afs_Trace2(afs_iclSetp, CM_TRACE_WVCACHE, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); @@ -1743,8 +1748,9 @@ afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, afs_uint32 start; register struct conn *tc; struct AFSFetchStatus OutDirStatus; - XSTATS_DECLS if (!name) - name = ""; /* XXX */ + XSTATS_DECLS; + if (!name) + name = ""; /* XXX */ do { tc = afs_Conn(afid, areq, SHARED_LOCK); if (tc) { @@ -2198,16 +2204,16 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq, #endif /* AFS_OSF_ENV */ #ifdef AFS_DARWIN14_ENV /* It'd really suck if we allowed duplicate vcaches for the - same fid to happen. Wonder if this will work? */ + * same fid to happen. Wonder if this will work? */ struct vnode *vp = AFSTOV(tvc); - if (vp->v_flag & (VXLOCK|VORECLAIM|VTERMINATE)) { - printf("precluded FindVCache on %x (%d:%d:%d)\n", + if (vp->v_flag & (VXLOCK | VORECLAIM | VTERMINATE)) { + printf("precluded FindVCache on %x (%d:%d:%d)\n", vp, tvc->fid.Fid.Volume, tvc->fid.Fid.Vnode, tvc->fid.Fid.Unique); simple_lock(&vp->v_interlock); SET(vp->v_flag, VTERMWANT); simple_unlock(&vp->v_interlock); - (void)tsleep((caddr_t)&vp->v_ubcinfo, PINOD, "vget1", 0); + (void)tsleep((caddr_t) & vp->v_ubcinfo, PINOD, "vget1", 0); printf("VTERMWANT ended on %x\n", vp); continue; } @@ -2378,7 +2384,7 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid, struct AFSCallBack CallBack; struct AFSVolSync tsync; struct volume *volp; - XSTATS_DECLS + XSTATS_DECLS; do { tc = afs_Conn(afid, areq, SHARED_LOCK); avc->quick.stamp = 0; diff --git a/src/auth/authcon.c b/src/auth/authcon.c index 029464730e..aff1106a8f 100644 --- a/src/auth/authcon.c +++ b/src/auth/authcon.c @@ -72,14 +72,17 @@ afsconf_ServerAuth(adir, astr, aindex) { register struct rx_securityClass *tclass; - LOCK_GLOBAL_MUTEX tclass = (struct rx_securityClass *) + LOCK_GLOBAL_MUTEX; + tclass = (struct rx_securityClass *) rxkad_NewServerSecurityObject(0, adir, afsconf_GetKey, NULL); if (tclass) { *astr = tclass; *aindex = 2; /* kerberos security index */ - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } else { - UNLOCK_GLOBAL_MUTEX return 2; + UNLOCK_GLOBAL_MUTEX; + return 2; } } #endif /* !defined(UKERNEL) */ @@ -145,8 +148,10 @@ afsconf_ClientAuth(struct afsconf_dir * adir, struct rx_securityClass ** astr, { afs_int32 rc; - LOCK_GLOBAL_MUTEX rc = GenericAuth(adir, astr, aindex, rxkad_clear); - UNLOCK_GLOBAL_MUTEX return rc; + LOCK_GLOBAL_MUTEX; + rc = GenericAuth(adir, astr, aindex, rxkad_clear); + UNLOCK_GLOBAL_MUTEX; + return rc; } /* build a fake ticket for 'afs' using keys from adir, returning an @@ -161,6 +166,8 @@ afsconf_ClientAuthSecure(adir, astr, aindex) { afs_int32 rc; - LOCK_GLOBAL_MUTEX rc = GenericAuth(adir, astr, aindex, rxkad_crypt); - UNLOCK_GLOBAL_MUTEX return rc; + LOCK_GLOBAL_MUTEX; + rc = GenericAuth(adir, astr, aindex, rxkad_crypt); + UNLOCK_GLOBAL_MUTEX; + return rc; } diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index 39bd0e3f07..0e3a6320a2 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -211,20 +211,21 @@ afsconf_Check(register struct afsconf_dir *adir) #ifdef AFS_NT40_ENV /* NT client CellServDB has different file name than NT server or Unix */ if (IsClientConfigDirectory(adir->name)) { - if ( !afssw_GetClientCellServDBDir(&p) ) { - strcompose(tbuffer, sizeof(tbuffer), p, "/", - AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); - free(p); - } else { - int len; - strncpy(tbuffer, adir->name, sizeof(tbuffer)); - len = strlen(tbuffer); - if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) { - strncat(tbuffer, "\\", sizeof(tbuffer)); - } - strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer)); - tbuffer[sizeof(tbuffer)-1] = '\0'; - } + if (!afssw_GetClientCellServDBDir(&p)) { + strcompose(tbuffer, sizeof(tbuffer), p, "/", + AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); + free(p); + } else { + int len; + strncpy(tbuffer, adir->name, sizeof(tbuffer)); + len = strlen(tbuffer); + if (tbuffer[len - 1] != '\\' && tbuffer[len - 1] != '/') { + strncat(tbuffer, "\\", sizeof(tbuffer)); + } + strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, + sizeof(tbuffer)); + tbuffer[sizeof(tbuffer) - 1] = '\0'; + } } else { strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL); @@ -260,18 +261,19 @@ afsconf_Touch(register struct afsconf_dir *adir) /* NT client CellServDB has different file name than NT server or Unix */ if (IsClientConfigDirectory(adir->name)) { - if ( !afssw_GetClientCellServDBDir(&p) ) { - strcompose(tbuffer, sizeof(tbuffer), p, "/", - AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); - free(p); - } else { - int len = strlen(tbuffer); - if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) { - strncat(tbuffer, "\\", sizeof(tbuffer)); - } - strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer)); - tbuffer[sizeof(tbuffer)-1] = '\0'; - } + if (!afssw_GetClientCellServDBDir(&p)) { + strcompose(tbuffer, sizeof(tbuffer), p, "/", + AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); + free(p); + } else { + int len = strlen(tbuffer); + if (tbuffer[len - 1] != '\\' && tbuffer[len - 1] != '/') { + strncat(tbuffer, "\\", sizeof(tbuffer)); + } + strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, + sizeof(tbuffer)); + tbuffer[sizeof(tbuffer) - 1] = '\0'; + } } else { strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, NULL); @@ -293,9 +295,9 @@ afsconf_Open(register const char *adir) register struct afsconf_dir *tdir; register afs_int32 code; - LOCK_GLOBAL_MUTEX - /* zero structure and fill in name; rest is done by internal routine */ - tdir = (struct afsconf_dir *)malloc(sizeof(struct afsconf_dir)); + LOCK_GLOBAL_MUTEX; + /* zero structure and fill in name; rest is done by internal routine */ + tdir = (struct afsconf_dir *)malloc(sizeof(struct afsconf_dir)); memset(tdir, 0, sizeof(struct afsconf_dir)); tdir->name = (char *)malloc(strlen(adir) + 1); strcpy(tdir->name, adir); @@ -317,7 +319,8 @@ afsconf_Open(register const char *adir) fp = fopen("/.AFSCONF", "r"); if (fp == 0) { free(tdir); - UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; + UNLOCK_GLOBAL_MUTEX; + return (struct afsconf_dir *)0; } fgets(afs_confdir, 128, fp); fclose(fp); @@ -331,7 +334,8 @@ afsconf_Open(register const char *adir) fp = fopen("/.AFSCONF", "r"); if (fp == 0) { free(tdir); - UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; + UNLOCK_GLOBAL_MUTEX; + return (struct afsconf_dir *)0; } } fgets(afs_confdir, 128, fp); @@ -340,7 +344,8 @@ afsconf_Open(register const char *adir) len = strlen(afs_confdir); if (len == 0) { free(tdir); - UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; + UNLOCK_GLOBAL_MUTEX; + return (struct afsconf_dir *)0; } if (afs_confdir[len - 1] == '\n') { afs_confdir[len - 1] = 0; @@ -353,10 +358,12 @@ afsconf_Open(register const char *adir) if (code) { free(tdir->name); free(tdir); - UNLOCK_GLOBAL_MUTEX return (struct afsconf_dir *)0; + UNLOCK_GLOBAL_MUTEX; + return (struct afsconf_dir *)0; } } - UNLOCK_GLOBAL_MUTEX return tdir; + UNLOCK_GLOBAL_MUTEX; + return tdir; } @@ -434,21 +441,22 @@ afsconf_OpenInternal(register struct afsconf_dir *adir, char *cell, */ if (IsClientConfigDirectory(adir->name)) { /* NT client config dir */ - char * p; - if ( !afssw_GetClientCellServDBDir(&p) ) { - strcompose(tbuffer, sizeof(tbuffer), p, "/", - AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); - free(p); - } else { - int len; - strncpy(tbuffer, adir->name, sizeof(tbuffer)); - len = strlen(tbuffer); - if ( tbuffer[len-1] != '\\' && tbuffer[len-1] != '/' ) { - strncat(tbuffer, "\\", sizeof(tbuffer)); - } - strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, sizeof(tbuffer)); - tbuffer[sizeof(tbuffer)-1] = '\0'; - } + char *p; + if (!afssw_GetClientCellServDBDir(&p)) { + strcompose(tbuffer, sizeof(tbuffer), p, "/", + AFSDIR_CELLSERVDB_FILE_NTCLIENT, NULL); + free(p); + } else { + int len; + strncpy(tbuffer, adir->name, sizeof(tbuffer)); + len = strlen(tbuffer); + if (tbuffer[len - 1] != '\\' && tbuffer[len - 1] != '/') { + strncat(tbuffer, "\\", sizeof(tbuffer)); + } + strncat(tbuffer, AFSDIR_CELLSERVDB_FILE_NTCLIENT, + sizeof(tbuffer)); + tbuffer[sizeof(tbuffer) - 1] = '\0'; + } } else { /* NT server config dir */ strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLSERVDB_FILE, @@ -663,13 +671,16 @@ afsconf_CellApply(struct afsconf_dir *adir, { register struct afsconf_entry *tde; register afs_int32 code; - LOCK_GLOBAL_MUTEX for (tde = adir->entries; tde; tde = tde->next) { + LOCK_GLOBAL_MUTEX; + for (tde = adir->entries; tde; tde = tde->next) { code = (*aproc) (&tde->cellInfo, arock, adir); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* call aproc(entry, arock, adir) for all cell aliases. @@ -683,13 +694,16 @@ afsconf_CellAliasApply(struct afsconf_dir *adir, { register struct afsconf_aliasentry *tde; register afs_int32 code; - LOCK_GLOBAL_MUTEX for (tde = adir->alias_entries; tde; tde = tde->next) { + LOCK_GLOBAL_MUTEX; + for (tde = adir->alias_entries; tde; tde = tde->next) { code = (*aproc) (&tde->aliasInfo, arock, adir); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } afs_int32 afsconf_SawCell = 0; @@ -735,10 +749,11 @@ afsconf_GetAfsdbInfo(char *acellName, char *aservice, * replaced with a more fine-grained lock just for the resolver * operations. */ - LOCK_GLOBAL_MUTEX len = - res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer)); - UNLOCK_GLOBAL_MUTEX if (len < 0) - return AFSCONF_NOTFOUND; + LOCK_GLOBAL_MUTEX; + len = res_search(acellName, C_IN, T_AFSDB, answer, sizeof(answer)); + UNLOCK_GLOBAL_MUTEX; + if (len < 0) + return AFSCONF_NOTFOUND; p = answer + sizeof(HEADER); /* Skip header */ code = dn_expand(answer, answer + len, p, host, sizeof(host)); @@ -830,14 +845,15 @@ afsconf_GetAfsdbInfo(char *acellName, char *aservice, int tservice; struct afsconf_entry DNSce; afs_int32 cellHostAddrs[AFSMAXCELLHOSTS]; - char cellHostNames[AFSMAXCELLHOSTS][MAXHOSTCHARS]; + char cellHostNames[AFSMAXCELLHOSTS][MAXHOSTCHARS]; int numServers; int rc; int ttl; DNSce.cellInfo.numServers = 0; DNSce.next = NULL; - rc = getAFSServer(acellName, cellHostAddrs, cellHostNames, &numServers, &ttl); + rc = getAFSServer(acellName, cellHostAddrs, cellHostNames, &numServers, + &ttl); /* ignore the ttl here since this code is only called by transitory programs * like klog, etc. */ if (rc < 0) @@ -857,8 +873,10 @@ afsconf_GetAfsdbInfo(char *acellName, char *aservice, acellInfo->numServers = numServers; strcpy(acellInfo->name, acellName); if (aservice) { - LOCK_GLOBAL_MUTEX tservice = afsconf_FindService(aservice); - UNLOCK_GLOBAL_MUTEX if (tservice < 0) { + LOCK_GLOBAL_MUTEX; + tservice = afsconf_FindService(aservice); + UNLOCK_GLOBAL_MUTEX; + if (tservice < 0) { return AFSCONF_NOTFOUND; /* service not found */ } for (i = 0; i < acellInfo->numServers; i++) { @@ -886,8 +904,9 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice, int ambig; char tbuffer[64]; - LOCK_GLOBAL_MUTEX if (adir) - afsconf_Check(adir); + LOCK_GLOBAL_MUTEX; + if (adir) + afsconf_Check(adir); if (acellName) { tcell = acellName; cnLen = strlen(tcell) + 1; @@ -897,7 +916,8 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice, } else { i = afsconf_GetLocalCell(adir, tbuffer, sizeof(tbuffer)); if (i) { - UNLOCK_GLOBAL_MUTEX return i; + UNLOCK_GLOBAL_MUTEX; + return i; } tcell = tbuffer; } @@ -905,7 +925,8 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice, bestce = (struct afsconf_entry *)0; ambig = 0; if (!adir) { - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* Look through the list of aliases */ @@ -936,20 +957,22 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice, if (aservice) { tservice = afsconf_FindService(aservice); if (tservice < 0) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; /* service not found */ + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_NOTFOUND; /* service not found */ } for (i = 0; i < acellInfo->numServers; i++) { acellInfo->hostAddr[i].sin_port = tservice; } } acellInfo->timeout = 0; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } else { - UNLOCK_GLOBAL_MUTEX + UNLOCK_GLOBAL_MUTEX; #ifdef AFS_AFSDB_ENV - return afsconf_GetAfsdbInfo(tcell, aservice, acellInfo); + return afsconf_GetAfsdbInfo(tcell, aservice, acellInfo); #else - return AFSCONF_NOTFOUND; + return AFSCONF_NOTFOUND; #endif /* AFS_AFSDB_ENV */ } } @@ -962,14 +985,14 @@ afsconf_GetLocalCell(register struct afsconf_dir *adir, char *aname, char *afscell_path; afs_int32 code = 0; - LOCK_GLOBAL_MUTEX - /* - * If a cell switch was specified in a command, then it should override the - * AFSCELL variable. If a cell was specified, then the afsconf_SawCell flag - * is set and the cell name in the adir structure is used. - * Read the AFSCELL var each time: in case it changes (unsetenv AFSCELL). - */ - if (!afsconf_SawCell && (afscell_path = getenv("AFSCELL"))) { + LOCK_GLOBAL_MUTEX; + /* + * If a cell switch was specified in a command, then it should override the + * AFSCELL variable. If a cell was specified, then the afsconf_SawCell flag + * is set and the cell name in the adir structure is used. + * Read the AFSCELL var each time: in case it changes (unsetenv AFSCELL). + */ + if (!afsconf_SawCell && (afscell_path = getenv("AFSCELL"))) { if (!afsconf_showcell) { fprintf(stderr, "Note: Operation is performed on cell %s\n", afscell_path); @@ -984,17 +1007,20 @@ afsconf_GetLocalCell(register struct afsconf_dir *adir, char *aname, code = AFSCONF_UNKNOWN; } - UNLOCK_GLOBAL_MUTEX return (code); + UNLOCK_GLOBAL_MUTEX; + return (code); } int afsconf_Close(struct afsconf_dir *adir) { - LOCK_GLOBAL_MUTEX afsconf_CloseInternal(adir); + LOCK_GLOBAL_MUTEX; + afsconf_CloseInternal(adir); if (adir->name) free(adir->name); free(adir); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } static int @@ -1060,9 +1086,9 @@ afsconf_IntGetKeys(struct afsconf_dir *adir) } #endif /* AFS_NT40_ENV */ - LOCK_GLOBAL_MUTEX - /* compute the key name and other setup */ - strcompose(tbuffer, 256, adir->name, "/", AFSDIR_KEY_FILE, NULL); + LOCK_GLOBAL_MUTEX; + /* compute the key name and other setup */ + strcompose(tbuffer, 256, adir->name, "/", AFSDIR_KEY_FILE, NULL); tstr = (struct afsconf_keys *)malloc(sizeof(struct afsconf_keys)); adir->keystr = tstr; @@ -1070,13 +1096,15 @@ afsconf_IntGetKeys(struct afsconf_dir *adir) fd = open(tbuffer, O_RDONLY); if (fd < 0) { tstr->nkeys = 0; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } code = read(fd, tstr, sizeof(struct afsconf_keys)); close(fd); if (code < sizeof(afs_int32)) { tstr->nkeys = 0; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* convert key structure to host order */ @@ -1084,7 +1112,8 @@ afsconf_IntGetKeys(struct afsconf_dir *adir) for (fd = 0; fd < tstr->nkeys; fd++) tstr->key[fd].kvno = ntohl(tstr->key[fd].kvno); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* get keys structure */ @@ -1093,12 +1122,15 @@ afsconf_GetKeys(struct afsconf_dir *adir, struct afsconf_keys *astr) { register afs_int32 code; - LOCK_GLOBAL_MUTEX code = afsconf_Check(adir); + LOCK_GLOBAL_MUTEX; + code = afsconf_Check(adir); if (code) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_FAILURE; } memcpy(astr, adir->keystr, sizeof(struct afsconf_keys)); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* get latest key */ @@ -1112,9 +1144,11 @@ afsconf_GetLatestKey(struct afsconf_dir * adir, afs_int32 * avno, char *akey) struct afsconf_key *bestk; register afs_int32 code; - LOCK_GLOBAL_MUTEX code = afsconf_Check(adir); + LOCK_GLOBAL_MUTEX; + code = afsconf_Check(adir); if (code) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_FAILURE; } maxa = adir->keystr->nkeys; @@ -1133,9 +1167,11 @@ afsconf_GetLatestKey(struct afsconf_dir * adir, afs_int32 * avno, char *akey) memcpy(akey, bestk->key, 8); /* copy out latest key */ if (avno) *avno = bestk->kvno; /* and kvno to caller */ - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } - UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; /* didn't find any keys */ + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_NOTFOUND; /* didn't find any keys */ } /* get a particular key */ @@ -1146,20 +1182,24 @@ afsconf_GetKey(struct afsconf_dir *adir, afs_int32 avno, char *akey) register struct afsconf_key *tk; register afs_int32 code; - LOCK_GLOBAL_MUTEX code = afsconf_Check(adir); + LOCK_GLOBAL_MUTEX; + code = afsconf_Check(adir); if (code) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_FAILURE; } maxa = adir->keystr->nkeys; for (tk = adir->keystr->key, i = 0; i < maxa; i++, tk++) { if (tk->kvno == avno) { memcpy(akey, tk->key, 8); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } } - UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_NOTFOUND; } /* save the key structure in the appropriate file */ @@ -1202,18 +1242,21 @@ afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, char akey[8], register afs_int32 i; int foundSlot; - LOCK_GLOBAL_MUTEX tk = adir->keystr; + LOCK_GLOBAL_MUTEX; + tk = adir->keystr; if (akvno != 999) { if (akvno < 0 || akvno > 255) { - UNLOCK_GLOBAL_MUTEX return ERANGE; + UNLOCK_GLOBAL_MUTEX; + return ERANGE; } } foundSlot = 0; for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) { if (tkey->kvno == akvno) { if (!overwrite) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_KEYINUSE; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_KEYINUSE; } foundSlot = 1; break; @@ -1221,7 +1264,8 @@ afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, char akey[8], } if (!foundSlot) { if (tk->nkeys >= AFSCONF_MAXKEYS) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_FULL; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_FULL; } tkey = &tk->key[tk->nkeys++]; } @@ -1229,7 +1273,8 @@ afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno, char akey[8], memcpy(tkey->key, akey, 8); i = SaveKeys(adir); afsconf_Touch(adir); - UNLOCK_GLOBAL_MUTEX return i; + UNLOCK_GLOBAL_MUTEX; + return i; } /* this proc works by sliding the other guys down, rather than using a funny @@ -1243,7 +1288,8 @@ afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno) register int i; int foundFlag = 0; - LOCK_GLOBAL_MUTEX tk = adir->keystr; + LOCK_GLOBAL_MUTEX; + tk = adir->keystr; for (i = 0, tkey = tk->key; i < tk->nkeys; i++, tkey++) { if (tkey->kvno == akvno) { @@ -1252,7 +1298,8 @@ afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno) } } if (!foundFlag) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_NOTFOUND; } /* otherwise slide the others down. i and tkey point at the guy to delete */ @@ -1263,5 +1310,6 @@ afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno) tk->nkeys--; i = SaveKeys(adir); afsconf_Touch(adir); - UNLOCK_GLOBAL_MUTEX return i; + UNLOCK_GLOBAL_MUTEX; + return i; } diff --git a/src/auth/ktc.c b/src/auth/ktc.c index d1c22b58a4..531ee60b80 100644 --- a/src/auth/ktc.c +++ b/src/auth/ktc.c @@ -424,9 +424,9 @@ ktc_SetToken(aserver, atoken, aclient, flags) { int ncode, ocode; - LOCK_GLOBAL_MUTEX + LOCK_GLOBAL_MUTEX; #ifdef AFS_KERBEROS_ENV - if (!lcell[0]) + if (!lcell[0]) ktc_LocalCell(); if ( /*!strcmp(aclient->cell, lcell) && this would only store local creds */ @@ -453,7 +453,8 @@ ktc_SetToken(aserver, atoken, aclient, flags) } afs_tf_close(); #ifdef NO_AFS_CLIENT - UNLOCK_GLOBAL_MUTEX return ncode; + UNLOCK_GLOBAL_MUTEX; + return ncode; #endif /* NO_AFS_CLIENT */ } #endif @@ -466,7 +467,8 @@ ktc_SetToken(aserver, atoken, aclient, flags) } else ocode = 0; if (ncode && ocode) { - UNLOCK_GLOBAL_MUTEX if (ocode == -1) + UNLOCK_GLOBAL_MUTEX; + if (ocode == -1) ocode = errno; else if (ocode == KTC_PIOCTLFAIL) ocode = errno; @@ -479,7 +481,8 @@ ktc_SetToken(aserver, atoken, aclient, flags) return KTC_PIOCTLFAIL; } #endif /* NO_AFS_CLIENT */ - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* get token, given server we need and token buffer. aclient will eventually @@ -502,9 +505,9 @@ ktc_GetToken(aserver, atoken, atokenLen, aclient) int tktLen; /* server ticket length */ char found = 0; - LOCK_GLOBAL_MUTEX + LOCK_GLOBAL_MUTEX; #ifndef NO_AFS_CLIENT - TRY_KERNEL(KTC_GETTOKEN_OP, aserver, aclient, atoken, atokenLen); + TRY_KERNEL(KTC_GETTOKEN_OP, aserver, aclient, atoken, atokenLen); #endif /* NO_AFS_CLIENT */ #ifdef AFS_KERBEROS_ENV @@ -527,7 +530,8 @@ ktc_GetToken(aserver, atoken, atokenLen, aclient) min(atokenLen, sizeof(struct ktc_token))); if (aclient) *aclient = local_tokens[i].client; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } #ifdef AFS_KERBEROS_ENV if (!afs_tf_init(ktc_tkt_string(), R_TKT_FIL)) { @@ -557,13 +561,15 @@ ktc_GetToken(aserver, atoken, atokenLen, aclient) min(atokenLen, sizeof(struct ktc_token))); afs_tf_close(); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } } } afs_tf_close(); #endif - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } #ifndef NO_AFS_CLIENT for (index = 0; index < 200; index++) { /* sanity check in case pioctl fails */ @@ -577,7 +583,8 @@ ktc_GetToken(aserver, atoken, atokenLen, aclient) if (code) { /* failed to retrieve specified token */ if (code < 0 && errno == EDOM) { - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } } else { /* token retrieved; parse buffer */ @@ -595,7 +602,8 @@ ktc_GetToken(aserver, atoken, atokenLen, aclient) /* get size of clear token and verify */ memcpy(&temp, tp, sizeof(afs_int32)); if (temp != sizeof(struct ClearToken)) { - UNLOCK_GLOBAL_MUTEX return KTC_ERROR; + UNLOCK_GLOBAL_MUTEX; + return KTC_ERROR; } tp += sizeof(afs_int32); @@ -618,7 +626,8 @@ ktc_GetToken(aserver, atoken, atokenLen, aclient) maxLen = atokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN; if (maxLen < tktLen) { - UNLOCK_GLOBAL_MUTEX return KTC_TOOBIG; + UNLOCK_GLOBAL_MUTEX; + return KTC_TOOBIG; } /* set return values */ @@ -645,13 +654,15 @@ ktc_GetToken(aserver, atoken, atokenLen, aclient) sprintf(aclient->name, "Unix UID %d", ct.ViceId); } } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } } } #endif /* NO_AFS_CLIENT */ - UNLOCK_GLOBAL_MUTEX if ((code < 0) && (errno == EINVAL)) + UNLOCK_GLOBAL_MUTEX; + if ((code < 0) && (errno == EINVAL)) return KTC_NOPIOCTL; return KTC_PIOCTLFAIL; /* probable cause */ } @@ -666,10 +677,12 @@ ktc_ForgetToken(aserver) { int rc; - LOCK_GLOBAL_MUTEX TRY_KERNEL(KTC_FORGETTOKEN_OP, aserver, 0, 0, 0); + LOCK_GLOBAL_MUTEX; + TRY_KERNEL(KTC_FORGETTOKEN_OP, aserver, 0, 0, 0); rc = ktc_ForgetAllTokens(); /* bogus, but better */ - UNLOCK_GLOBAL_MUTEX return rc; + UNLOCK_GLOBAL_MUTEX; + return rc; } #endif /* NO_AFS_CLIENT */ @@ -689,9 +702,9 @@ ktc_ListTokens(aprevIndex, aindex, aserver) memset(tbuffer, 0, sizeof(tbuffer)); - LOCK_GLOBAL_MUTEX + LOCK_GLOBAL_MUTEX; #ifndef NO_AFS_CLIENT - TRY_KERNEL(KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0); + TRY_KERNEL(KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0); #endif /* NO_AFS_CLIENT */ index = aprevIndex; @@ -708,20 +721,23 @@ ktc_ListTokens(aprevIndex, aindex, aserver) if (afs_tf_init(ktc_tkt_string(), R_TKT_FIL) || afs_tf_get_pname(tbuffer) || afs_tf_get_pinst(tbuffer)) { afs_tf_close(); - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } for (i = 214; i < index; i++) { if (afs_tf_get_cred(&cprincipal, &ctoken)) { afs_tf_close(); - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } } again: if (afs_tf_get_cred(&cprincipal, &ctoken)) { afs_tf_close(); - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } index++; @@ -743,7 +759,8 @@ ktc_ListTokens(aprevIndex, aindex, aserver) *aserver = cprincipal; *aindex = index; afs_tf_close(); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } #endif @@ -753,15 +770,16 @@ ktc_ListTokens(aprevIndex, aindex, aserver) if (local_tokens[index - 123].valid) { *aserver = local_tokens[index - 123].server; *aindex = index + 1; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } index++; } - UNLOCK_GLOBAL_MUTEX + UNLOCK_GLOBAL_MUTEX; #ifdef AFS_KERBEROS_ENV - return ktc_ListTokens(214, aindex, aserver); + return ktc_ListTokens(214, aindex, aserver); #else - return KTC_NOENT; + return KTC_NOENT; #endif } @@ -776,9 +794,11 @@ ktc_ListTokens(aprevIndex, aindex, aserver) if (index < 123) { int rc; rc = ktc_ListTokens(123, aindex, aserver); - UNLOCK_GLOBAL_MUTEX return rc; + UNLOCK_GLOBAL_MUTEX; + return rc; } else { - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } } if (code == 0) @@ -787,7 +807,8 @@ ktc_ListTokens(aprevIndex, aindex, aserver) index++; } if (code < 0) { - UNLOCK_GLOBAL_MUTEX if (errno == EINVAL) + UNLOCK_GLOBAL_MUTEX; + if (errno == EINVAL) return KTC_NOPIOCTL; return KTC_PIOCTLFAIL; } @@ -803,7 +824,8 @@ ktc_ListTokens(aprevIndex, aindex, aserver) tp += temp; /* skip ticket for now */ memcpy(&temp, tp, sizeof(afs_int32)); /* get size of clear token */ if (temp != sizeof(struct ClearToken)) { - UNLOCK_GLOBAL_MUTEX return KTC_ERROR; + UNLOCK_GLOBAL_MUTEX; + return KTC_ERROR; } tp += sizeof(afs_int32); /* skip length */ tp += temp; /* skip clear token itself */ @@ -813,7 +835,8 @@ ktc_ListTokens(aprevIndex, aindex, aserver) aserver->instance[0] = 0; strcpy(aserver->name, "afs"); #endif /* NO_AFS_CLIENT */ - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* discard all tokens from this user's cache */ @@ -854,9 +877,9 @@ ktc_ForgetAllTokens() { int ncode, ocode; - LOCK_GLOBAL_MUTEX + LOCK_GLOBAL_MUTEX; #ifdef AFS_KERBEROS_ENV - (void) afs_tf_dest_tkt(); + (void)afs_tf_dest_tkt(); #endif ncode = NewForgetAll(); @@ -866,11 +889,13 @@ ktc_ForgetAllTokens() ocode = errno; else if (ocode == KTC_PIOCTLFAIL) ocode = errno; - UNLOCK_GLOBAL_MUTEX if (ocode == EINVAL) + UNLOCK_GLOBAL_MUTEX; + if (ocode == EINVAL) return KTC_NOPIOCTL; return KTC_PIOCTLFAIL; } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* ktc_OldPioctl - returns a boolean true if the kernel supports only the old @@ -879,14 +904,15 @@ ktc_ForgetAllTokens() ktc_OldPioctl() { int rc; - LOCK_GLOBAL_MUTEX + LOCK_GLOBAL_MUTEX; #ifdef KERNEL_KTC_COMPAT - CHECK_KERNEL; + CHECK_KERNEL; rc = (kernelKTC != 1); /* old style interface */ #else - rc = 1; + rc = 1; #endif - UNLOCK_GLOBAL_MUTEX return rc; + UNLOCK_GLOBAL_MUTEX; + return rc; } @@ -1415,7 +1441,8 @@ ktc_tkt_string() { char *env; - LOCK_GLOBAL_MUTEX if (!*krb_ticket_string) { + LOCK_GLOBAL_MUTEX; + if (!*krb_ticket_string) { if (env = getenv("KRBTKFILE")) { (void)strncpy(krb_ticket_string, env, sizeof(krb_ticket_string) - 1); @@ -1426,7 +1453,8 @@ ktc_tkt_string() (void)sprintf(krb_ticket_string, "%s%d", TKT_ROOT, getuid()); } } - UNLOCK_GLOBAL_MUTEX return krb_ticket_string; + UNLOCK_GLOBAL_MUTEX; + return krb_ticket_string; } /* @@ -1445,10 +1473,11 @@ ktc_set_tkt_string(val) char *val; { - LOCK_GLOBAL_MUTEX(void) strncpy(krb_ticket_string, val, - sizeof(krb_ticket_string) - 1); + LOCK_GLOBAL_MUTEX; + (void)strncpy(krb_ticket_string, val, sizeof(krb_ticket_string) - 1); krb_ticket_string[sizeof(krb_ticket_string) - 1] = '\0'; - UNLOCK_GLOBAL_MUTEX return; + UNLOCK_GLOBAL_MUTEX; + return; } /* @@ -1615,7 +1644,8 @@ ktc_newpag() int numenv; char **newenv, **senv, **denv; - LOCK_GLOBAL_MUTEX if (stat("/ticket", &sbuf) == -1) { + LOCK_GLOBAL_MUTEX; + if (stat("/ticket", &sbuf) == -1) { prefix = "/tmp/tkt"; } @@ -1641,7 +1671,8 @@ ktc_newpag() strcat(*denv, fname); *++denv = 0; environ = newenv; -UNLOCK_GLOBAL_MUTEX} + UNLOCK_GLOBAL_MUTEX; +} /* * BLETCH! We have to invoke the entire afsconf package just to diff --git a/src/auth/ktc_nt.c b/src/auth/ktc_nt.c index fd1948c94b..10bd995ec9 100644 --- a/src/auth/ktc_nt.c +++ b/src/auth/ktc_nt.c @@ -49,7 +49,7 @@ static char AFSConfigKeyName[] = "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters"; static char AFSGlobalKTCMutexName[] = "Global\\AFS_KTC_Mutex"; -static char AFSKTCMutexName[] = "AFS_KTC_Mutex"; +static char AFSKTCMutexName[] = "AFS_KTC_Mutex"; /* * Support for RPC's to send and receive session keys @@ -351,35 +351,32 @@ ktc_SetToken(struct ktc_principal *server, struct ktc_token *token, #ifndef AFS_WIN95_ENV ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName); - if ( ktcMutex == NULL ) - return KTC_PIOCTLFAIL; - if ( GetLastError() == ERROR_ALREADY_EXISTS ) { - if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) { - CloseHandle(ktcMutex); - return KTC_PIOCTLFAIL; - } + if (ktcMutex == NULL) + return KTC_PIOCTLFAIL; + if (GetLastError() == ERROR_ALREADY_EXISTS) { + if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) { + CloseHandle(ktcMutex); + return KTC_PIOCTLFAIL; + } } /* RPC to send session key */ status = send_key(uuid, token->sessionKey.data); if (status != RPC_S_OK) { - if (status == 1) - strcpy(rpcErr, "RPC failure in AFS gateway"); - else - DceErrorInqText(status, rpcErr); - if (status == RPC_S_SERVER_UNAVAILABLE || - status == EPT_S_NOT_REGISTERED) - { - ReleaseMutex(ktcMutex); - CloseHandle(ktcMutex); - return KTC_NOCMRPC; - } - else - { - ReleaseMutex(ktcMutex); - CloseHandle(ktcMutex); - return KTC_RPC; - } + if (status == 1) + strcpy(rpcErr, "RPC failure in AFS gateway"); + else + DceErrorInqText(status, rpcErr); + if (status == RPC_S_SERVER_UNAVAILABLE || + status == EPT_S_NOT_REGISTERED) { + ReleaseMutex(ktcMutex); + CloseHandle(ktcMutex); + return KTC_NOCMRPC; + } else { + ReleaseMutex(ktcMutex); + CloseHandle(ktcMutex); + return KTC_RPC; + } } #endif /* AFS_WIN95_ENV */ @@ -397,17 +394,17 @@ ktc_SetToken(struct ktc_principal *server, struct ktc_token *token, #endif /* AFS_WIN95_ENV */ if (code) { - if (code == -1) { - if (errno == ESRCH) - return KTC_NOCELL; - else if (errno == ENODEV) - return KTC_NOCM; - else if (errno == EINVAL) - return KTC_INVAL; - else - return KTC_PIOCTLFAIL; - } else - return KTC_PIOCTLFAIL; + if (code == -1) { + if (errno == ESRCH) + return KTC_NOCELL; + else if (errno == ENODEV) + return KTC_NOCM; + else if (errno == EINVAL) + return KTC_INVAL; + else + return KTC_PIOCTLFAIL; + } else + return KTC_PIOCTLFAIL; } return 0; @@ -454,40 +451,39 @@ ktc_GetToken(struct ktc_principal *server, struct ktc_token *token, iob.out = tbuffer; iob.out_size = sizeof(tbuffer); -#ifndef AFS_WIN95_ENV +#ifndef AFS_WIN95_ENV ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName); - if ( ktcMutex == NULL ) - return KTC_PIOCTLFAIL; - if ( GetLastError() == ERROR_ALREADY_EXISTS ) { - if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) { - CloseHandle(ktcMutex); - return KTC_PIOCTLFAIL; - } + if (ktcMutex == NULL) + return KTC_PIOCTLFAIL; + if (GetLastError() == ERROR_ALREADY_EXISTS) { + if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) { + CloseHandle(ktcMutex); + return KTC_PIOCTLFAIL; + } } #endif /* AFS_WIN95_ENV */ code = pioctl(0, VIOCNEWGETTOK, &iob, 0); if (code) { #ifndef AFS_WIN95_ENV - ReleaseMutex(ktcMutex); - CloseHandle(ktcMutex); + ReleaseMutex(ktcMutex); + CloseHandle(ktcMutex); #endif /* AFS_WIN95_ENV */ - if (code == -1) { - if (errno == ESRCH) - return KTC_NOCELL; - else if (errno == ENODEV) - return KTC_NOCM; - else if (errno == EINVAL) - return KTC_INVAL; - else if (errno == EDOM) - return KTC_NOENT; - else - return KTC_PIOCTLFAIL; - } else - return KTC_PIOCTLFAIL; - } - -#ifndef AFS_WIN95_ENV + if (code == -1) { + if (errno == ESRCH) + return KTC_NOCELL; + else if (errno == ENODEV) + return KTC_NOCM; + else if (errno == EINVAL) + return KTC_INVAL; + else if (errno == EDOM) + return KTC_NOENT; + else + return KTC_PIOCTLFAIL; + } else + return KTC_PIOCTLFAIL; + } +#ifndef AFS_WIN95_ENV /* get rid of RPC for win95 build */ /* RPC to receive session key */ status = receive_key(uuid, token->sessionKey.data); @@ -496,15 +492,15 @@ ktc_GetToken(struct ktc_principal *server, struct ktc_token *token, CloseHandle(ktcMutex); if (status != RPC_S_OK) { - if (status == 1) - strcpy(rpcErr, "RPC failure in AFS gateway"); - else - DceErrorInqText(status, rpcErr); - if (status == RPC_S_SERVER_UNAVAILABLE - || status == EPT_S_NOT_REGISTERED) - return KTC_NOCMRPC; - else - return KTC_RPC; + if (status == 1) + strcpy(rpcErr, "RPC failure in AFS gateway"); + else + DceErrorInqText(status, rpcErr); + if (status == RPC_S_SERVER_UNAVAILABLE + || status == EPT_S_NOT_REGISTERED) + return KTC_NOCMRPC; + else + return KTC_RPC; } #endif /* AFS_WIN95_ENV */ @@ -539,12 +535,12 @@ ktc_GetToken(struct ktc_principal *server, struct ktc_token *token, /* user name is here */ /* check that ticket will fit - * this compares the size of the ktc_token allocated by the app - * which might be smaller than the current definition of MAXKTCTICKETLEN - */ - maxLen = tokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN; - if (maxLen < ticketLen) - return KTC_TOOBIG; + * this compares the size of the ktc_token allocated by the app + * which might be smaller than the current definition of MAXKTCTICKETLEN + */ + maxLen = tokenLen - sizeof(struct ktc_token) + MAXKTCTICKETLEN; + if (maxLen < ticketLen) + return KTC_TOOBIG; /* set return values */ memcpy(token->ticket, ticketP, ticketLen); @@ -580,15 +576,15 @@ ktc_ListTokens(int cellNum, int *cellNumP, struct ktc_principal *server) int code; HANDLE ktcMutex = NULL; -#ifndef AFS_WIN95_ENV +#ifndef AFS_WIN95_ENV ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName); - if ( ktcMutex == NULL ) - return KTC_PIOCTLFAIL; - if ( GetLastError() == ERROR_ALREADY_EXISTS ) { - if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) { - CloseHandle(ktcMutex); - return KTC_PIOCTLFAIL; - } + if (ktcMutex == NULL) + return KTC_PIOCTLFAIL; + if (GetLastError() == ERROR_ALREADY_EXISTS) { + if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) { + CloseHandle(ktcMutex); + return KTC_PIOCTLFAIL; + } } #endif /* AFS_WIN95_ENV */ @@ -607,8 +603,8 @@ ktc_ListTokens(int cellNum, int *cellNumP, struct ktc_principal *server) code = pioctl(0, VIOCGETTOK, &iob, 0); #ifndef AFS_WIN95_ENV - ReleaseMutex(ktcMutex); - CloseHandle(ktcMutex); + ReleaseMutex(ktcMutex); + CloseHandle(ktcMutex); #endif /* AFS_WIN95_ENV */ if (code) { @@ -675,16 +671,15 @@ ktc_ForgetToken(struct ktc_principal *server) if (strcmp(server->name, "afs")) { return ForgetOneLocalToken(server); } - -#ifndef AFS_WIN95_ENV +#ifndef AFS_WIN95_ENV ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName); - if ( ktcMutex == NULL ) - return KTC_PIOCTLFAIL; - if ( GetLastError() == ERROR_ALREADY_EXISTS ) { - if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) { - CloseHandle(ktcMutex); - return KTC_PIOCTLFAIL; - } + if (ktcMutex == NULL) + return KTC_PIOCTLFAIL; + if (GetLastError() == ERROR_ALREADY_EXISTS) { + if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) { + CloseHandle(ktcMutex); + return KTC_PIOCTLFAIL; + } } #endif /* AFS_WIN95_ENV */ @@ -731,15 +726,15 @@ ktc_ForgetAllTokens() (void)ForgetLocalTokens(); -#ifndef AFS_WIN95_ENV +#ifndef AFS_WIN95_ENV ktcMutex = CreateMutex(NULL, TRUE, AFSGlobalKTCMutexName); - if ( ktcMutex == NULL ) - return KTC_PIOCTLFAIL; - if ( GetLastError() == ERROR_ALREADY_EXISTS ) { - if ( WaitForSingleObject( ktcMutex, INFINITE) != WAIT_OBJECT_0 ) { - CloseHandle(ktcMutex); - return KTC_PIOCTLFAIL; - } + if (ktcMutex == NULL) + return KTC_PIOCTLFAIL; + if (GetLastError() == ERROR_ALREADY_EXISTS) { + if (WaitForSingleObject(ktcMutex, INFINITE) != WAIT_OBJECT_0) { + CloseHandle(ktcMutex); + return KTC_PIOCTLFAIL; + } } #endif /* AFS_WIN95_ENV */ @@ -790,7 +785,8 @@ SetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, int found = -1; int i; - LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) + LOCK_GLOBAL_MUTEX; + for (i = 0; i < MAXLOCALTOKENS; i++) if (local_tokens[i].valid) { if ((strcmp(local_tokens[i].server.name, aserver->name) == 0) && (strcmp(local_tokens[i].server.instance, aserver->instance) @@ -802,7 +798,8 @@ SetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, } else if (found == -1) found = i; /* remember empty slot but keep looking for a match */ if (found == -1) { - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } memcpy(&local_tokens[found].token, atoken, sizeof(struct ktc_token)); memcpy(&local_tokens[found].server, aserver, @@ -810,7 +807,8 @@ SetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, memcpy(&local_tokens[found].client, aclient, sizeof(struct ktc_principal)); local_tokens[found].valid = 1; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } @@ -820,7 +818,8 @@ GetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, { int i; - LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) + LOCK_GLOBAL_MUTEX; + for (i = 0; i < MAXLOCALTOKENS; i++) if (local_tokens[i].valid && (strcmp(local_tokens[i].server.name, aserver->name) == 0) && (strcmp(local_tokens[i].server.instance, aserver->instance) == @@ -830,9 +829,11 @@ GetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken, min(atokenLen, sizeof(struct ktc_token))); memcpy(aclient, &local_tokens[i].client, sizeof(struct ktc_principal)); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } @@ -841,12 +842,14 @@ ForgetLocalTokens() { int i; - LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) { + LOCK_GLOBAL_MUTEX; + for (i = 0; i < MAXLOCALTOKENS; i++) { local_tokens[i].valid = 0; memset(&local_tokens[i].token.sessionKey, 0, sizeof(struct ktc_encryptionKey)); } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } @@ -855,7 +858,8 @@ ForgetOneLocalToken(struct ktc_principal *aserver) { int i; - LOCK_GLOBAL_MUTEX for (i = 0; i < MAXLOCALTOKENS; i++) { + LOCK_GLOBAL_MUTEX; + for (i = 0; i < MAXLOCALTOKENS; i++) { if (local_tokens[i].valid && (strcmp(local_tokens[i].server.name, aserver->name) == 0) && (strcmp(local_tokens[i].server.instance, aserver->instance) == @@ -864,8 +868,10 @@ ForgetOneLocalToken(struct ktc_principal *aserver) local_tokens[i].valid = 0; memset(&local_tokens[i].token.sessionKey, 0, sizeof(struct ktc_encryptionKey)); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } } - UNLOCK_GLOBAL_MUTEX return KTC_NOENT; + UNLOCK_GLOBAL_MUTEX; + return KTC_NOENT; } diff --git a/src/auth/userok.c b/src/auth/userok.c index 7b7abd46ff..09da2e0708 100644 --- a/src/auth/userok.c +++ b/src/auth/userok.c @@ -54,9 +54,10 @@ afsconf_CheckAuth(adir, acall) register struct rx_call *acall; register struct afsconf_dir *adir; { - LOCK_GLOBAL_MUTEX return ((afsconf_SuperUser(adir, acall, NULL) == 0) ? - 10029 : 0); -UNLOCK_GLOBAL_MUTEX} + LOCK_GLOBAL_MUTEX; + return ((afsconf_SuperUser(adir, acall, NULL) == 0) ? 10029 : 0); + UNLOCK_GLOBAL_MUTEX; +} #endif /* !defined(UKERNEL) */ static int @@ -77,8 +78,10 @@ afsconf_GetNoAuthFlag(adir) { int rc; - LOCK_GLOBAL_MUTEX rc = GetNoAuthFlag(adir); - UNLOCK_GLOBAL_MUTEX return rc; + LOCK_GLOBAL_MUTEX; + rc = GetNoAuthFlag(adir); + UNLOCK_GLOBAL_MUTEX; + return rc; } void @@ -88,7 +91,8 @@ afsconf_SetNoAuthFlag(adir, aflag) { register afs_int32 code; - LOCK_GLOBAL_MUTEX if (aflag == 0) { + LOCK_GLOBAL_MUTEX; + if (aflag == 0) { /* turn off noauth flag */ code = (unlink(AFSDIR_SERVER_NOAUTH_FILEPATH) ? errno : 0); osi_audit(NoAuthDisableEvent, code, AUD_END); @@ -103,7 +107,8 @@ afsconf_SetNoAuthFlag(adir, aflag) } else osi_audit(NoAuthEnableEvent, errno, AUD_END); } -UNLOCK_GLOBAL_MUTEX} + UNLOCK_GLOBAL_MUTEX; +} /* deletes a user from the UserList file */ int @@ -122,8 +127,9 @@ afsconf_DeleteUser(adir, auser) struct stat tstat; register afs_int32 code; - LOCK_GLOBAL_MUTEX strcompose(tbuffer, sizeof tbuffer, adir->name, "/", - AFSDIR_ULIST_FILE, NULL); + LOCK_GLOBAL_MUTEX; + strcompose(tbuffer, sizeof tbuffer, adir->name, "/", + AFSDIR_ULIST_FILE, NULL); #ifndef AFS_NT40_ENV { /* @@ -140,18 +146,21 @@ afsconf_DeleteUser(adir, auser) #endif /* AFS_NT40_ENV */ tf = fopen(tbuffer, "r"); if (!tf) { - UNLOCK_GLOBAL_MUTEX return -1; + UNLOCK_GLOBAL_MUTEX; + return -1; } code = stat(tbuffer, &tstat); if (code < 0) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } strcpy(nbuffer, tbuffer); strcat(nbuffer, ".NXX"); nf = fopen(nbuffer, "w+"); if (!nf) { fclose(tf); - UNLOCK_GLOBAL_MUTEX return EIO; + UNLOCK_GLOBAL_MUTEX; + return EIO; } flag = 0; found = 0; @@ -185,8 +194,9 @@ afsconf_DeleteUser(adir, auser) unlink(nbuffer); /* finally, decide what to return to the caller */ - UNLOCK_GLOBAL_MUTEX if (flag) - return EIO; /* something mysterious went wrong */ + UNLOCK_GLOBAL_MUTEX; + if (flag) + return EIO; /* something mysterious went wrong */ if (!found) return ENOENT; /* entry wasn't found, no changes made */ return 0; /* everything was fine */ @@ -207,11 +217,13 @@ afsconf_GetNthUser(adir, an, abuffer, abufferLen) register int flag; register afs_int32 code; - LOCK_GLOBAL_MUTEX strcompose(tbuffer, sizeof tbuffer, adir->name, "/", - AFSDIR_ULIST_FILE, NULL); + LOCK_GLOBAL_MUTEX; + strcompose(tbuffer, sizeof tbuffer, adir->name, "/", + AFSDIR_ULIST_FILE, NULL); tf = fopen(tbuffer, "r"); if (!tf) { - UNLOCK_GLOBAL_MUTEX return 1; + UNLOCK_GLOBAL_MUTEX; + return 1; } flag = 1; while (1) { @@ -228,7 +240,8 @@ afsconf_GetNthUser(adir, an, abuffer, abufferLen) if (flag == 0) strcpy(abuffer, tname); fclose(tf); - UNLOCK_GLOBAL_MUTEX return flag; + UNLOCK_GLOBAL_MUTEX; + return flag; } /* returns true iff user is in the UserList file */ @@ -275,15 +288,18 @@ afsconf_AddUser(adir, aname) register afs_int32 code; char tbuffer[256]; - LOCK_GLOBAL_MUTEX if (FindUser(adir, aname)) { - UNLOCK_GLOBAL_MUTEX return EEXIST; /* already in the list */ + LOCK_GLOBAL_MUTEX; + if (FindUser(adir, aname)) { + UNLOCK_GLOBAL_MUTEX; + return EEXIST; /* already in the list */ } strcompose(tbuffer, sizeof tbuffer, adir->name, "/", AFSDIR_ULIST_FILE, NULL); tf = fopen(tbuffer, "a+"); if (!tf) { - UNLOCK_GLOBAL_MUTEX return EIO; + UNLOCK_GLOBAL_MUTEX; + return EIO; } fprintf(tf, "%s\n", aname); code = 0; @@ -291,7 +307,8 @@ afsconf_AddUser(adir, aname) code = EIO; if (fclose(tf)) code = EIO; - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } /* special CompFindUser routine that builds up a princ and then @@ -352,23 +369,28 @@ afsconf_SuperUser(adir, acall, namep) register afs_int32 code; int flag; - LOCK_GLOBAL_MUTEX if (!adir) { - UNLOCK_GLOBAL_MUTEX return 0; + LOCK_GLOBAL_MUTEX; + if (!adir) { + UNLOCK_GLOBAL_MUTEX; + return 0; } if (afsconf_GetNoAuthFlag(adir)) { if (namep) strcpy(namep, ""); - UNLOCK_GLOBAL_MUTEX return 1; + UNLOCK_GLOBAL_MUTEX; + return 1; } tconn = rx_ConnectionOf(acall); code = rx_SecurityClassOf(tconn); if (code == 0) { - UNLOCK_GLOBAL_MUTEX return 0; /* not authenticated at all, answer is no */ + UNLOCK_GLOBAL_MUTEX; + return 0; /* not authenticated at all, answer is no */ } else if (code == 1) { /* bcrypt tokens */ - UNLOCK_GLOBAL_MUTEX return 0; /* not supported any longer */ + UNLOCK_GLOBAL_MUTEX; + return 0; /* not supported any longer */ } else if (code == 2) { char tname[MAXKTCNAMELEN]; /* authentication from ticket */ char tinst[MAXKTCNAMELEN]; @@ -388,7 +410,8 @@ afsconf_SuperUser(adir, acall, namep) rxkad_GetServerInfo(acall->conn, NULL, &exp, tname, tinst, tcell, NULL); if (code) { - UNLOCK_GLOBAL_MUTEX return 0; /* bogus connection/other error */ + UNLOCK_GLOBAL_MUTEX; + return 0; /* bogus connection/other error */ } /* don't bother checking anything else if tix have expired */ @@ -397,7 +420,8 @@ afsconf_SuperUser(adir, acall, namep) #else if (exp < FT_ApproxTime()) { #endif - UNLOCK_GLOBAL_MUTEX return 0; /* expired tix */ + UNLOCK_GLOBAL_MUTEX; + return 0; /* expired tix */ } /* generate lowercased version of cell name */ @@ -467,8 +491,10 @@ afsconf_SuperUser(adir, acall, namep) if (namep) strcpy(namep, uname); - UNLOCK_GLOBAL_MUTEX return flag; + UNLOCK_GLOBAL_MUTEX; + return flag; } else { /* some other auth type */ - UNLOCK_GLOBAL_MUTEX return 0; /* mysterious, just say no */ + UNLOCK_GLOBAL_MUTEX; + return 0; /* mysterious, just say no */ } } diff --git a/src/auth/writeconfig.c b/src/auth/writeconfig.c index eca66162b9..5116f32f5f 100644 --- a/src/auth/writeconfig.c +++ b/src/auth/writeconfig.c @@ -115,35 +115,40 @@ afsconf_SetExtendedCellInfo(adir, apath, acellInfo, clones) register FILE *tf; register afs_int32 i; - LOCK_GLOBAL_MUTEX - /* write ThisCell file */ - strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL); + LOCK_GLOBAL_MUTEX; + /* write ThisCell file */ + strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, NULL); fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0666); if (fd < 0) { - UNLOCK_GLOBAL_MUTEX return errno; + UNLOCK_GLOBAL_MUTEX; + return errno; } i = strlen(acellInfo->name); code = write(fd, acellInfo->name, i); if (code != i) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_FAILURE; } if (close(fd) < 0) { - UNLOCK_GLOBAL_MUTEX return errno; + UNLOCK_GLOBAL_MUTEX; + return errno; } /* make sure we have both name and address for each host, looking up other * if need be */ code = VerifyEntries(acellInfo); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } /* write CellServDB */ strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, NULL); tf = fopen(tbuffer, "w"); if (!tf) { - UNLOCK_GLOBAL_MUTEX return AFSCONF_NOTFOUND; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_NOTFOUND; } fprintf(tf, ">%s #Cell name\n", acellInfo->name); for (i = 0; i < acellInfo->numServers; i++) { @@ -162,7 +167,8 @@ afsconf_SetExtendedCellInfo(adir, apath, acellInfo, clones) } if (ferror(tf)) { fclose(tf); - UNLOCK_GLOBAL_MUTEX return AFSCONF_FAILURE; + UNLOCK_GLOBAL_MUTEX; + return AFSCONF_FAILURE; } code = fclose(tf); @@ -173,7 +179,8 @@ afsconf_SetExtendedCellInfo(adir, apath, acellInfo, clones) if (adir) adir->timeRead = 0; - UNLOCK_GLOBAL_MUTEX if (code == EOF) + UNLOCK_GLOBAL_MUTEX; + if (code == EOF) return AFSCONF_FAILURE; return 0; } diff --git a/src/comerr/error_msg.c b/src/comerr/error_msg.c index 3c4e650b9e..ac8855bbe0 100644 --- a/src/comerr/error_msg.c +++ b/src/comerr/error_msg.c @@ -54,9 +54,11 @@ et_mutex_once(void) } #define LOCK_ET_LIST \ - (et_list_done || pthread_once(&et_list_once, et_mutex_once)); \ - assert(pthread_mutex_lock(&et_list_mutex)==0); -#define UNLOCK_ET_LIST assert(pthread_mutex_unlock(&et_list_mutex)==0); + do { \ + (et_list_done || pthread_once(&et_list_once, et_mutex_once)); \ + assert(pthread_mutex_lock(&et_list_mutex)==0); \ + } while (0) +#define UNLOCK_ET_LIST assert(pthread_mutex_unlock(&et_list_mutex)==0) #else #define LOCK_ET_LIST #define UNLOCK_ET_LIST @@ -131,16 +133,19 @@ error_message(afs_int32 code) else goto oops; } - LOCK_ET_LIST for (et = _et_list; et; et = et->next) { + LOCK_ET_LIST; + for (et = _et_list; et; et = et->next) { if (et->table->base == table_num) { /* This is the right table */ if (et->table->n_msgs <= offset) goto oops; - UNLOCK_ET_LIST return (et->table->msgs[offset]); + UNLOCK_ET_LIST; + return (et->table->msgs[offset]); } } oops: - UNLOCK_ET_LIST strcpy(buffer, "Unknown code "); + UNLOCK_ET_LIST; + strcpy(buffer, "Unknown code "); if (table_num) { strcat(buffer, error_table_name(table_num)); strcat(buffer, " "); @@ -168,16 +173,18 @@ add_to_error_table(struct et_list *new_table) { struct et_list *et; - LOCK_ET_LIST - /* - * Protect against adding the same error table twice - */ - for (et = _et_list; et; et = et->next) { + LOCK_ET_LIST; + /* + * Protect against adding the same error table twice + */ + for (et = _et_list; et; et = et->next) { if (et->table->base == new_table->table->base) { - UNLOCK_ET_LIST return; + UNLOCK_ET_LIST; + return; } } new_table->next = _et_list; _et_list = new_table; -UNLOCK_ET_LIST} + UNLOCK_ET_LIST; +} diff --git a/src/des/des.c b/src/des/des.c index 8fe29ee685..732e266bb7 100644 --- a/src/des/des.c +++ b/src/des/des.c @@ -104,25 +104,26 @@ des_ecb_encrypt(afs_uint32 * clear, afs_uint32 * cipher, #ifdef DEBUG afs_uint32 dbg_tmp[2]; #endif - LOCK_RXKAD_STATS if (encrypt) - rxkad_stats.des_encrypts[DES_ENCRYPT]++; + LOCK_RXKAD_STATS; + if (encrypt) + rxkad_stats.des_encrypts[DES_ENCRYPT]++; else rxkad_stats.des_encrypts[DES_DECRYPT]++; - UNLOCK_RXKAD_STATS - /* - * Use L1,R1 and L2,R2 as two sets of "64-bit" registers always - * work from L1,R1 input to L2,R2 output; initialize the cleartext - * into registers. - */ + UNLOCK_RXKAD_STATS; + /* + * Use L1,R1 and L2,R2 as two sets of "64-bit" registers always + * work from L1,R1 input to L2,R2 output; initialize the cleartext + * into registers. + */ #ifdef MUSTALIGN #ifdef DEBUG - /* - * If the alignment is wrong, the programmer really screwed up -- - * we aren't even getting the right data type. His problem. Keep - * this code for debugging. - */ - /* Make sure schedule is ok */ - if ((afs_int32) schedule & 3) { + /* + * If the alignment is wrong, the programmer really screwed up -- + * we aren't even getting the right data type. His problem. Keep + * this code for debugging. + */ + /* Make sure schedule is ok */ + if ((afs_int32) schedule & 3) { fprintf(stderr, "des.c schedule arg pointer not aligned\n"); abort(); } diff --git a/src/des/key_sched.c b/src/des/key_sched.c index f9abaa1d97..38e75a000d 100644 --- a/src/des/key_sched.c +++ b/src/des/key_sched.c @@ -66,10 +66,11 @@ des_key_sched(register des_cblock k, des_key_schedule schedule) n = 0; p_char = k_char; - LOCK_RXKAD_STATS rxkad_stats.des_key_scheds++; - UNLOCK_RXKAD_STATS + LOCK_RXKAD_STATS; + rxkad_stats.des_key_scheds++; + UNLOCK_RXKAD_STATS; #ifdef lint - n = n; /* fool it in case of VAXASM */ + n = n; /* fool it in case of VAXASM */ #endif #ifdef DEBUG if (des_debug) diff --git a/src/des/new_rnd_key.c b/src/des/new_rnd_key.c index 291340ab1b..c1f11bf6e9 100644 --- a/src/des/new_rnd_key.c +++ b/src/des/new_rnd_key.c @@ -54,8 +54,8 @@ static int is_inited = 0; #include pthread_mutex_t des_init_mutex; -#define LOCK_INIT assert(pthread_mutex_lock(&des_init_mutex)==0); -#define UNLOCK_INIT assert(pthread_mutex_unlock(&des_init_mutex)==0); +#define LOCK_INIT assert(pthread_mutex_lock(&des_init_mutex)==0) +#define UNLOCK_INIT assert(pthread_mutex_unlock(&des_init_mutex)==0) #else #define LOCK_INIT #define UNLOCK_INIT @@ -75,10 +75,11 @@ pthread_mutex_t des_init_mutex; int des_random_key(des_cblock key) { - LOCK_INIT if (!is_inited) { + LOCK_INIT; + if (!is_inited) { des_init_random_number_generator(key); } - UNLOCK_INIT + UNLOCK_INIT; do { des_generate_random_block(key); des_fixup_key_parity(key); @@ -192,8 +193,8 @@ static unsigned char sequence_number[8]; #include pthread_mutex_t des_random_mutex; -#define LOCK_RANDOM assert(pthread_mutex_lock(&des_random_mutex)==0); -#define UNLOCK_RANDOM assert(pthread_mutex_unlock(&des_random_mutex)==0); +#define LOCK_RANDOM assert(pthread_mutex_lock(&des_random_mutex)==0) +#define UNLOCK_RANDOM assert(pthread_mutex_unlock(&des_random_mutex)==0) #else #define LOCK_RANDOM #define UNLOCK_RANDOM @@ -216,12 +217,14 @@ des_set_random_generator_seed(des_cblock key) register int i; /* select the new stream: (note errors are not possible here...) */ - LOCK_RANDOM des_key_sched(key, random_sequence_key.d); + LOCK_RANDOM; + des_key_sched(key, random_sequence_key.d); /* "seek" to the start of the stream: */ for (i = 0; i < 8; i++) sequence_number[i] = 0; -UNLOCK_RANDOM} + UNLOCK_RANDOM; +} /* * des_set_sequence_number: this routine is used to set the sequence number @@ -234,9 +237,11 @@ UNLOCK_RANDOM} static afs_int32 des_set_sequence_number(des_cblock new_sequence_number) { - LOCK_RANDOM memcpy((char *)sequence_number, (char *)new_sequence_number, - sizeof(sequence_number)); - UNLOCK_RANDOM return 0; + LOCK_RANDOM; + memcpy((char *)sequence_number, (char *)new_sequence_number, + sizeof(sequence_number)); + UNLOCK_RANDOM; + return 0; } /* @@ -252,13 +257,14 @@ des_generate_random_block(des_cblock block) { int i; - LOCK_RXKAD_STATS rxkad_stats.des_randoms++; - UNLOCK_RXKAD_STATS - /* - * Encrypt the sequence number to get the new random block: - */ - LOCK_RANDOM des_ecb_encrypt(sequence_number, block, - random_sequence_key.d, 1); + LOCK_RXKAD_STATS; + rxkad_stats.des_randoms++; + UNLOCK_RXKAD_STATS; + /* + * Encrypt the sequence number to get the new random block: + */ + LOCK_RANDOM; + des_ecb_encrypt(sequence_number, block, random_sequence_key.d, 1); /* * Increment the sequence number as an 8 byte unsigned number with wrap: @@ -269,5 +275,6 @@ des_generate_random_block(des_cblock block) if (sequence_number[i]) break; } - UNLOCK_RANDOM return 0; + UNLOCK_RANDOM; + return 0; } diff --git a/src/des/stats.h b/src/des/stats.h index fc28877f0a..7699ee21c4 100644 --- a/src/des/stats.h +++ b/src/des/stats.h @@ -37,8 +37,8 @@ struct rxkad_stats { #include #include extern pthread_mutex_t rxkad_stats_mutex; -#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0); -#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0); +#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0) +#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0) #else #define LOCK_RXKAD_STATS #define UNLOCK_RXKAD_STATS diff --git a/src/kauth/authclient.c b/src/kauth/authclient.c index 2a06ed6ea5..7bf9503c2b 100644 --- a/src/kauth/authclient.c +++ b/src/kauth/authclient.c @@ -83,7 +83,8 @@ ka_ExplicitCell(char *cell, afs_int32 serverList[]) { int i; - LOCK_GLOBAL_MUTEX ka_ExpandCell(cell, explicit_cell_server_list.name, 0); + LOCK_GLOBAL_MUTEX; + ka_ExpandCell(cell, explicit_cell_server_list.name, 0); for (i = 0; i < MAXHOSTSPERCELL; i++) if (serverList[i]) { explicit_cell_server_list.numServers = i + 1; @@ -100,7 +101,8 @@ ka_ExplicitCell(char *cell, afs_int32 serverList[]) explicit = 1; } else break; -UNLOCK_GLOBAL_MUTEX} + UNLOCK_GLOBAL_MUTEX; +} static int myCellLookup(struct afsconf_dir *conf, char *cell, char *service, @@ -125,8 +127,9 @@ ka_GetServers(char *cell, struct afsconf_cell * cellinfo) afs_int32 code; char cellname[MAXKTCREALMLEN]; - LOCK_GLOBAL_MUTEX if (cell && !strlen(cell)) - cell = 0; + LOCK_GLOBAL_MUTEX; + if (cell && !strlen(cell)) + cell = 0; else cell = lcstring(cellname, cell, sizeof(cellname)); @@ -137,18 +140,21 @@ ka_GetServers(char *cell, struct afsconf_cell * cellinfo) conf = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH); #endif /* UKERNEL */ if (!conf) { - UNLOCK_GLOBAL_MUTEX return KANOCELLS; + UNLOCK_GLOBAL_MUTEX; + return KANOCELLS; } } code = myCellLookup(conf, cell, AFSCONF_KAUTHSERVICE, cellinfo); - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } afs_int32 ka_GetSecurity(int service, struct ktc_token * token, struct rx_securityClass ** scP, int *siP) { /* security class index */ - LOCK_GLOBAL_MUTEX *scP = 0; + LOCK_GLOBAL_MUTEX; + *scP = 0; switch (service) { case KA_AUTHENTICATION_SERVICE: case KA_TICKET_GRANTING_SERVICE: @@ -166,13 +172,16 @@ ka_GetSecurity(int service, struct ktc_token * token, *siP = RX_SCINDEX_KAD; break; default: - UNLOCK_GLOBAL_MUTEX return KABADARGUMENT; + UNLOCK_GLOBAL_MUTEX; + return KABADARGUMENT; } if (*scP == 0) { printf("Failed gettting security object\n"); - UNLOCK_GLOBAL_MUTEX return KARXFAIL; + UNLOCK_GLOBAL_MUTEX; + return KARXFAIL; } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } afs_int32 @@ -190,9 +199,11 @@ ka_SingleServerConn(char *cell, char *server, /* name of server to contact */ char sname[MAXHOSTCHARS]; int snamel; - LOCK_GLOBAL_MUTEX code = ka_GetServers(cell, &cellinfo); + LOCK_GLOBAL_MUTEX; + code = ka_GetServers(cell, &cellinfo); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } lcstring(sname, server, sizeof(sname)); @@ -201,23 +212,27 @@ ka_SingleServerConn(char *cell, char *server, /* name of server to contact */ for (i = 0; i < cellinfo.numServers; i++) { if (strncmp(cellinfo.hostName[i], sname, snamel) == 0) { if (match >= 0) { - UNLOCK_GLOBAL_MUTEX return KANOCELLS; + UNLOCK_GLOBAL_MUTEX; + return KANOCELLS; } else match = i; } } if (match < 0) { - UNLOCK_GLOBAL_MUTEX return KANOCELLS; + UNLOCK_GLOBAL_MUTEX; + return KANOCELLS; } code = rx_Init(0); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ka_GetSecurity(service, token, &sc, &si); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } #ifdef AFS_PTHREAD_ENV serverconns[0] = @@ -237,8 +252,9 @@ ka_SingleServerConn(char *cell, char *server, /* name of server to contact */ *conn = 0; code = ubik_ClientInit(serverconns, conn); rxs_Release(sc); - UNLOCK_GLOBAL_MUTEX if (code) - return KAUBIKINIT; + UNLOCK_GLOBAL_MUTEX; + if (code) + return KAUBIKINIT; return 0; } @@ -253,14 +269,17 @@ ka_AuthSpecificServersConn(int service, struct ktc_token * token, int si; /* security class index */ int i; - LOCK_GLOBAL_MUTEX code = rx_Init(0); + LOCK_GLOBAL_MUTEX; + code = rx_Init(0); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ka_GetSecurity(service, token, &sc, &si); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } for (i = 0; i < cellinfo->numServers; i++) @@ -282,8 +301,9 @@ ka_AuthSpecificServersConn(int service, struct ktc_token * token, *conn = 0; code = ubik_ClientInit(serverconns, conn); rxs_Release(sc); - UNLOCK_GLOBAL_MUTEX if (code) - return KAUBIKINIT; + UNLOCK_GLOBAL_MUTEX; + if (code) + return KAUBIKINIT; return 0; } @@ -298,19 +318,23 @@ ka_AuthServerConn(char *cell, int service, struct ktc_token * token, int i; struct afsconf_cell cellinfo; /* for cell auth server list */ - LOCK_GLOBAL_MUTEX code = ka_GetServers(cell, &cellinfo); + LOCK_GLOBAL_MUTEX; + code = ka_GetServers(cell, &cellinfo); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = rx_Init(0); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ka_GetSecurity(service, token, &sc, &si); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } for (i = 0; i < cellinfo.numServers; i++) @@ -332,8 +356,9 @@ ka_AuthServerConn(char *cell, int service, struct ktc_token * token, *conn = 0; code = ubik_ClientInit(serverconns, conn); rxs_Release(sc); - UNLOCK_GLOBAL_MUTEX if (code) - return KAUBIKINIT; + UNLOCK_GLOBAL_MUTEX; + if (code) + return KAUBIKINIT; return 0; } @@ -501,8 +526,10 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con char *ans_label; int version; - LOCK_GLOBAL_MUTEX if ((code = des_key_sched(key, schedule))) { - UNLOCK_GLOBAL_MUTEX return KABADKEY; + LOCK_GLOBAL_MUTEX; + if ((code = des_key_sched(key, schedule))) { + UNLOCK_GLOBAL_MUTEX; + return KABADKEY; } if (service == KA_MAINTENANCE_SERVICE) { @@ -512,7 +539,8 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con req_label = KA_GETTGT_REQ_LABEL; ans_label = KA_GETTGT_ANS_LABEL; } else { - UNLOCK_GLOBAL_MUTEX return KABADARGUMENT; + UNLOCK_GLOBAL_MUTEX; + return KABADARGUMENT; } request_time = time(0); @@ -552,8 +580,9 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con } } if (code) { - UNLOCK_GLOBAL_MUTEX if ((code >= KAMINERROR) && (code <= KAMAXERROR)) - return code; + UNLOCK_GLOBAL_MUTEX; + if ((code >= KAMINERROR) && (code <= KAMAXERROR)) + return code; return KAUBIKCALL; } des_pcbc_encrypt(oanswer.SeqBody, oanswer.SeqBody, oanswer.SeqLen, @@ -571,7 +600,8 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con CheckTicketAnswer(&oanswer, request_time + 1, token, &caller, 0, ans_label, pwexpires); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } } break; @@ -581,13 +611,15 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con if ((answer_old.time != request_time + 1) || (answer_old.ticket_len < MINKTCTICKETLEN) || (answer_old.ticket_len > MAXKTCTICKETLEN)) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } { char *label = ((char *)answer_old.ticket) + answer_old.ticket_len; if (strncmp(label, ans_label, sizeof(answer_old.label))) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } token->startTime = start; token->endTime = end; @@ -599,10 +631,12 @@ ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client * con } break; default: - UNLOCK_GLOBAL_MUTEX return KAINTERNALERROR; + UNLOCK_GLOBAL_MUTEX; + return KAINTERNALERROR; } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } afs_int32 @@ -624,12 +658,14 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st int version; afs_int32 pwexpires; - LOCK_GLOBAL_MUTEX aticket.SeqLen = auth_token->ticketLen; + LOCK_GLOBAL_MUTEX; + aticket.SeqLen = auth_token->ticketLen; aticket.SeqBody = auth_token->ticket; code = des_key_sched(&auth_token->sessionKey, schedule); if (code) { - UNLOCK_GLOBAL_MUTEX return KABADKEY; + UNLOCK_GLOBAL_MUTEX; + return KABADKEY; } times.start = htonl(start); @@ -662,8 +698,9 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st } } if (code) { - UNLOCK_GLOBAL_MUTEX if ((code >= KAMINERROR) && (code <= KAMAXERROR)) - return code; + UNLOCK_GLOBAL_MUTEX; + if ((code >= KAMINERROR) && (code <= KAMAXERROR)) + return code; return KAUBIKCALL; } @@ -680,7 +717,8 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st CheckTicketAnswer(&oanswer, 0, token, 0, &server, KA_GETTICKET_ANS_LABEL, &pwexpires); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } } break; @@ -693,51 +731,61 @@ ka_GetToken(char *name, char *instance, char *cell, char *cname, char *cinst, st sizeof(token->sessionKey)); if (tkt_CheckTimes(token->startTime, token->endTime, time(0)) < 0) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } if ((token->ticketLen < MINKTCTICKETLEN) || (token->ticketLen > MAXKTCTICKETLEN)) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } strings = answer_old.name; len = strlen(strings); /* check client name */ if ((len < 1) || (len > MAXKTCNAMELEN)) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } strings += len + 1; /* check client instance */ len = strlen(strings); if ((len < 0) || (len > MAXKTCNAMELEN)) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } strings += len + 1; len = strlen(strings); /* check client cell */ if ((len < 0) || (len > MAXKTCNAMELEN)) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } strings += len + 1; len = strlen(strings); /* check server name */ if ((len < 1) || (len > MAXKTCNAMELEN) || strcmp(name, strings)) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } strings += len + 1; len = strlen(strings); /* check server instance */ if ((len < 0) || (len > MAXKTCNAMELEN) || strcmp(instance, strings)) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } strings += len + 1; if ((strings - oanswer.SeqBody + token->ticketLen) - oanswer.SeqLen >= ENCRYPTIONBLOCKSIZE) { - UNLOCK_GLOBAL_MUTEX return KABADPROTOCOL; + UNLOCK_GLOBAL_MUTEX; + return KABADPROTOCOL; } memcpy(token->ticket, strings, token->ticketLen); break; default: - UNLOCK_GLOBAL_MUTEX return KAINTERNALERROR; + UNLOCK_GLOBAL_MUTEX; + return KAINTERNALERROR; } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } afs_int32 @@ -748,14 +796,15 @@ ka_ChangePassword(char *name, char *instance, struct ubik_client * conn, /* Ubik { afs_int32 code; - LOCK_GLOBAL_MUTEX + LOCK_GLOBAL_MUTEX; #if defined(AFS_S390_LINUX20_ENV) && !defined(AFS_S390X_LINUX20_ENV) - code = + code = ubik_Call_New(KAM_SetPassword, conn, 0, name, instance, 0, 0, *newkey); #else - code = + code = ubik_Call_New(KAM_SetPassword, conn, 0, name, instance, 0, *newkey); #endif - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } diff --git a/src/kauth/client.c b/src/kauth/client.c index efe4a355d7..64f8f4e600 100644 --- a/src/kauth/client.c +++ b/src/kauth/client.c @@ -141,7 +141,8 @@ ka_StringToKey(char *str, char *cell, /* cell for password */ char realm[MAXKTCREALMLEN]; afs_int32 code; - LOCK_GLOBAL_MUTEX code = ka_CellToRealm(cell, realm, 0 /*local */ ); + LOCK_GLOBAL_MUTEX; + code = ka_CellToRealm(cell, realm, 0 /*local */ ); if (code) /* just take his word for it */ strncpy(realm, cell, sizeof(realm)); else /* for backward compatibility */ @@ -150,7 +151,8 @@ ka_StringToKey(char *str, char *cell, /* cell for password */ StringToKey(str, realm, key); else Andrew_StringToKey(str, realm, key); -UNLOCK_GLOBAL_MUTEX} + UNLOCK_GLOBAL_MUTEX; +} /* This prints out a prompt and reads a string from the terminal, turning off echoing. If verify is requested it requests that the string be entered @@ -168,16 +170,20 @@ ka_ReadPassword(char *prompt, int verify, char *cell, char password[BUFSIZ]; afs_int32 code; - LOCK_GLOBAL_MUTEX memset(key, 0, sizeof(struct ktc_encryptionKey)); + LOCK_GLOBAL_MUTEX; + memset(key, 0, sizeof(struct ktc_encryptionKey)); code = read_pw_string(password, sizeof(password), prompt, verify); if (code) { - UNLOCK_GLOBAL_MUTEX return KAREADPW; + UNLOCK_GLOBAL_MUTEX; + return KAREADPW; } if (strlen(password) == 0) { - UNLOCK_GLOBAL_MUTEX return KANULLPASSWORD; + UNLOCK_GLOBAL_MUTEX; + return KANULLPASSWORD; } ka_StringToKey(password, cell, key); - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } /* This performs the backslash quoting defined by AC_ParseLoginName. */ @@ -310,8 +316,10 @@ ka_Init(int flags) afs_int32 code; static int inited = 0; - LOCK_GLOBAL_MUTEX if (inited) { - UNLOCK_GLOBAL_MUTEX return 0; + LOCK_GLOBAL_MUTEX; + if (inited) { + UNLOCK_GLOBAL_MUTEX; + return 0; } inited++; initialize_U_error_table(); @@ -320,8 +328,9 @@ ka_Init(int flags) initialize_KTC_error_table(); initialize_ACFG_error_table(); code = ka_CellConfig(AFSDIR_CLIENT_ETC_DIRPATH); - UNLOCK_GLOBAL_MUTEX if (code) - return code; + UNLOCK_GLOBAL_MUTEX; + if (code) + return code; return 0; } diff --git a/src/kauth/kadatabase.c b/src/kauth/kadatabase.c index f22e3a30cf..c3bee37b4c 100644 --- a/src/kauth/kadatabase.c +++ b/src/kauth/kadatabase.c @@ -689,11 +689,12 @@ ka_debugKeyCache(info) (keyCache[i].superseded == NEVERDATE); info->kcInfo[j].keycksum = 0; #if DEBUG_KEY_CACHE - { - int k; - for (k = 0; k < sizeof(struct ktc_encryptionKey); k++) - info->kcInfo[j].keycksum += ((char *)&keyCache[i].key)[k]; - } + { + int k; + for (k = 0; k < sizeof(struct ktc_encryptionKey); k++) + info->kcInfo[j].keycksum += + ((char *)&keyCache[i].key)[k]; + } #endif strcpy(principal, keyCache[i].name); strcat(principal, "."); diff --git a/src/kauth/kalocalcell.c b/src/kauth/kalocalcell.c index 42798bd5de..0081e9c7e6 100644 --- a/src/kauth/kalocalcell.c +++ b/src/kauth/kalocalcell.c @@ -68,14 +68,17 @@ ka_CellConfig(const char *dir) strcpy(cell_name, afs_LclCellName); return 0; #else /* UKERNEL */ - LOCK_GLOBAL_MUTEX if (conf) - afsconf_Close(conf); + LOCK_GLOBAL_MUTEX; + if (conf) + afsconf_Close(conf); conf = afsconf_Open(dir); if (!conf) { - UNLOCK_GLOBAL_MUTEX return KANOCELLS; + UNLOCK_GLOBAL_MUTEX; + return KANOCELLS; } code = afsconf_GetLocalCell(conf, cell_name, sizeof(cell_name)); - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; #endif /* UKERNEL */ } @@ -84,8 +87,10 @@ ka_LocalCell(void) { int code; - LOCK_GLOBAL_MUTEX if (conf) { - UNLOCK_GLOBAL_MUTEX return cell_name; + LOCK_GLOBAL_MUTEX; + if (conf) { + UNLOCK_GLOBAL_MUTEX; + return cell_name; } #ifdef UKERNEL conf = afs_cdir; @@ -99,10 +104,12 @@ ka_LocalCell(void) if (!conf || code) { printf("** Can't determine local cell name!\n"); conf = 0; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } #endif /* UKERNEL */ - UNLOCK_GLOBAL_MUTEX return cell_name; + UNLOCK_GLOBAL_MUTEX; + return cell_name; } int @@ -113,9 +120,11 @@ ka_ExpandCell(char *cell, char *fullCell, int *alocal) char cellname[MAXKTCREALMLEN]; struct afsconf_cell cellinfo; /* storage for cell info */ - LOCK_GLOBAL_MUTEX ka_LocalCell(); /* initialize things */ + LOCK_GLOBAL_MUTEX; + ka_LocalCell(); /* initialize things */ if (!conf) { - UNLOCK_GLOBAL_MUTEX return KANOCELLS; + UNLOCK_GLOBAL_MUTEX; + return KANOCELLS; } if ((cell == 0) || (strlen(cell) == 0)) { @@ -125,7 +134,8 @@ ka_ExpandCell(char *cell, char *fullCell, int *alocal) cell = lcstring(cellname, cell, sizeof(cellname)); code = afsconf_GetCellInfo(conf, cell, 0, &cellinfo); if (code) { - UNLOCK_GLOBAL_MUTEX return KANOCELL; + UNLOCK_GLOBAL_MUTEX; + return KANOCELL; } cell = cellinfo.name; } @@ -136,7 +146,8 @@ ka_ExpandCell(char *cell, char *fullCell, int *alocal) strcpy(fullCell, cell); if (alocal) *alocal = local; - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } int @@ -144,7 +155,9 @@ ka_CellToRealm(char *cell, char *realm, int *local) { int code; - LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, realm, local); + LOCK_GLOBAL_MUTEX; + code = ka_ExpandCell(cell, realm, local); ucstring(realm, realm, MAXKTCREALMLEN); - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } diff --git a/src/kauth/kaprocs.c b/src/kauth/kaprocs.c index 92fbc4c371..5fe2fdb878 100644 --- a/src/kauth/kaprocs.c +++ b/src/kauth/kaprocs.c @@ -1032,7 +1032,8 @@ PrepareTicketAnswer(oanswer, challenge, ticket, ticketLen, sessionKey, start, code = KAANSWERTOOLONG; if (oanswer->MaxSeqLen < - sizeof(struct ka_ticketAnswer) - 5 * MAXKTCNAMELEN - MAXKTCTICKETLEN + ticketLen) + sizeof(struct ka_ticketAnswer) - 5 * MAXKTCNAMELEN - MAXKTCTICKETLEN + + ticketLen) return code; answer = (struct ka_ticketAnswer *)oanswer->SeqBody; @@ -1958,7 +1959,8 @@ GetTicket(version, call, kvno, authDomain, aticket, sname, sinstance, atimes, case 0: code = KAANSWERTOOLONG; if (oanswer->MaxSeqLen < - sizeof(struct ka_getTicketAnswer) - 5 * MAXKTCNAMELEN - MAXKTCTICKETLEN + ticketLen) + sizeof(struct ka_getTicketAnswer) - 5 * MAXKTCNAMELEN - + MAXKTCTICKETLEN + ticketLen) goto abort; answer = (struct ka_getTicketAnswer *)oanswer->SeqBody; diff --git a/src/kauth/kpasswd.c b/src/kauth/kpasswd.c index aae1ab4fe6..0d5039289e 100644 --- a/src/kauth/kpasswd.c +++ b/src/kauth/kpasswd.c @@ -211,10 +211,10 @@ CommandProc(as, arock) char *arock; struct cmd_syndesc *as; { - char name[MAXKTCNAMELEN]=""; - char instance[MAXKTCNAMELEN]=""; - char cell[MAXKTCREALMLEN]=""; - char realm[MAXKTCREALMLEN]=""; + char name[MAXKTCNAMELEN] = ""; + char instance[MAXKTCNAMELEN] = ""; + char cell[MAXKTCREALMLEN] = ""; + char realm[MAXKTCREALMLEN] = ""; afs_int32 serverList[MAXSERVERS]; char *lcell; /* local cellname */ int code; diff --git a/src/kauth/prot.h b/src/kauth/prot.h index 3e0c58b4ee..b62e049c74 100644 --- a/src/kauth/prot.h +++ b/src/kauth/prot.h @@ -11,7 +11,7 @@ #include - /* #include *//* removed 890221 */ + /* #include *//* removed 890221 */ #ifndef PROT_DEFS #define PROT_DEFS @@ -60,9 +60,9 @@ /* Routines to create and read packets may be found in prot.c */ - /* KTEXT create_auth_reply(); *//* removed 890221 */ - /* KTEXT create_death_packet(); *//* removed 890221 */ - /* KTEXT pkt_cipher(); *//* removed 890221 */ + /* KTEXT create_auth_reply(); *//* removed 890221 */ + /* KTEXT create_death_packet(); *//* removed 890221 */ + /* KTEXT pkt_cipher(); *//* removed 890221 */ /* Message types , always leave lsb for byte order */ diff --git a/src/kauth/token.c b/src/kauth/token.c index 6166433806..7a126bba78 100644 --- a/src/kauth/token.c +++ b/src/kauth/token.c @@ -65,7 +65,7 @@ RCSID afs_int32 ka_GetAuthToken(char *name, char *instance, char *cell, - struct ktc_encryptionKey *key, afs_int32 lifetime, + struct ktc_encryptionKey * key, afs_int32 lifetime, afs_int32 * pwexpires) { afs_int32 code; @@ -76,32 +76,38 @@ ka_GetAuthToken(char *name, char *instance, char *cell, char realm[MAXKTCREALMLEN]; struct ktc_principal client, server; - LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ ); + LOCK_GLOBAL_MUTEX; + code = ka_ExpandCell(cell, cellname, 0 /*local */ ); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } cell = cellname; /* get an unauthenticated connection to desired cell */ code = ka_AuthServerConn(cell, KA_AUTHENTICATION_SERVICE, 0, &conn); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ka_Authenticate(name, instance, cell, conn, KA_TICKET_GRANTING_SERVICE, key, now, now + lifetime, &token, pwexpires); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ubik_ClientDestroy(conn); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ka_CellToRealm(cell, realm, 0 /*local */ ); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } strcpy(client.name, name); strcpy(client.instance, instance); @@ -110,7 +116,8 @@ ka_GetAuthToken(char *name, char *instance, char *cell, strcpy(server.instance, realm); strcpy(server.cell, cell); code = ktc_SetToken(&server, &token, &client, 0); - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } afs_int32 @@ -129,9 +136,11 @@ ka_GetServerToken(char *name, char *instance, char *cell, Date lifetime, char authDomain[MAXKTCREALMLEN]; int local; - LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ ); + LOCK_GLOBAL_MUTEX; + code = ka_ExpandCell(cell, cellname, 0 /*local */ ); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } cell = cellname; @@ -142,13 +151,15 @@ ka_GetServerToken(char *name, char *instance, char *cell, Date lifetime, code = ktc_GetToken(&server, token, sizeof(struct ktc_token), &client); if (!code) { - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } } code = ka_CellToRealm(cell, realm, &local); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } /* get TGS ticket for proper realm */ @@ -167,7 +178,8 @@ ka_GetServerToken(char *name, char *instance, char *cell, Date lifetime, } if (code && local) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } else if (code) { /* here we invoke the inter-cell mechanism */ @@ -179,13 +191,15 @@ ka_GetServerToken(char *name, char *instance, char *cell, Date lifetime, ktc_GetToken(&auth_server, &cell_token, sizeof(cell_token), &client); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } /* get a connection to the local cell */ if ((code = ka_AuthServerConn(localCell, KA_TICKET_GRANTING_SERVICE, 0, &conn))) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } /* get foreign auth ticket */ if ((code = @@ -193,11 +207,13 @@ ka_GetServerToken(char *name, char *instance, char *cell, Date lifetime, client.instance, conn, now, now + lifetime, &cell_token, "" /* local auth domain */ , &auth_token))) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ubik_ClientDestroy(conn); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } conn = 0; @@ -206,30 +222,36 @@ ka_GetServerToken(char *name, char *instance, char *cell, Date lifetime, lcstring(auth_server.cell, localCell, sizeof(auth_server.cell)); ucstring(authDomain, localCell, sizeof(authDomain)); if ((code = ktc_SetToken(&auth_server, &auth_token, &client, 0))) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } } if ((code = ka_AuthServerConn(cell, KA_TICKET_GRANTING_SERVICE, 0, &conn))) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } if ((code = ka_GetToken(name, instance, cell, client.name, client.instance, conn, now, now + lifetime, &auth_token, authDomain, token))) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ubik_ClientDestroy(conn); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } if ((code = ktc_SetToken(&server, token, &client, dosetpag ? AFS_SETTOK_SETPAG : 0))) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } afs_int32 @@ -244,9 +266,11 @@ ka_GetAdminToken(char *name, char *instance, char *cell, struct ktc_token localToken; char cellname[MAXKTCREALMLEN]; - LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ ); + LOCK_GLOBAL_MUTEX; + code = ka_ExpandCell(cell, cellname, 0 /*local */ ); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } cell = cellname; @@ -260,33 +284,38 @@ ka_GetAdminToken(char *name, char *instance, char *cell, code = ktc_GetToken(&server, token, sizeof(struct ktc_token), &client); if (code == 0) { - UNLOCK_GLOBAL_MUTEX return 0; + UNLOCK_GLOBAL_MUTEX; + return 0; } } if ((name == 0) || (key == 0)) { /* just lookup in cache don't get new one */ - UNLOCK_GLOBAL_MUTEX return KANOTICKET; + UNLOCK_GLOBAL_MUTEX; + return KANOTICKET; } /* get an unauthenticated connection to desired cell */ code = ka_AuthServerConn(cell, KA_AUTHENTICATION_SERVICE, 0, &conn); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ka_Authenticate(name, instance, cell, conn, KA_MAINTENANCE_SERVICE, key, now, now + lifetime, token, 0); (void)ubik_ClientDestroy(conn); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } strcpy(client.name, name); strcpy(client.instance, instance); strncpy(client.cell, cell, sizeof(client.cell)); code = ktc_SetToken(&server, token, &client, 0); - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } @@ -301,9 +330,11 @@ ka_VerifyUserToken(char *name, char *instance, char *cell, char cellname[MAXKTCREALMLEN]; afs_int32 pwexpires; - LOCK_GLOBAL_MUTEX code = ka_ExpandCell(cell, cellname, 0 /*local */ ); + LOCK_GLOBAL_MUTEX; + code = ka_ExpandCell(cell, cellname, 0 /*local */ ); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } cell = cellname; @@ -311,7 +342,8 @@ ka_VerifyUserToken(char *name, char *instance, char *cell, /* get an unauthenticated connection to desired cell */ code = ka_AuthServerConn(cell, KA_AUTHENTICATION_SERVICE, 0, &conn); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = @@ -319,8 +351,10 @@ ka_VerifyUserToken(char *name, char *instance, char *cell, KA_TICKET_GRANTING_SERVICE, key, now, now + MAXKTCTICKETLIFETIME, &token, &pwexpires); if (code) { - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } code = ubik_ClientDestroy(conn); - UNLOCK_GLOBAL_MUTEX return code; + UNLOCK_GLOBAL_MUTEX; + return code; } diff --git a/src/kauth/user.c b/src/kauth/user.c index 6d01e24530..6dbafe60a0 100644 --- a/src/kauth/user.c +++ b/src/kauth/user.c @@ -68,7 +68,7 @@ RCSID afs_int32 GetTickets(char *name, char *instance, char *realm, - struct ktc_encryptionKey *key, Date lifetime, + struct ktc_encryptionKey * key, Date lifetime, afs_int32 * pwexpires, afs_int32 flags) { afs_int32 code; diff --git a/src/kauth/user_nt.c b/src/kauth/user_nt.c index 49c7b14a1f..da99ac486a 100644 --- a/src/kauth/user_nt.c +++ b/src/kauth/user_nt.c @@ -797,7 +797,7 @@ send_recv(pkt, rpkt, f, _to) (void)fflush(stdout); } FD_ZERO(&readfds); - FD_SET(f,&readfds); + FD_SET(f, &readfds); errno = 0; /* select - either recv is ready, or timeout */ /* see if timeout or error or wrong descriptor */ diff --git a/src/libadmin/adminutil/afs_utilAdmin.c b/src/libadmin/adminutil/afs_utilAdmin.c index c29e3d4379..a259809ee4 100644 --- a/src/libadmin/adminutil/afs_utilAdmin.c +++ b/src/libadmin/adminutil/afs_utilAdmin.c @@ -446,7 +446,8 @@ util_AdminServerAddressGetFromName(const char *serverName, int *serverAddress, if (num_converted == 4) { *serverAddress = (part1 << 24) | (part2 << 16) | (part3 << 8) | part4; } else { - LOCK_GLOBAL_MUTEX server = gethostbyname(serverName); + LOCK_GLOBAL_MUTEX; + server = gethostbyname(serverName); if (server != NULL) { memcpy((void *)serverAddress, (const void *)server->h_addr, sizeof(serverAddress)); @@ -456,7 +457,8 @@ util_AdminServerAddressGetFromName(const char *serverName, int *serverAddress, UNLOCK_GLOBAL_MUTEX; goto fail_util_AdminServerAddressGetFromName; } - UNLOCK_GLOBAL_MUTEX} + UNLOCK_GLOBAL_MUTEX; + } rc = 1; fail_util_AdminServerAddressGetFromName: diff --git a/src/libadmin/client/afs_clientAdmin.c b/src/libadmin/client/afs_clientAdmin.c index 8ec3071d23..f256586780 100644 --- a/src/libadmin/client/afs_clientAdmin.c +++ b/src/libadmin/client/afs_clientAdmin.c @@ -1956,7 +1956,8 @@ afsclient_AFSServerGetBegin(const void *cellHandle, void **iterationIdP, * Iterate over the list and fill in the hostname of each of the servers */ - LOCK_GLOBAL_MUTEX for (iserv = 0; iserv < serv->total; iserv++) { + LOCK_GLOBAL_MUTEX; + for (iserv = 0; iserv < serv->total; iserv++) { int addr = htonl(serv->server[iserv].serverAddress[0]); host = gethostbyaddr((const char *)&addr, sizeof(int), AF_INET); if (host != NULL) { @@ -1964,8 +1965,8 @@ afsclient_AFSServerGetBegin(const void *cellHandle, void **iterationIdP, AFS_MAX_SERVER_NAME_LEN); } } - UNLOCK_GLOBAL_MUTEX - if (IteratorInit + UNLOCK_GLOBAL_MUTEX; + if (IteratorInit (iter, (void *)serv, GetServerRPC, GetServerFromCache, NULL, NULL, &tst)) { *iterationIdP = (void *)iter; diff --git a/src/lwp/lock.h b/src/lwp/lock.h index e1c9a76573..8655c85b46 100644 --- a/src/lwp/lock.h +++ b/src/lwp/lock.h @@ -45,8 +45,8 @@ #ifdef AFS_PTHREAD_ENV #include #include -#define LOCK_LOCK(A) assert(pthread_mutex_lock(&(A)->mutex) == 0); -#define LOCK_UNLOCK(A) assert(pthread_mutex_unlock(&(A)->mutex) == 0); +#define LOCK_LOCK(A) assert(pthread_mutex_lock(&(A)->mutex) == 0) +#define LOCK_UNLOCK(A) assert(pthread_mutex_unlock(&(A)->mutex) == 0) #else /* AFS_PTHREAD_ENV */ #define LOCK_LOCK(A) #define LOCK_UNLOCK(A) @@ -82,88 +82,88 @@ void Lock_Destroy(struct Lock *lock); #define ObtainReadLock(lock)\ BEGINMAC \ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!((lock)->excl_locked & WRITE_LOCK) && !(lock)->wait_states)\ (lock) -> readers_reading++;\ else\ Afs_Lock_Obtain(lock, READ_LOCK); \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #define ObtainReadLockNoBlock(lock, code)\ BEGINMAC \ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!((lock)->excl_locked & WRITE_LOCK) && !(lock)->wait_states) {\ (lock) -> readers_reading++;\ code = 0;\ }\ else\ code = -1; \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #define ObtainWriteLock(lock)\ BEGINMAC \ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!(lock)->excl_locked && !(lock)->readers_reading)\ (lock) -> excl_locked = WRITE_LOCK;\ else\ Afs_Lock_Obtain(lock, WRITE_LOCK); \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #define ObtainWriteLockNoBlock(lock, code)\ BEGINMAC \ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!(lock)->excl_locked && !(lock)->readers_reading) {\ (lock) -> excl_locked = WRITE_LOCK;\ code = 0;\ }\ else\ code = -1; \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #define ObtainSharedLock(lock)\ BEGINMAC \ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!(lock)->excl_locked && !(lock)->wait_states)\ (lock) -> excl_locked = SHARED_LOCK;\ else\ Afs_Lock_Obtain(lock, SHARED_LOCK); \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #define ObtainSharedLockNoBlock(lock, code)\ BEGINMAC \ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!(lock)->excl_locked && !(lock)->wait_states) {\ (lock) -> excl_locked = SHARED_LOCK;\ code = 0;\ }\ else\ code = -1; \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #define BoostSharedLock(lock)\ BEGINMAC \ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!(lock)->readers_reading)\ (lock)->excl_locked = WRITE_LOCK;\ else\ Afs_Lock_Obtain(lock, BOOSTED_LOCK); \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC /* this must only be called with a WRITE or boosted SHARED lock! */ #define UnboostSharedLock(lock)\ BEGINMAC\ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ (lock)->excl_locked = SHARED_LOCK; \ if((lock)->wait_states) \ Afs_Lock_ReleaseR(lock); \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #ifdef notdef @@ -177,10 +177,10 @@ void Lock_Destroy(struct Lock *lock); #define ReleaseReadLock(lock)\ BEGINMAC\ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ if (!--(lock)->readers_reading && (lock)->wait_states)\ Afs_Lock_ReleaseW(lock) ; \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC @@ -195,10 +195,10 @@ void Lock_Destroy(struct Lock *lock); #define ReleaseWriteLock(lock)\ BEGINMAC\ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ (lock)->excl_locked &= ~WRITE_LOCK;\ if ((lock)->wait_states) Afs_Lock_ReleaseR(lock);\ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #ifdef notdef @@ -213,10 +213,10 @@ void Lock_Destroy(struct Lock *lock); /* can be used on shared or boosted (write) locks */ #define ReleaseSharedLock(lock)\ BEGINMAC\ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ (lock)->excl_locked &= ~(SHARED_LOCK | WRITE_LOCK);\ if ((lock)->wait_states) Afs_Lock_ReleaseR(lock);\ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC #ifdef notdef @@ -232,12 +232,12 @@ void Lock_Destroy(struct Lock *lock); /* convert a write lock to a read lock */ #define ConvertWriteToReadLock(lock)\ BEGINMAC\ - LOCK_LOCK(lock) \ + LOCK_LOCK(lock); \ (lock)->excl_locked &= ~WRITE_LOCK;\ (lock)->readers_reading++;\ if ((lock)->wait_states & READ_LOCK) \ Afs_Lock_WakeupR(lock) ; \ - LOCK_UNLOCK(lock) \ + LOCK_UNLOCK(lock); \ ENDMAC /* I added this next macro to make sure it is safe to nuke a lock -- Mike K. */ diff --git a/src/rx/rx.c b/src/rx/rx.c index 303c81bfa0..892c2230a9 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -221,7 +221,7 @@ rxi_InitPthread(void) pthread_once_t rx_once_init = PTHREAD_ONCE_INIT; #define INIT_PTHREAD_LOCKS \ -assert(pthread_once(&rx_once_init, rxi_InitPthread)==0); +assert(pthread_once(&rx_once_init, rxi_InitPthread)==0) /* * The rx_stats_mutex mutex protects the following global variables: * rxi_dataQuota @@ -337,8 +337,8 @@ struct rx_serverQueueEntry *rx_waitingForPacket = 0; * rx_epoch */ -#define LOCK_EPOCH assert(pthread_mutex_lock(&epoch_mutex)==0); -#define UNLOCK_EPOCH assert(pthread_mutex_unlock(&epoch_mutex)==0); +#define LOCK_EPOCH assert(pthread_mutex_lock(&epoch_mutex)==0) +#define UNLOCK_EPOCH assert(pthread_mutex_unlock(&epoch_mutex)==0) #else #define LOCK_EPOCH #define UNLOCK_EPOCH @@ -347,8 +347,10 @@ struct rx_serverQueueEntry *rx_waitingForPacket = 0; void rx_SetEpoch(afs_uint32 epoch) { - LOCK_EPOCH rx_epoch = epoch; -UNLOCK_EPOCH} + LOCK_EPOCH; + rx_epoch = epoch; + UNLOCK_EPOCH; +} /* Initialize rx. A port number may be mentioned, in which case this * becomes the default port number for any service installed later. @@ -363,14 +365,14 @@ static int rxinit_status = 1; * rxinit_status */ -#define LOCK_RX_INIT assert(pthread_mutex_lock(&rx_init_mutex)==0); -#define UNLOCK_RX_INIT assert(pthread_mutex_unlock(&rx_init_mutex)==0); +#define LOCK_RX_INIT assert(pthread_mutex_lock(&rx_init_mutex)==0) +#define UNLOCK_RX_INIT assert(pthread_mutex_unlock(&rx_init_mutex)==0) #else #define LOCK_RX_INIT #define UNLOCK_RX_INIT #endif -int +int rx_InitHost(u_int host, u_int port) { #ifdef KERNEL @@ -387,9 +389,12 @@ rx_InitHost(u_int host, u_int port) SPLVAR; - INIT_PTHREAD_LOCKS LOCK_RX_INIT if (rxinit_status == 0) { + INIT_PTHREAD_LOCKS; + LOCK_RX_INIT; + if (rxinit_status == 0) { tmp_status = rxinit_status; - UNLOCK_RX_INIT return tmp_status; /* Already started; return previous error code. */ + UNLOCK_RX_INIT; + return tmp_status; /* Already started; return previous error code. */ } #ifdef AFS_NT40_ENV if (afs_winsockInit() < 0) @@ -409,7 +414,8 @@ rx_InitHost(u_int host, u_int port) rx_socket = rxi_GetHostUDPSocket(host, (u_short) port); if (rx_socket == OSI_NULLSOCKET) { - UNLOCK_RX_INIT return RX_ADDRINUSE; + UNLOCK_RX_INIT; + return RX_ADDRINUSE; } #ifdef RX_ENABLE_LOCKS #ifdef RX_LOCKS_DB @@ -531,10 +537,12 @@ rx_InitHost(u_int host, u_int port) AFS_RXGUNLOCK(); USERPRI; tmp_status = rxinit_status = 0; - UNLOCK_RX_INIT return tmp_status; + UNLOCK_RX_INIT; + return tmp_status; } -int rx_Init(u_int port) +int +rx_Init(u_int port) { return rx_InitHost(htonl(INADDR_ANY), port); } @@ -1924,8 +1932,11 @@ rx_Finalize(void) { register struct rx_connection **conn_ptr, **conn_end; - INIT_PTHREAD_LOCKS LOCK_RX_INIT if (rxinit_status == 1) { - UNLOCK_RX_INIT return; /* Already shutdown. */ + INIT_PTHREAD_LOCKS; + LOCK_RX_INIT; + if (rxinit_status == 1) { + UNLOCK_RX_INIT; + return; /* Already shutdown. */ } rxi_DeleteCachedConnections(); if (rx_connHashTable) { @@ -1963,7 +1974,8 @@ rx_Finalize(void) rxi_flushtrace(); rxinit_status = 1; -UNLOCK_RX_INIT} + UNLOCK_RX_INIT; +} #endif /* if we wakeup packet waiter too often, can get in loop with two @@ -2310,7 +2322,8 @@ rxi_FindConnection(osi_socket socket, register afs_int32 host, if (type == RX_CLIENT_CONNECTION && pp->port == port) break; /* So what happens when it's a callback connection? */ - if (/*type == RX_CLIENT_CONNECTION &&*/ (conn->epoch & 0x80000000)) + if ( /*type == RX_CLIENT_CONNECTION && */ + (conn->epoch & 0x80000000)) break; } if (!flag) { @@ -6079,8 +6092,8 @@ rx_PrintPeerStats(FILE * file, struct rx_peer *peer) * counter */ -#define LOCK_RX_DEBUG assert(pthread_mutex_lock(&rx_debug_mutex)==0); -#define UNLOCK_RX_DEBUG assert(pthread_mutex_unlock(&rx_debug_mutex)==0); +#define LOCK_RX_DEBUG assert(pthread_mutex_lock(&rx_debug_mutex)==0) +#define UNLOCK_RX_DEBUG assert(pthread_mutex_unlock(&rx_debug_mutex)==0) #else #define LOCK_RX_DEBUG #define UNLOCK_RX_DEBUG @@ -6103,8 +6116,10 @@ MakeDebugCall(osi_socket socket, afs_uint32 remoteAddr, afs_uint16 remotePort, register char *tp; endTime = time(0) + 20; /* try for 20 seconds */ - LOCK_RX_DEBUG counter++; - UNLOCK_RX_DEBUG tp = &tbuffer[sizeof(struct rx_header)]; + LOCK_RX_DEBUG; + counter++; + UNLOCK_RX_DEBUG; + tp = &tbuffer[sizeof(struct rx_header)]; taddr.sin_family = AF_INET; taddr.sin_port = remotePort; taddr.sin_addr.s_addr = remoteAddr; @@ -6134,18 +6149,18 @@ MakeDebugCall(osi_socket socket, afs_uint32 remoteAddr, afs_uint16 remotePort, tv.tv_sec = 1; tv.tv_usec = 0; code = select(socket + 1, &imask, 0, 0, &tv); - if (code == 1 && FD_ISSET(socket,&imask)) { + if (code == 1 && FD_ISSET(socket, &imask)) { /* now receive a packet */ faddrLen = sizeof(struct sockaddr_in); code = recvfrom(socket, tbuffer, sizeof(tbuffer), 0, (struct sockaddr *)&faddr, &faddrLen); - if (code > 0) { - memcpy(&theader, tbuffer, sizeof(struct rx_header)); - if (counter == ntohl(theader.callNumber)) - break; - } + if (code > 0) { + memcpy(&theader, tbuffer, sizeof(struct rx_header)); + if (counter == ntohl(theader.callNumber)) + break; + } } /* see if we've timed out */ @@ -6418,8 +6433,10 @@ shutdown_rx(void) register struct rx_serverQueueEntry *sq; #endif /* KERNEL */ - LOCK_RX_INIT if (rxinit_status == 1) { - UNLOCK_RX_INIT return; /* Already shutdown. */ + LOCK_RX_INIT; + if (rxinit_status == 1) { + UNLOCK_RX_INIT; + return; /* Already shutdown. */ } #ifndef KERNEL rx_port = 0; @@ -6536,7 +6553,8 @@ shutdown_rx(void) MUTEX_EXIT(&rx_stats_mutex); rxinit_status = 1; -UNLOCK_RX_INIT} + UNLOCK_RX_INIT; +} #ifdef RX_ENABLE_LOCKS void diff --git a/src/rx/rx_clock_nt.c b/src/rx/rx_clock_nt.c index 5e8942ed45..a449a4e83d 100644 --- a/src/rx/rx_clock_nt.c +++ b/src/rx/rx_clock_nt.c @@ -23,7 +23,7 @@ RCSID #include #include "rx_clock.h" -void clock_UpdateTime(void); /* forward reference */ +void clock_UpdateTime(void); /* forward reference */ struct clock clock_now; /* The last elapsed time ready by clock_GetTimer */ @@ -63,7 +63,7 @@ int clock_UnInit(void) { clockInitialized = 0; - return 0; + return 0; } #endif diff --git a/src/rx/rx_conncache.c b/src/rx/rx_conncache.c index b447c7fd54..4754194e39 100644 --- a/src/rx/rx_conncache.c +++ b/src/rx/rx_conncache.c @@ -48,8 +48,8 @@ static struct rx_queue rxi_connectionCache = { &rxi_connectionCache, */ pthread_mutex_t rxi_connCacheMutex; -#define LOCK_CONN_CACHE assert(pthread_mutex_lock(&rxi_connCacheMutex)==0); -#define UNLOCK_CONN_CACHE assert(pthread_mutex_unlock(&rxi_connCacheMutex)==0); +#define LOCK_CONN_CACHE assert(pthread_mutex_lock(&rxi_connCacheMutex)==0) +#define UNLOCK_CONN_CACHE assert(pthread_mutex_unlock(&rxi_connCacheMutex)==0) #else #define LOCK_CONN_CACHE #define UNLOCK_CONN_CACHE @@ -183,7 +183,8 @@ rxi_GetCachedConnection(rx_connParts_p parts, struct rx_connection **conn) * increase the frequency of cache hits. */ - LOCK_CONN_CACHE if (!rxi_FindCachedConnection(parts, conn)) { + LOCK_CONN_CACHE; + if (!rxi_FindCachedConnection(parts, conn)) { /* * Create a new connection and enter it in the cache */ @@ -195,7 +196,8 @@ rxi_GetCachedConnection(rx_connParts_p parts, struct rx_connection **conn) error = 1; } } - UNLOCK_CONN_CACHE return error; + UNLOCK_CONN_CACHE; + return error; } /* @@ -208,16 +210,16 @@ rxi_DeleteCachedConnections(void) { cache_entry_p cacheConn, nCacheConn; - LOCK_CONN_CACHE - for (queue_Scan - (&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) { + LOCK_CONN_CACHE; + for (queue_Scan(&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) { if (!cacheConn) break; queue_Remove(cacheConn); rxi_DestroyConnection(cacheConn->conn); free(cacheConn); } -UNLOCK_CONN_CACHE} + UNLOCK_CONN_CACHE; +} /* * External functions @@ -262,9 +264,8 @@ rx_ReleaseCachedConnection(struct rx_connection *conn) { cache_entry_p cacheConn, nCacheConn; - LOCK_CONN_CACHE - for (queue_Scan - (&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) { + LOCK_CONN_CACHE; + for (queue_Scan(&rxi_connectionCache, cacheConn, nCacheConn, cache_entry)) { if (conn == cacheConn->conn) { cacheConn->inUse--; /* @@ -284,4 +285,5 @@ rx_ReleaseCachedConnection(struct rx_connection *conn) break; } } -UNLOCK_CONN_CACHE} + UNLOCK_CONN_CACHE; +} diff --git a/src/rx/rx_event.c b/src/rx/rx_event.c index e703b165fb..3d78a3be3d 100644 --- a/src/rx/rx_event.c +++ b/src/rx/rx_event.c @@ -109,8 +109,8 @@ afs_kmutex_t rxevent_lock; #include pthread_mutex_t rx_event_mutex; -#define LOCK_EV_INIT assert(pthread_mutex_lock(&rx_event_mutex)==0); -#define UNLOCK_EV_INIT assert(pthread_mutex_unlock(&rx_event_mutex)==0); +#define LOCK_EV_INIT assert(pthread_mutex_lock(&rx_event_mutex)==0) +#define UNLOCK_EV_INIT assert(pthread_mutex_unlock(&rx_event_mutex)==0) #else #define LOCK_EV_INIT #define UNLOCK_EV_INIT @@ -122,8 +122,10 @@ int rxevent_initialized = 0; void rxevent_Init(int nEvents, void (*scheduler) (void)) { - LOCK_EV_INIT if (rxevent_initialized) { - UNLOCK_EV_INIT return; + LOCK_EV_INIT; + if (rxevent_initialized) { + UNLOCK_EV_INIT; + return; } MUTEX_INIT(&rxevent_lock, "rxevent_lock", MUTEX_DEFAULT, 0); clock_Init(); @@ -138,7 +140,8 @@ rxevent_Init(int nEvents, void (*scheduler) (void)) rxevent_initialized = 1; clock_Zero(&rxevent_nextRaiseEvents); rxevent_raiseScheduled = 0; -UNLOCK_EV_INIT} + UNLOCK_EV_INIT; +} /* Create and initialize new epoch structure */ struct rxepoch * @@ -413,11 +416,14 @@ shutdown_rxevent(void) { struct xfreelist *xp, *nxp; - LOCK_EV_INIT if (!rxevent_initialized) { - UNLOCK_EV_INIT return; + LOCK_EV_INIT; + if (!rxevent_initialized) { + UNLOCK_EV_INIT; + return; } rxevent_initialized = 0; - UNLOCK_EV_INIT MUTEX_DESTROY(&rxevent_lock); + UNLOCK_EV_INIT; + MUTEX_DESTROY(&rxevent_lock); #if defined(AFS_AIX32_ENV) && defined(KERNEL) /* Everything is freed in afs_osinet.c */ #else diff --git a/src/rx/rx_kcommon.c b/src/rx/rx_kcommon.c index c1b4872987..f0b2e8e983 100644 --- a/src/rx/rx_kcommon.c +++ b/src/rx/rx_kcommon.c @@ -516,7 +516,7 @@ rxi_GetcbiInfo(void) memset((void *)mtus, 0, sizeof(mtus)); for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) { - if (!afs_cb_interface.mtu[i]) + if (!afs_cb_interface.mtu[i]) afs_cb_interface.mtu[i] = htonl(1500); rxmtu = (ntohl(afs_cb_interface.mtu[i]) - RX_IPUDP_SIZE); ifinaddr = ntohl(afs_cb_interface.addr_in[i]); @@ -791,16 +791,17 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport) #if defined(AFS_HPUX102_ENV) #if defined(AFS_HPUX110_ENV) /* we need a file associated with the socket so sosend in NetSend - will not fail */ + * will not fail */ /* blocking socket */ code = socreate(AF_INET, &newSocket, SOCK_DGRAM, 0, 0); fp = falloc(); - if (!fp) goto bad; + if (!fp) + goto bad; fp->f_flag = FREAD | FWRITE; fp->f_type = DTYPE_SOCKET; - fp->f_ops = &socketops; + fp->f_ops = &socketops; - fp->f_data = (void *) newSocket; + fp->f_data = (void *)newSocket; newSocket->so_fp = (void *)fp; #else /* AFS_HPUX110_ENV */ @@ -930,11 +931,11 @@ rxk_FreeSocket(register struct socket *asocket) #endif #ifdef AFS_HPUX110_ENV if (asocket->so_fp) { - struct file * fp = asocket->so_fp; + struct file *fp = asocket->so_fp; #if !defined(AFS_HPUX1123_ENV) /* 11.23 still has falloc, but not FPENTRYFREE ! - so for now if we shutdown, we will waist a file - structure */ + * so for now if we shutdown, we will waist a file + * structure */ FPENTRYFREE(fp); asocket->so_fp = NULL; #endif diff --git a/src/rx/rx_misc.c b/src/rx/rx_misc.c index 3fc9ea2eaa..4b9761d189 100644 --- a/src/rx/rx_misc.c +++ b/src/rx/rx_misc.c @@ -109,8 +109,8 @@ ntoh_syserr_conv(int code) #include pthread_mutex_t osi_malloc_mutex; -#define LOCK_MALLOC_STATS assert(pthread_mutex_lock(&osi_malloc_mutex)==0); -#define UNLOCK_MALLOC_STATS assert(pthread_mutex_unlock(&osi_malloc_mutex)==0); +#define LOCK_MALLOC_STATS assert(pthread_mutex_lock(&osi_malloc_mutex)==0) +#define UNLOCK_MALLOC_STATS assert(pthread_mutex_unlock(&osi_malloc_mutex)==0) #else #define LOCK_MALLOC_STATS #define UNLOCK_MALLOC_STATS @@ -126,9 +126,11 @@ osi_alloc(afs_int32 x) */ if (x == 0) return (char *)&memZero; - LOCK_MALLOC_STATS osi_alloccnt++; + LOCK_MALLOC_STATS; + osi_alloccnt++; osi_allocsize += x; - UNLOCK_MALLOC_STATS return (char *)(mem_alloc(x)); + UNLOCK_MALLOC_STATS; + return (char *)(mem_alloc(x)); } int @@ -136,9 +138,11 @@ osi_free(char *x, afs_int32 size) { if ((x == &memZero) || !x) return 0; - LOCK_MALLOC_STATS osi_alloccnt--; + LOCK_MALLOC_STATS; + osi_alloccnt--; osi_allocsize -= size; - UNLOCK_MALLOC_STATS mem_free(x, size); + UNLOCK_MALLOC_STATS; + mem_free(x, size); return 0; } #endif diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c index f7a2859bf3..749777429c 100644 --- a/src/rx/rx_packet.c +++ b/src/rx/rx_packet.c @@ -833,8 +833,7 @@ rxi_ReadPacket(int socket, register struct rx_packet *p, afs_uint32 * host, MUTEX_ENTER(&rx_stats_mutex); rx_stats.noPacketOnRead++; MUTEX_EXIT(&rx_stats_mutex); - } - else { + } else { MUTEX_ENTER(&rx_stats_mutex); rx_stats.bogusPacketOnRead++; rx_stats.bogusHost = from.sin_addr.s_addr; @@ -1828,11 +1827,7 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn, assert(p != NULL); - dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", - deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], - peer->host, peer->port, p->header.serial, p->header.epoch, - p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, - (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length)); + dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length)); #endif MUTEX_ENTER(&rx_stats_mutex); diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index bd3d3b4bc2..4791d10925 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -156,7 +156,7 @@ event_handler(void *argp) next.sec = 30; /* Time to sleep if there are no events scheduled */ next.usec = 0; clock_GetTime(&cv); - rxevent_RaiseEvents(&next); + rxevent_RaiseEvents(&next); assert(pthread_mutex_lock(&event_handler_mutex) == 0); if (rx_pthread_event_rescheduled) { diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c index afa2292199..a3c6324791 100644 --- a/src/rx/rx_user.c +++ b/src/rx/rx_user.c @@ -66,8 +66,8 @@ RCSID */ pthread_mutex_t rx_if_init_mutex; -#define LOCK_IF_INIT assert(pthread_mutex_lock(&rx_if_init_mutex)==0); -#define UNLOCK_IF_INIT assert(pthread_mutex_unlock(&rx_if_init_mutex)==0); +#define LOCK_IF_INIT assert(pthread_mutex_lock(&rx_if_init_mutex)==0) +#define UNLOCK_IF_INIT assert(pthread_mutex_unlock(&rx_if_init_mutex)==0) /* * The rx_if_mutex mutex protects the following global variables: @@ -77,8 +77,8 @@ pthread_mutex_t rx_if_init_mutex; */ pthread_mutex_t rx_if_mutex; -#define LOCK_IF assert(pthread_mutex_lock(&rx_if_mutex)==0); -#define UNLOCK_IF assert(pthread_mutex_unlock(&rx_if_mutex)==0); +#define LOCK_IF assert(pthread_mutex_lock(&rx_if_mutex)==0) +#define UNLOCK_IF assert(pthread_mutex_unlock(&rx_if_mutex)==0) #else #define LOCK_IF_INIT #define UNLOCK_IF_INIT @@ -296,8 +296,10 @@ rx_getAllAddr(afs_int32 * buffer, int maxSize) void rx_GetIFInfo(void) { - LOCK_IF_INIT if (Inited) { - UNLOCK_IF_INIT return; + LOCK_IF_INIT; + if (Inited) { + UNLOCK_IF_INIT; + return; } else { u_int maxsize; u_int rxsize; @@ -305,10 +307,12 @@ rx_GetIFInfo(void) afs_uint32 i; Inited = 1; - UNLOCK_IF_INIT rxi_numNetAddrs = ADDRSPERSITE; + UNLOCK_IF_INIT; + rxi_numNetAddrs = ADDRSPERSITE; - LOCK_IF(void) syscfg_GetIFInfo(&rxi_numNetAddrs, rxi_NetAddrs, - myNetMasks, myNetMTUs, myNetFlags); + LOCK_IF; + (void)syscfg_GetIFInfo(&rxi_numNetAddrs, rxi_NetAddrs, + myNetMasks, myNetMTUs, myNetFlags); for (i = 0; i < rxi_numNetAddrs; i++) { rxsize = rxi_AdjustIfMTU(myNetMTUs[i] - RX_IPUDP_SIZE); @@ -322,7 +326,8 @@ rx_GetIFInfo(void) } } - UNLOCK_IF ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE); + UNLOCK_IF; + ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE); if (ncbufs > 0) { ncbufs = ncbufs / RX_CBUFFERSIZE; npackets = rx_initSendWindow - 1; @@ -391,16 +396,21 @@ rx_GetIFInfo(void) struct sockaddr_in *a; #endif /* AFS_DJGPP_ENV */ - LOCK_IF_INIT if (Inited) { - UNLOCK_IF_INIT return; + LOCK_IF_INIT; + if (Inited) { + UNLOCK_IF_INIT; + return; } Inited = 1; - UNLOCK_IF_INIT LOCK_IF rxi_numNetAddrs = 0; + UNLOCK_IF_INIT; + LOCK_IF; + rxi_numNetAddrs = 0; memset(rxi_NetAddrs, 0, sizeof(rxi_NetAddrs)); memset(myNetFlags, 0, sizeof(myNetFlags)); memset(myNetMTUs, 0, sizeof(myNetMTUs)); memset(myNetMasks, 0, sizeof(myNetMasks)); - UNLOCK_IF s = socket(AF_INET, SOCK_DGRAM, 0); + UNLOCK_IF; + s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) return; @@ -421,10 +431,10 @@ rx_GetIFInfo(void) return; } - LOCK_IF + LOCK_IF; #ifdef AFS_AIX41_ENV #define size(p) MAX((p).sa_len, sizeof(p)) - cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */ + cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */ for (cp = buf; cp < cplim; cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a))) { if (rxi_numNetAddrs >= ADDRSPERSITE) @@ -432,7 +442,7 @@ rx_GetIFInfo(void) ifr = (struct ifreq *)cp; #else - len = ifc.ifc_len / sizeof(struct ifreq); + len = ifc.ifc_len / sizeof(struct ifreq); if (len > ADDRSPERSITE) len = ADDRSPERSITE; @@ -552,7 +562,8 @@ rx_GetIFInfo(void) ++rxi_numNetAddrs; } } - UNLOCK_IF close(s); + UNLOCK_IF; + close(s); /* have to allocate at least enough to allow a single packet to reach its * maximum size, so ReadPacket will work. Allocate enough for a couple @@ -594,15 +605,17 @@ rxi_InitPeerParams(struct rx_peer *pp) - LOCK_IF_INIT if (!Inited) { - UNLOCK_IF_INIT - /* - * there's a race here since more than one thread could call - * rx_GetIFInfo. The race stops in rx_GetIFInfo. - */ - rx_GetIFInfo(); + LOCK_IF_INIT; + if (!Inited) { + UNLOCK_IF_INIT; + /* + * there's a race here since more than one thread could call + * rx_GetIFInfo. The race stops in rx_GetIFInfo. + */ + rx_GetIFInfo(); } else { - UNLOCK_IF_INIT} + UNLOCK_IF_INIT; + } #ifdef ADAPT_MTU /* try to second-guess IP, and identify which link is most likely to @@ -616,7 +629,8 @@ rxi_InitPeerParams(struct rx_peer *pp) * pp->burstSize pp->burst pp->burstWait.sec pp->burstWait.usec * pp->timeout.usec */ - LOCK_IF for (ix = 0; ix < rxi_numNetAddrs; ++ix) { + LOCK_IF; + for (ix = 0; ix < rxi_numNetAddrs; ++ix) { if ((rxi_NetAddrs[ix] & myNetMasks[ix]) == (ppaddr & myNetMasks[ix])) { #ifdef IFF_POINTOPOINT if (myNetFlags[ix] & IFF_POINTOPOINT) @@ -629,7 +643,8 @@ rxi_InitPeerParams(struct rx_peer *pp) pp->ifMTU = MIN(rx_MyMaxSendSize, rxmtu); } } - UNLOCK_IF if (!pp->ifMTU) { /* not local */ + UNLOCK_IF; + if (!pp->ifMTU) { /* not local */ pp->timeout.sec = 3; pp->ifMTU = MIN(rx_MyMaxSendSize, RX_REMOTE_PACKET_SIZE); } @@ -665,8 +680,8 @@ rx_SetNoJumbo(void) /* Override max MTU. If rx_SetNoJumbo is called, it must be called before calling rx_SetMaxMTU since SetNoJumbo clobbers rx_maxReceiveSize */ -void rx_SetMaxMTU(int mtu) +void +rx_SetMaxMTU(int mtu) { - rx_MyMaxSendSize = rx_maxReceiveSizeUser = rx_maxReceiveSize = mtu; + rx_MyMaxSendSize = rx_maxReceiveSizeUser = rx_maxReceiveSize = mtu; } - diff --git a/src/rx/rx_user.h b/src/rx/rx_user.h index a11a4cedd0..3810be4035 100644 --- a/src/rx/rx_user.h +++ b/src/rx/rx_user.h @@ -28,8 +28,8 @@ error - foo error - foo error - foo #define AFS_RXGUNLOCK() #ifndef UKERNEL /* Defined in rx/UKERNEL/rx_kmutex.h */ -#define ISAFS_GLOCK() -#define ISAFS_RXGLOCK() +#define ISAFS_GLOCK() +#define ISAFS_RXGLOCK() #endif #define AFS_ASSERT_RXGLOCK() /* Some "operating-system independent" stuff, for the user mode implementation */ diff --git a/src/rx/rx_xmit_nt.c b/src/rx/rx_xmit_nt.c index 4c56679e50..8ce42e558f 100644 --- a/src/rx/rx_xmit_nt.c +++ b/src/rx/rx_xmit_nt.c @@ -79,12 +79,12 @@ recvmsg(int socket, struct msghdr *msgP, int flags) code -= size; } else { #ifdef AFS_NT40_ENV - if (code == SOCKET_ERROR) - code = WSAGetLastError(); - if (code == WSAEWOULDBLOCK) - errno = WSAEWOULDBLOCK; - else - errno = EIO; + if (code == SOCKET_ERROR) + code = WSAGetLastError(); + if (code == WSAEWOULDBLOCK) + errno = WSAEWOULDBLOCK; + else + errno = EIO; #endif /* AFS_NT40_ENV */ code = -1; } @@ -136,9 +136,9 @@ sendmsg(int socket, struct msghdr *msgP, int flags) case WSAENOBUFS: errno = 0; break; - case WSAEWOULDBLOCK: - errno = WSAEWOULDBLOCK; - break; + case WSAEWOULDBLOCK: + errno = WSAEWOULDBLOCK; + break; default: errno = EIO; break; diff --git a/src/rx/rxdebug.c b/src/rx/rxdebug.c index ee716baf54..db94347e1d 100644 --- a/src/rx/rxdebug.c +++ b/src/rx/rxdebug.c @@ -333,7 +333,7 @@ MainCommand(as, arock) printf("getconn call failed with code %d\n", code); break; } - if (tconn.cid == (afs_int32)0xffffffff) { + if (tconn.cid == (afs_int32) 0xffffffff) { printf("Done.\n"); break; } diff --git a/src/rx/xdr_int64.c b/src/rx/xdr_int64.c index 7ee00727c1..c7afdf0cc7 100644 --- a/src/rx/xdr_int64.c +++ b/src/rx/xdr_int64.c @@ -53,8 +53,8 @@ xdr_afs_int64(register XDR * xdrs, afs_int64 * ulp) return (TRUE); } if (xdrs->x_op == XDR_ENCODE) { - high = (afs_int32)(*ulp >> 32); - low = (afs_uint32)(*ulp & 0xFFFFFFFFL); + high = (afs_int32) (*ulp >> 32); + low = (afs_uint32) (*ulp & 0xFFFFFFFFL); if (!XDR_PUTINT32(xdrs, (afs_int32 *) & high)) return (FALSE); return (XDR_PUTINT32(xdrs, (afs_int32 *) & low)); @@ -90,8 +90,8 @@ xdr_afs_uint64(register XDR * xdrs, afs_uint64 * ulp) return (TRUE); } if (xdrs->x_op == XDR_ENCODE) { - high = (afs_uint32)(*ulp >> 32); - low = (afs_uint32)(*ulp & 0xFFFFFFFFL); + high = (afs_uint32) (*ulp >> 32); + low = (afs_uint32) (*ulp & 0xFFFFFFFFL); if (!XDR_PUTINT32(xdrs, (afs_uint32 *) & high)) return (FALSE); return (XDR_PUTINT32(xdrs, (afs_uint32 *) & low)); diff --git a/src/rxkad/bg-fcrypt.c b/src/rxkad/bg-fcrypt.c index d21fc7456e..5892e7bfbc 100644 --- a/src/rxkad/bg-fcrypt.c +++ b/src/rxkad/bg-fcrypt.c @@ -507,9 +507,11 @@ afs_int32 fc_ecb_encrypt(afs_uint32 * in, afs_uint32 * out, fc_KeySchedule sched, int encrypt) { - LOCK_RXKAD_STATS rxkad_stats.fc_encrypts[encrypt]++; - UNLOCK_RXKAD_STATS if (encrypt) - fc_ecb_enc(in[0], in[1], out, sched); + LOCK_RXKAD_STATS; + rxkad_stats.fc_encrypts[encrypt]++; + UNLOCK_RXKAD_STATS; + if (encrypt) + fc_ecb_enc(in[0], in[1], out, sched); else fc_ecb_dec(in[0], in[1], out, sched); return 0; @@ -667,8 +669,10 @@ fc_keysched(void *key_, fc_KeySchedule sched) ROT56R(hi, lo, 11); *sched++ = EFF_NTOHL(lo); #endif - LOCK_RXKAD_STATS rxkad_stats.fc_key_scheds++; - UNLOCK_RXKAD_STATS return 0; + LOCK_RXKAD_STATS; + rxkad_stats.fc_key_scheds++; + UNLOCK_RXKAD_STATS; + return 0; } /* @@ -688,9 +692,10 @@ rxkad_EncryptPacket(const struct rx_connection * rx_connection_not_used, obj = rx_SecurityObjectOf(rx_connection_not_used); tp = (struct rxkad_cprivate *)obj->privateData; - LOCK_RXKAD_STATS rxkad_stats.bytesEncrypted[rxkad_TypeIndex(tp->type)] += - len; - UNLOCK_RXKAD_STATS { + LOCK_RXKAD_STATS; + rxkad_stats.bytesEncrypted[rxkad_TypeIndex(tp->type)] += len; + UNLOCK_RXKAD_STATS; + { /* What is this good for? * It turns out that the security header for auth_enc is of * size 8 bytes and the last 4 bytes are defined to be 0! @@ -725,9 +730,10 @@ rxkad_DecryptPacket(const struct rx_connection * rx_connection_not_used, obj = rx_SecurityObjectOf(rx_connection_not_used); tp = (struct rxkad_cprivate *)obj->privateData; - LOCK_RXKAD_STATS rxkad_stats.bytesDecrypted[rxkad_TypeIndex(tp->type)] += - len; - UNLOCK_RXKAD_STATS memcpy(ivec, iv, sizeof(ivec)); /* Must use copy of iv */ + LOCK_RXKAD_STATS; + rxkad_stats.bytesDecrypted[rxkad_TypeIndex(tp->type)] += len; + UNLOCK_RXKAD_STATS; + memcpy(ivec, iv, sizeof(ivec)); /* Must use copy of iv */ for (frag = &packet->wirevec[1]; len > 0; frag++) { int iov_len = frag->iov_len; afs_uint32 *iov_bas = (afs_uint32 *) frag->iov_base; diff --git a/src/rxkad/hash.h b/src/rxkad/hash.h index ade01ff1ca..481dc27918 100644 --- a/src/rxkad/hash.h +++ b/src/rxkad/hash.h @@ -62,7 +62,7 @@ #endif static inline afs_uint32 -cshift (afs_uint32 x, unsigned int n) +cshift(afs_uint32 x, unsigned int n) { x = CRAYFIX(x); return CRAYFIX((x << n) | (x >> (32 - n))); diff --git a/src/rxkad/md4.c b/src/rxkad/md4.c index 5b479647cb..7bc3cee383 100644 --- a/src/rxkad/md4.c +++ b/src/rxkad/md4.c @@ -86,14 +86,14 @@ RCSID("$Id$"); #define X data void -MD4_Init (struct md4 *m) +MD4_Init(struct md4 *m) { - m->sz[0] = 0; - m->sz[1] = 0; - D = 0x10325476; - C = 0x98badcfe; - B = 0xefcdab89; - A = 0x67452301; + m->sz[0] = 0; + m->sz[1] = 0; + D = 0x10325476; + C = 0x98badcfe; + B = 0xefcdab89; + A = 0x67452301; } #define F(x,y,z) CRAYFIX((x & y) | (~x & z)) @@ -108,85 +108,85 @@ a = cshift(a + OP(b,c,d) + X[k] + i, s) #define DO3(a,b,c,d,k,s,i) DOIT(a,b,c,d,k,s,i,H) static inline void -calc (struct md4 *m, afs_uint32 *data) +calc(struct md4 *m, afs_uint32 * data) { - afs_uint32 AA, BB, CC, DD; + afs_uint32 AA, BB, CC, DD; - AA = A; - BB = B; - CC = C; - DD = D; + AA = A; + BB = B; + CC = C; + DD = D; - /* Round 1 */ + /* Round 1 */ - DO1(A,B,C,D,0,3,0); - DO1(D,A,B,C,1,7,0); - DO1(C,D,A,B,2,11,0); - DO1(B,C,D,A,3,19,0); + DO1(A, B, C, D, 0, 3, 0); + DO1(D, A, B, C, 1, 7, 0); + DO1(C, D, A, B, 2, 11, 0); + DO1(B, C, D, A, 3, 19, 0); - DO1(A,B,C,D,4,3,0); - DO1(D,A,B,C,5,7,0); - DO1(C,D,A,B,6,11,0); - DO1(B,C,D,A,7,19,0); + DO1(A, B, C, D, 4, 3, 0); + DO1(D, A, B, C, 5, 7, 0); + DO1(C, D, A, B, 6, 11, 0); + DO1(B, C, D, A, 7, 19, 0); - DO1(A,B,C,D,8,3,0); - DO1(D,A,B,C,9,7,0); - DO1(C,D,A,B,10,11,0); - DO1(B,C,D,A,11,19,0); + DO1(A, B, C, D, 8, 3, 0); + DO1(D, A, B, C, 9, 7, 0); + DO1(C, D, A, B, 10, 11, 0); + DO1(B, C, D, A, 11, 19, 0); - DO1(A,B,C,D,12,3,0); - DO1(D,A,B,C,13,7,0); - DO1(C,D,A,B,14,11,0); - DO1(B,C,D,A,15,19,0); + DO1(A, B, C, D, 12, 3, 0); + DO1(D, A, B, C, 13, 7, 0); + DO1(C, D, A, B, 14, 11, 0); + DO1(B, C, D, A, 15, 19, 0); - /* Round 2 */ + /* Round 2 */ - DO2(A,B,C,D,0,3,0x5A827999); - DO2(D,A,B,C,4,5,0x5A827999); - DO2(C,D,A,B,8,9,0x5A827999); - DO2(B,C,D,A,12,13,0x5A827999); + DO2(A, B, C, D, 0, 3, 0x5A827999); + DO2(D, A, B, C, 4, 5, 0x5A827999); + DO2(C, D, A, B, 8, 9, 0x5A827999); + DO2(B, C, D, A, 12, 13, 0x5A827999); - DO2(A,B,C,D,1,3,0x5A827999); - DO2(D,A,B,C,5,5,0x5A827999); - DO2(C,D,A,B,9,9,0x5A827999); - DO2(B,C,D,A,13,13,0x5A827999); + DO2(A, B, C, D, 1, 3, 0x5A827999); + DO2(D, A, B, C, 5, 5, 0x5A827999); + DO2(C, D, A, B, 9, 9, 0x5A827999); + DO2(B, C, D, A, 13, 13, 0x5A827999); - DO2(A,B,C,D,2,3,0x5A827999); - DO2(D,A,B,C,6,5,0x5A827999); - DO2(C,D,A,B,10,9,0x5A827999); - DO2(B,C,D,A,14,13,0x5A827999); + DO2(A, B, C, D, 2, 3, 0x5A827999); + DO2(D, A, B, C, 6, 5, 0x5A827999); + DO2(C, D, A, B, 10, 9, 0x5A827999); + DO2(B, C, D, A, 14, 13, 0x5A827999); - DO2(A,B,C,D,3,3,0x5A827999); - DO2(D,A,B,C,7,5,0x5A827999); - DO2(C,D,A,B,11,9,0x5A827999); - DO2(B,C,D,A,15,13,0x5A827999); + DO2(A, B, C, D, 3, 3, 0x5A827999); + DO2(D, A, B, C, 7, 5, 0x5A827999); + DO2(C, D, A, B, 11, 9, 0x5A827999); + DO2(B, C, D, A, 15, 13, 0x5A827999); - /* Round 3 */ + /* Round 3 */ - DO3(A,B,C,D,0,3,0x6ED9EBA1); - DO3(D,A,B,C,8,9,0x6ED9EBA1); - DO3(C,D,A,B,4,11,0x6ED9EBA1); - DO3(B,C,D,A,12,15,0x6ED9EBA1); + DO3(A, B, C, D, 0, 3, 0x6ED9EBA1); + DO3(D, A, B, C, 8, 9, 0x6ED9EBA1); + DO3(C, D, A, B, 4, 11, 0x6ED9EBA1); + DO3(B, C, D, A, 12, 15, 0x6ED9EBA1); - DO3(A,B,C,D,2,3,0x6ED9EBA1); - DO3(D,A,B,C,10,9,0x6ED9EBA1); - DO3(C,D,A,B,6,11,0x6ED9EBA1); - DO3(B,C,D,A,14,15,0x6ED9EBA1); + DO3(A, B, C, D, 2, 3, 0x6ED9EBA1); + DO3(D, A, B, C, 10, 9, 0x6ED9EBA1); + DO3(C, D, A, B, 6, 11, 0x6ED9EBA1); + DO3(B, C, D, A, 14, 15, 0x6ED9EBA1); - DO3(A,B,C,D,1,3,0x6ED9EBA1); - DO3(D,A,B,C,9,9,0x6ED9EBA1); - DO3(C,D,A,B,5,11,0x6ED9EBA1); - DO3(B,C,D,A,13,15,0x6ED9EBA1); + DO3(A, B, C, D, 1, 3, 0x6ED9EBA1); + DO3(D, A, B, C, 9, 9, 0x6ED9EBA1); + DO3(C, D, A, B, 5, 11, 0x6ED9EBA1); + DO3(B, C, D, A, 13, 15, 0x6ED9EBA1); - DO3(A,B,C,D,3,3,0x6ED9EBA1); - DO3(D,A,B,C,11,9,0x6ED9EBA1); - DO3(C,D,A,B,7,11,0x6ED9EBA1); - DO3(B,C,D,A,15,15,0x6ED9EBA1); + DO3(A, B, C, D, 3, 3, 0x6ED9EBA1); + DO3(D, A, B, C, 11, 9, 0x6ED9EBA1); + DO3(C, D, A, B, 7, 11, 0x6ED9EBA1); + DO3(B, C, D, A, 15, 15, 0x6ED9EBA1); - A += AA; - B += BB; - C += CC; - D += DD; + A += AA; + B += BB; + C += CC; + D += DD; } /* @@ -195,26 +195,26 @@ calc (struct md4 *m, afs_uint32 *data) #if defined(WORDS_BIGENDIAN) static inline afs_uint32 -swap_afs_uint32 (afs_uint32 t) +swap_afs_uint32(afs_uint32 t) { - afs_uint32 temp1, temp2; + afs_uint32 temp1, temp2; - temp1 = cshift(t, 16); - temp2 = temp1 >> 8; - temp1 &= 0x00ff00ff; - temp2 &= 0x00ff00ff; - temp1 <<= 8; - return temp1 | temp2; + temp1 = cshift(t, 16); + temp2 = temp1 >> 8; + temp1 &= 0x00ff00ff; + temp2 &= 0x00ff00ff; + temp1 <<= 8; + return temp1 | temp2; } #endif -struct x32{ - unsigned int a:32; - unsigned int b:32; +struct x32 { + unsigned int a:32; + unsigned int b:32; }; void -MD4_Update (struct md4 *m, const void *v, size_t len) +MD4_Update(struct md4 *m, const void *v, size_t len) { const unsigned char *p = v; size_t old_sz = m->sz[0]; @@ -223,25 +223,25 @@ MD4_Update (struct md4 *m, const void *v, size_t len) m->sz[0] += len * 8; if (m->sz[0] < old_sz) ++m->sz[1]; - offset = (old_sz / 8) % 64; - while(len > 0) { + offset = (old_sz / 8) % 64; + while (len > 0) { size_t l = min(len, 64 - offset); memcpy(m->save + offset, p, l); offset += l; p += l; len -= l; - if(offset == 64) { + if (offset == 64) { #if defined(WORDS_BIGENDIAN) int i; afs_uint32 current[16]; - struct x32 *u = (struct x32*)m->save; - for(i = 0; i < 8; i++){ - current[2*i+0] = swap_afs_uint32(u[i].a); - current[2*i+1] = swap_afs_uint32(u[i].b); + struct x32 *u = (struct x32 *)m->save; + for (i = 0; i < 8; i++) { + current[2 * i + 0] = swap_afs_uint32(u[i].a); + current[2 * i + 1] = swap_afs_uint32(u[i].b); } calc(m, current); #else - calc(m, (afs_uint32*)m->save); + calc(m, (afs_uint32 *) m->save); #endif offset = 0; } @@ -249,41 +249,41 @@ MD4_Update (struct md4 *m, const void *v, size_t len) } void -MD4_Final (void *res, struct md4 *m) +MD4_Final(void *res, struct md4 *m) { - static unsigned char zeros[72]; - unsigned offset = (m->sz[0] / 8) % 64; - unsigned int dstart = (120 - offset - 1) % 64 + 1; + static unsigned char zeros[72]; + unsigned offset = (m->sz[0] / 8) % 64; + unsigned int dstart = (120 - offset - 1) % 64 + 1; - *zeros = 0x80; - memset (zeros + 1, 0, sizeof(zeros) - 1); - zeros[dstart+0] = (m->sz[0] >> 0) & 0xff; - zeros[dstart+1] = (m->sz[0] >> 8) & 0xff; - zeros[dstart+2] = (m->sz[0] >> 16) & 0xff; - zeros[dstart+3] = (m->sz[0] >> 24) & 0xff; - zeros[dstart+4] = (m->sz[1] >> 0) & 0xff; - zeros[dstart+5] = (m->sz[1] >> 8) & 0xff; - zeros[dstart+6] = (m->sz[1] >> 16) & 0xff; - zeros[dstart+7] = (m->sz[1] >> 24) & 0xff; - MD4_Update (m, zeros, dstart + 8); - { - int i; - unsigned char *r = (unsigned char *)res; + *zeros = 0x80; + memset(zeros + 1, 0, sizeof(zeros) - 1); + zeros[dstart + 0] = (m->sz[0] >> 0) & 0xff; + zeros[dstart + 1] = (m->sz[0] >> 8) & 0xff; + zeros[dstart + 2] = (m->sz[0] >> 16) & 0xff; + zeros[dstart + 3] = (m->sz[0] >> 24) & 0xff; + zeros[dstart + 4] = (m->sz[1] >> 0) & 0xff; + zeros[dstart + 5] = (m->sz[1] >> 8) & 0xff; + zeros[dstart + 6] = (m->sz[1] >> 16) & 0xff; + zeros[dstart + 7] = (m->sz[1] >> 24) & 0xff; + MD4_Update(m, zeros, dstart + 8); + { + int i; + unsigned char *r = (unsigned char *)res; - for (i = 0; i < 4; ++i) { - r[4*i] = m->counter[i] & 0xFF; - r[4*i+1] = (m->counter[i] >> 8) & 0xFF; - r[4*i+2] = (m->counter[i] >> 16) & 0xFF; - r[4*i+3] = (m->counter[i] >> 24) & 0xFF; - } - } + for (i = 0; i < 4; ++i) { + r[4 * i] = m->counter[i] & 0xFF; + r[4 * i + 1] = (m->counter[i] >> 8) & 0xFF; + r[4 * i + 2] = (m->counter[i] >> 16) & 0xFF; + r[4 * i + 3] = (m->counter[i] >> 24) & 0xFF; + } + } #if 0 - { - int i; - afs_uint32 *r = (afs_uint32 *)res; + { + int i; + afs_uint32 *r = (afs_uint32 *) res; - for (i = 0; i < 4; ++i) - r[i] = swap_afs_uint32 (m->counter[i]); - } + for (i = 0; i < 4; ++i) + r[i] = swap_afs_uint32(m->counter[i]); + } #endif } diff --git a/src/rxkad/md4.h b/src/rxkad/md4.h index 710eb48766..7e19358df0 100644 --- a/src/rxkad/md4.h +++ b/src/rxkad/md4.h @@ -42,13 +42,13 @@ #endif struct md4 { - unsigned int sz[2]; - afs_uint32 counter[4]; - unsigned char save[64]; + unsigned int sz[2]; + afs_uint32 counter[4]; + unsigned char save[64]; }; typedef struct md4 MD4_CTX; -void MD4_Init (struct md4 *m); -void MD4_Update (struct md4 *m, const void *p, size_t len); -void MD4_Final (void *res, struct md4 *m); +void MD4_Init(struct md4 *m); +void MD4_Update(struct md4 *m, const void *p, size_t len); +void MD4_Final(void *res, struct md4 *m); diff --git a/src/rxkad/md5.c b/src/rxkad/md5.c index 59190120ea..7b3b4b79fc 100644 --- a/src/rxkad/md5.c +++ b/src/rxkad/md5.c @@ -86,14 +86,14 @@ RCSID("$Id$"); #define X data void -MD5_Init (struct md5 *m) +MD5_Init(struct md5 *m) { - m->sz[0] = 0; - m->sz[1] = 0; - D = 0x10325476; - C = 0x98badcfe; - B = 0xefcdab89; - A = 0x67452301; + m->sz[0] = 0; + m->sz[1] = 0; + D = 0x10325476; + C = 0x98badcfe; + B = 0xefcdab89; + A = 0x67452301; } #define F(x,y,z) CRAYFIX((x & y) | (~x & z)) @@ -110,107 +110,107 @@ a = b + cshift(a + OP(b,c,d) + X[k] + (i), s) #define DO4(a,b,c,d,k,s,i) DOIT(a,b,c,d,k,s,i,I) static inline void -calc (struct md5 *m, afs_uint32 *data) +calc(struct md5 *m, afs_uint32 * data) { - afs_uint32 AA, BB, CC, DD; + afs_uint32 AA, BB, CC, DD; - AA = A; - BB = B; - CC = C; - DD = D; + AA = A; + BB = B; + CC = C; + DD = D; - /* Round 1 */ + /* Round 1 */ - DO1(A,B,C,D,0,7,0xd76aa478); - DO1(D,A,B,C,1,12,0xe8c7b756); - DO1(C,D,A,B,2,17,0x242070db); - DO1(B,C,D,A,3,22,0xc1bdceee); + DO1(A, B, C, D, 0, 7, 0xd76aa478); + DO1(D, A, B, C, 1, 12, 0xe8c7b756); + DO1(C, D, A, B, 2, 17, 0x242070db); + DO1(B, C, D, A, 3, 22, 0xc1bdceee); - DO1(A,B,C,D,4,7,0xf57c0faf); - DO1(D,A,B,C,5,12,0x4787c62a); - DO1(C,D,A,B,6,17,0xa8304613); - DO1(B,C,D,A,7,22,0xfd469501); + DO1(A, B, C, D, 4, 7, 0xf57c0faf); + DO1(D, A, B, C, 5, 12, 0x4787c62a); + DO1(C, D, A, B, 6, 17, 0xa8304613); + DO1(B, C, D, A, 7, 22, 0xfd469501); - DO1(A,B,C,D,8,7,0x698098d8); - DO1(D,A,B,C,9,12,0x8b44f7af); - DO1(C,D,A,B,10,17,0xffff5bb1); - DO1(B,C,D,A,11,22,0x895cd7be); + DO1(A, B, C, D, 8, 7, 0x698098d8); + DO1(D, A, B, C, 9, 12, 0x8b44f7af); + DO1(C, D, A, B, 10, 17, 0xffff5bb1); + DO1(B, C, D, A, 11, 22, 0x895cd7be); - DO1(A,B,C,D,12,7,0x6b901122); - DO1(D,A,B,C,13,12,0xfd987193); - DO1(C,D,A,B,14,17,0xa679438e); - DO1(B,C,D,A,15,22,0x49b40821); + DO1(A, B, C, D, 12, 7, 0x6b901122); + DO1(D, A, B, C, 13, 12, 0xfd987193); + DO1(C, D, A, B, 14, 17, 0xa679438e); + DO1(B, C, D, A, 15, 22, 0x49b40821); - /* Round 2 */ + /* Round 2 */ - DO2(A,B,C,D,1,5,0xf61e2562); - DO2(D,A,B,C,6,9,0xc040b340); - DO2(C,D,A,B,11,14,0x265e5a51); - DO2(B,C,D,A,0,20,0xe9b6c7aa); + DO2(A, B, C, D, 1, 5, 0xf61e2562); + DO2(D, A, B, C, 6, 9, 0xc040b340); + DO2(C, D, A, B, 11, 14, 0x265e5a51); + DO2(B, C, D, A, 0, 20, 0xe9b6c7aa); - DO2(A,B,C,D,5,5,0xd62f105d); - DO2(D,A,B,C,10,9,0x2441453); - DO2(C,D,A,B,15,14,0xd8a1e681); - DO2(B,C,D,A,4,20,0xe7d3fbc8); + DO2(A, B, C, D, 5, 5, 0xd62f105d); + DO2(D, A, B, C, 10, 9, 0x2441453); + DO2(C, D, A, B, 15, 14, 0xd8a1e681); + DO2(B, C, D, A, 4, 20, 0xe7d3fbc8); - DO2(A,B,C,D,9,5,0x21e1cde6); - DO2(D,A,B,C,14,9,0xc33707d6); - DO2(C,D,A,B,3,14,0xf4d50d87); - DO2(B,C,D,A,8,20,0x455a14ed); + DO2(A, B, C, D, 9, 5, 0x21e1cde6); + DO2(D, A, B, C, 14, 9, 0xc33707d6); + DO2(C, D, A, B, 3, 14, 0xf4d50d87); + DO2(B, C, D, A, 8, 20, 0x455a14ed); - DO2(A,B,C,D,13,5,0xa9e3e905); - DO2(D,A,B,C,2,9,0xfcefa3f8); - DO2(C,D,A,B,7,14,0x676f02d9); - DO2(B,C,D,A,12,20,0x8d2a4c8a); + DO2(A, B, C, D, 13, 5, 0xa9e3e905); + DO2(D, A, B, C, 2, 9, 0xfcefa3f8); + DO2(C, D, A, B, 7, 14, 0x676f02d9); + DO2(B, C, D, A, 12, 20, 0x8d2a4c8a); - /* Round 3 */ + /* Round 3 */ - DO3(A,B,C,D,5,4,0xfffa3942); - DO3(D,A,B,C,8,11,0x8771f681); - DO3(C,D,A,B,11,16,0x6d9d6122); - DO3(B,C,D,A,14,23,0xfde5380c); + DO3(A, B, C, D, 5, 4, 0xfffa3942); + DO3(D, A, B, C, 8, 11, 0x8771f681); + DO3(C, D, A, B, 11, 16, 0x6d9d6122); + DO3(B, C, D, A, 14, 23, 0xfde5380c); - DO3(A,B,C,D,1,4,0xa4beea44); - DO3(D,A,B,C,4,11,0x4bdecfa9); - DO3(C,D,A,B,7,16,0xf6bb4b60); - DO3(B,C,D,A,10,23,0xbebfbc70); + DO3(A, B, C, D, 1, 4, 0xa4beea44); + DO3(D, A, B, C, 4, 11, 0x4bdecfa9); + DO3(C, D, A, B, 7, 16, 0xf6bb4b60); + DO3(B, C, D, A, 10, 23, 0xbebfbc70); - DO3(A,B,C,D,13,4,0x289b7ec6); - DO3(D,A,B,C,0,11,0xeaa127fa); - DO3(C,D,A,B,3,16,0xd4ef3085); - DO3(B,C,D,A,6,23,0x4881d05); + DO3(A, B, C, D, 13, 4, 0x289b7ec6); + DO3(D, A, B, C, 0, 11, 0xeaa127fa); + DO3(C, D, A, B, 3, 16, 0xd4ef3085); + DO3(B, C, D, A, 6, 23, 0x4881d05); - DO3(A,B,C,D,9,4,0xd9d4d039); - DO3(D,A,B,C,12,11,0xe6db99e5); - DO3(C,D,A,B,15,16,0x1fa27cf8); - DO3(B,C,D,A,2,23,0xc4ac5665); + DO3(A, B, C, D, 9, 4, 0xd9d4d039); + DO3(D, A, B, C, 12, 11, 0xe6db99e5); + DO3(C, D, A, B, 15, 16, 0x1fa27cf8); + DO3(B, C, D, A, 2, 23, 0xc4ac5665); - /* Round 4 */ + /* Round 4 */ - DO4(A,B,C,D,0,6,0xf4292244); - DO4(D,A,B,C,7,10,0x432aff97); - DO4(C,D,A,B,14,15,0xab9423a7); - DO4(B,C,D,A,5,21,0xfc93a039); + DO4(A, B, C, D, 0, 6, 0xf4292244); + DO4(D, A, B, C, 7, 10, 0x432aff97); + DO4(C, D, A, B, 14, 15, 0xab9423a7); + DO4(B, C, D, A, 5, 21, 0xfc93a039); - DO4(A,B,C,D,12,6,0x655b59c3); - DO4(D,A,B,C,3,10,0x8f0ccc92); - DO4(C,D,A,B,10,15,0xffeff47d); - DO4(B,C,D,A,1,21,0x85845dd1); + DO4(A, B, C, D, 12, 6, 0x655b59c3); + DO4(D, A, B, C, 3, 10, 0x8f0ccc92); + DO4(C, D, A, B, 10, 15, 0xffeff47d); + DO4(B, C, D, A, 1, 21, 0x85845dd1); - DO4(A,B,C,D,8,6,0x6fa87e4f); - DO4(D,A,B,C,15,10,0xfe2ce6e0); - DO4(C,D,A,B,6,15,0xa3014314); - DO4(B,C,D,A,13,21,0x4e0811a1); + DO4(A, B, C, D, 8, 6, 0x6fa87e4f); + DO4(D, A, B, C, 15, 10, 0xfe2ce6e0); + DO4(C, D, A, B, 6, 15, 0xa3014314); + DO4(B, C, D, A, 13, 21, 0x4e0811a1); - DO4(A,B,C,D,4,6,0xf7537e82); - DO4(D,A,B,C,11,10,0xbd3af235); - DO4(C,D,A,B,2,15,0x2ad7d2bb); - DO4(B,C,D,A,9,21,0xeb86d391); + DO4(A, B, C, D, 4, 6, 0xf7537e82); + DO4(D, A, B, C, 11, 10, 0xbd3af235); + DO4(C, D, A, B, 2, 15, 0x2ad7d2bb); + DO4(B, C, D, A, 9, 21, 0xeb86d391); - A += AA; - B += BB; - C += CC; - D += DD; + A += AA; + B += BB; + C += CC; + D += DD; } /* @@ -219,95 +219,95 @@ calc (struct md5 *m, afs_uint32 *data) #if defined(WORDS_BIGENDIAN) static inline afs_uint32 -swap_afs_uint32 (afs_uint32 t) +swap_afs_uint32(afs_uint32 t) { - afs_uint32 temp1, temp2; + afs_uint32 temp1, temp2; - temp1 = cshift(t, 16); - temp2 = temp1 >> 8; - temp1 &= 0x00ff00ff; - temp2 &= 0x00ff00ff; - temp1 <<= 8; - return temp1 | temp2; + temp1 = cshift(t, 16); + temp2 = temp1 >> 8; + temp1 &= 0x00ff00ff; + temp2 &= 0x00ff00ff; + temp1 <<= 8; + return temp1 | temp2; } #endif -struct x32{ - unsigned int a:32; - unsigned int b:32; +struct x32 { + unsigned int a:32; + unsigned int b:32; }; void -MD5_Update (struct md5 *m, const void *v, size_t len) +MD5_Update(struct md5 *m, const void *v, size_t len) { - const unsigned char *p = v; - size_t old_sz = m->sz[0]; - size_t offset; + const unsigned char *p = v; + size_t old_sz = m->sz[0]; + size_t offset; - m->sz[0] += len * 8; - if (m->sz[0] < old_sz) - ++m->sz[1]; - offset = (old_sz / 8) % 64; - while(len > 0){ - size_t l = min(len, 64 - offset); - memcpy(m->save + offset, p, l); - offset += l; - p += l; - len -= l; - if(offset == 64){ + m->sz[0] += len * 8; + if (m->sz[0] < old_sz) + ++m->sz[1]; + offset = (old_sz / 8) % 64; + while (len > 0) { + size_t l = min(len, 64 - offset); + memcpy(m->save + offset, p, l); + offset += l; + p += l; + len -= l; + if (offset == 64) { #if defined(WORDS_BIGENDIAN) - int i; - afs_uint32 current[16]; - struct x32 *u = (struct x32*)m->save; - for(i = 0; i < 8; i++){ - current[2*i+0] = swap_afs_uint32(u[i].a); - current[2*i+1] = swap_afs_uint32(u[i].b); - } - calc(m, current); + int i; + afs_uint32 current[16]; + struct x32 *u = (struct x32 *)m->save; + for (i = 0; i < 8; i++) { + current[2 * i + 0] = swap_afs_uint32(u[i].a); + current[2 * i + 1] = swap_afs_uint32(u[i].b); + } + calc(m, current); #else - calc(m, (afs_uint32*)m->save); + calc(m, (afs_uint32 *) m->save); #endif - offset = 0; + offset = 0; + } } - } } void -MD5_Final (void *res, struct md5 *m) +MD5_Final(void *res, struct md5 *m) { - static unsigned char zeros[72]; - unsigned offset = (m->sz[0] / 8) % 64; - unsigned int dstart = (120 - offset - 1) % 64 + 1; + static unsigned char zeros[72]; + unsigned offset = (m->sz[0] / 8) % 64; + unsigned int dstart = (120 - offset - 1) % 64 + 1; - *zeros = 0x80; - memset (zeros + 1, 0, sizeof(zeros) - 1); - zeros[dstart+0] = (m->sz[0] >> 0) & 0xff; - zeros[dstart+1] = (m->sz[0] >> 8) & 0xff; - zeros[dstart+2] = (m->sz[0] >> 16) & 0xff; - zeros[dstart+3] = (m->sz[0] >> 24) & 0xff; - zeros[dstart+4] = (m->sz[1] >> 0) & 0xff; - zeros[dstart+5] = (m->sz[1] >> 8) & 0xff; - zeros[dstart+6] = (m->sz[1] >> 16) & 0xff; - zeros[dstart+7] = (m->sz[1] >> 24) & 0xff; - MD5_Update (m, zeros, dstart + 8); - { - int i; - unsigned char *r = (unsigned char *)res; + *zeros = 0x80; + memset(zeros + 1, 0, sizeof(zeros) - 1); + zeros[dstart + 0] = (m->sz[0] >> 0) & 0xff; + zeros[dstart + 1] = (m->sz[0] >> 8) & 0xff; + zeros[dstart + 2] = (m->sz[0] >> 16) & 0xff; + zeros[dstart + 3] = (m->sz[0] >> 24) & 0xff; + zeros[dstart + 4] = (m->sz[1] >> 0) & 0xff; + zeros[dstart + 5] = (m->sz[1] >> 8) & 0xff; + zeros[dstart + 6] = (m->sz[1] >> 16) & 0xff; + zeros[dstart + 7] = (m->sz[1] >> 24) & 0xff; + MD5_Update(m, zeros, dstart + 8); + { + int i; + unsigned char *r = (unsigned char *)res; - for (i = 0; i < 4; ++i) { - r[4*i] = m->counter[i] & 0xFF; - r[4*i+1] = (m->counter[i] >> 8) & 0xFF; - r[4*i+2] = (m->counter[i] >> 16) & 0xFF; - r[4*i+3] = (m->counter[i] >> 24) & 0xFF; - } - } + for (i = 0; i < 4; ++i) { + r[4 * i] = m->counter[i] & 0xFF; + r[4 * i + 1] = (m->counter[i] >> 8) & 0xFF; + r[4 * i + 2] = (m->counter[i] >> 16) & 0xFF; + r[4 * i + 3] = (m->counter[i] >> 24) & 0xFF; + } + } #if 0 - { - int i; - afs_uint32 *r = (afs_uint32 *)res; + { + int i; + afs_uint32 *r = (afs_uint32 *) res; - for (i = 0; i < 4; ++i) - r[i] = swap_afs_uint32 (m->counter[i]); - } + for (i = 0; i < 4; ++i) + r[i] = swap_afs_uint32(m->counter[i]); + } #endif } diff --git a/src/rxkad/md5.h b/src/rxkad/md5.h index 359714b094..5fed30a3cc 100644 --- a/src/rxkad/md5.h +++ b/src/rxkad/md5.h @@ -42,13 +42,13 @@ #endif struct md5 { - unsigned int sz[2]; - afs_uint32 counter[4]; - unsigned char save[64]; + unsigned int sz[2]; + afs_uint32 counter[4]; + unsigned char save[64]; }; typedef struct md5 MD5_CTX; -void MD5_Init (struct md5 *m); -void MD5_Update (struct md5 *m, const void *p, size_t len); -void MD5_Final (void *res, struct md5 *m); /* afs_uint32 res[4] */ +void MD5_Init(struct md5 *m); +void MD5_Update(struct md5 *m, const void *p, size_t len); +void MD5_Final(void *res, struct md5 *m); /* afs_uint32 res[4] */ diff --git a/src/rxkad/rxkad.p.h b/src/rxkad/rxkad.p.h index 8e7204318f..5887d23cf4 100644 --- a/src/rxkad/rxkad.p.h +++ b/src/rxkad/rxkad.p.h @@ -16,15 +16,15 @@ /* no ticket good for longer than 30 days */ #define MAXKTCTICKETLIFETIME (30*24*3600) #define MINKTCTICKETLEN 32 -#define MAXKTCTICKETLEN 12000 /* was 344 */ +#define MAXKTCTICKETLEN 12000 /* was 344 */ #define MAXKTCNAMELEN 64 /* name & inst should be 256 */ #define MAXKTCREALMLEN 64 /* should be 256 */ #define KTC_TIME_UNCERTAINTY (15*60) /* max skew bet. machines' clocks */ #define MAXRANDOMNAMELEN 16 /* length of random generated - * usernames used by afslog for high - * security must be < MAXKTCNAMELEN && < MAXSMBNAMELEN */ -#define MAXSMBNAMELEN 256 /* max length of an SMB name */ + * usernames used by afslog for high + * security must be < MAXKTCNAMELEN && < MAXSMBNAMELEN */ +#define MAXSMBNAMELEN 256 /* max length of an SMB name */ #define LOGON_OPTION_INTEGRATED 1 #define LOGON_OPTION_HIGHSECURITY 2 @@ -124,8 +124,8 @@ RXKAD_STATS_DECLSPEC struct rxkad_stats rxkad_stats; #include #include extern pthread_mutex_t rxkad_stats_mutex; -#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0); -#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0); +#define LOCK_RXKAD_STATS assert(pthread_mutex_lock(&rxkad_stats_mutex)==0) +#define UNLOCK_RXKAD_STATS assert(pthread_mutex_unlock(&rxkad_stats_mutex)==0) #else #define LOCK_RXKAD_STATS #define UNLOCK_RXKAD_STATS diff --git a/src/rxkad/rxkad_client.c b/src/rxkad/rxkad_client.c index 4d351987b8..d30cd73906 100644 --- a/src/rxkad/rxkad_client.c +++ b/src/rxkad/rxkad_client.c @@ -101,8 +101,8 @@ static struct rx_securityOps rxkad_client_ops = { */ #include pthread_mutex_t rxkad_client_uid_mutex; -#define LOCK_CUID assert(pthread_mutex_lock(&rxkad_client_uid_mutex)==0); -#define UNLOCK_CUID assert(pthread_mutex_unlock(&rxkad_client_uid_mutex)==0); +#define LOCK_CUID assert(pthread_mutex_lock(&rxkad_client_uid_mutex)==0) +#define UNLOCK_CUID assert(pthread_mutex_unlock(&rxkad_client_uid_mutex)==0) #else #define LOCK_CUID #define UNLOCK_CUID @@ -119,7 +119,8 @@ rxkad_AllocCID(struct rx_securityClass *aobj, struct rx_connection *aconn) struct rxkad_cidgen tgen; static afs_int32 counter = 0; /* not used anymore */ - LOCK_CUID if (Cuid[0] == 0) { + LOCK_CUID; + if (Cuid[0] == 0) { afs_uint32 xor[2]; tgen.ipAddr = rxi_getaddr(); /* comes back in net order */ clock_GetTime(&tgen.time); /* changes time1 and time2 */ @@ -154,12 +155,14 @@ rxkad_AllocCID(struct rx_securityClass *aobj, struct rx_connection *aconn) } if (!aconn) { - UNLOCK_CUID return 0; + UNLOCK_CUID; + return 0; } aconn->epoch = Cuid[0]; aconn->cid = Cuid[1]; Cuid[1] += 1 << RX_CIDSHIFT; - UNLOCK_CUID return 0; + UNLOCK_CUID; + return 0; } /* Allocate a new client security object. Called with the encryption level, @@ -204,8 +207,10 @@ rxkad_NewClientSecurityObject(rxkad_level level, } memcpy(tcp->ticket, ticket, ticketLen); - LOCK_RXKAD_STATS rxkad_stats_clientObjects++; - UNLOCK_RXKAD_STATS return tsc; + LOCK_RXKAD_STATS; + rxkad_stats_clientObjects++; + UNLOCK_RXKAD_STATS; + return tsc; } /* client: respond to a challenge packet */ @@ -250,8 +255,10 @@ rxkad_GetResponse(struct rx_securityClass *aobj, struct rx_connection *aconn, if (level > tcp->level) return RXKADLEVELFAIL; - LOCK_RXKAD_STATS rxkad_stats.challenges[rxkad_LevelIndex(tcp->level)]++; - UNLOCK_RXKAD_STATS if (v2) { + LOCK_RXKAD_STATS; + rxkad_stats.challenges[rxkad_LevelIndex(tcp->level)]++; + UNLOCK_RXKAD_STATS; + if (v2) { int i; afs_uint32 xor[2]; memset((void *)&r_v2, 0, sizeof(r_v2)); @@ -307,6 +314,8 @@ rxkad_GetResponse(struct rx_securityClass *aobj, struct rx_connection *aconn, void rxkad_ResetState(void) { - LOCK_CUID Cuid[0] = 0; + LOCK_CUID; + Cuid[0] = 0; rxkad_EpochWasSet = 0; -UNLOCK_CUID} + UNLOCK_CUID; +} diff --git a/src/rxkad/rxkad_common.c b/src/rxkad/rxkad_common.c index 640d26691f..e062ff4e39 100644 --- a/src/rxkad/rxkad_common.c +++ b/src/rxkad/rxkad_common.c @@ -83,7 +83,7 @@ RCSID #endif /* variable initialization for the benefit of darwin compiler; if it causes problems elsewhere, conditionalize for darwin or fc_test compile breaks */ -struct rxkad_stats rxkad_stats = {0}; +struct rxkad_stats rxkad_stats = { 0 }; /* static prototypes */ static afs_int32 ComputeSum(struct rx_packet *apacket, @@ -207,8 +207,10 @@ FreeObject(struct rx_securityClass *aobj) } else { return RXKADINCONSISTENCY; } /* unknown type */ - LOCK_RXKAD_STATS rxkad_stats.destroyObject++; - UNLOCK_RXKAD_STATS return 0; + LOCK_RXKAD_STATS; + rxkad_stats.destroyObject++; + UNLOCK_RXKAD_STATS; + return 0; } /* rxkad_Close - called by rx with the security class object as a parameter @@ -249,9 +251,10 @@ rxkad_NewConnection(struct rx_securityClass *aobj, rxkad_SetLevel(aconn, tcp->level); /* set header and trailer sizes */ rxkad_AllocCID(aobj, aconn); /* CHANGES cid AND epoch!!!! */ rxkad_DeriveXORInfo(aconn, tcp->keysched, tcp->ivec, tccp->preSeq); - LOCK_RXKAD_STATS rxkad_stats. - connections[rxkad_LevelIndex(tcp->level)]++; - UNLOCK_RXKAD_STATS} + LOCK_RXKAD_STATS; + rxkad_stats.connections[rxkad_LevelIndex(tcp->level)]++; + UNLOCK_RXKAD_STATS; + } aobj->refCount++; /* attached connection */ return 0; @@ -269,17 +272,21 @@ rxkad_DestroyConnection(struct rx_securityClass *aobj, sconn = (struct rxkad_sconn *)aconn->securityData; if (sconn) { aconn->securityData = 0; - LOCK_RXKAD_STATS if (sconn->authenticated) - rxkad_stats.destroyConn[rxkad_LevelIndex(sconn->level)]++; + LOCK_RXKAD_STATS; + if (sconn->authenticated) + rxkad_stats.destroyConn[rxkad_LevelIndex(sconn->level)]++; else rxkad_stats.destroyUnauth++; - UNLOCK_RXKAD_STATS rock = sconn->rock; + UNLOCK_RXKAD_STATS; + rock = sconn->rock; if (rock) rxi_Free(rock, sizeof(struct rxkad_serverinfo)); rxi_Free(sconn, sizeof(struct rxkad_sconn)); } else { - LOCK_RXKAD_STATS rxkad_stats.destroyUnused++; - UNLOCK_RXKAD_STATS} + LOCK_RXKAD_STATS; + rxkad_stats.destroyUnused++; + UNLOCK_RXKAD_STATS; + } } else { /* client */ struct rxkad_cconn *cconn; struct rxkad_cprivate *tcp; @@ -291,8 +298,10 @@ rxkad_DestroyConnection(struct rx_securityClass *aobj, aconn->securityData = 0; rxi_Free(cconn, sizeof(struct rxkad_cconn)); } - LOCK_RXKAD_STATS rxkad_stats.destroyClient++; - UNLOCK_RXKAD_STATS} + LOCK_RXKAD_STATS; + rxkad_stats.destroyClient++; + UNLOCK_RXKAD_STATS; + } aobj->refCount--; /* decrement connection counter */ if (aobj->refCount <= 0) { afs_int32 code; @@ -332,15 +341,18 @@ rxkad_CheckPacket(struct rx_securityClass *aobj, struct rx_call *acall, if (sconn && sconn->authenticated && (osi_Time() < sconn->expirationTime)) { level = sconn->level; - LOCK_RXKAD_STATS rxkad_stats. - checkPackets[rxkad_StatIndex(rxkad_server, level)]++; - UNLOCK_RXKAD_STATS sconn->stats.packetsReceived++; + LOCK_RXKAD_STATS; + rxkad_stats.checkPackets[rxkad_StatIndex(rxkad_server, level)]++; + UNLOCK_RXKAD_STATS; + sconn->stats.packetsReceived++; sconn->stats.bytesReceived += len; schedule = (fc_KeySchedule *) sconn->keysched; ivec = (fc_InitializationVector *) sconn->ivec; } else { - LOCK_RXKAD_STATS rxkad_stats.expired++; - UNLOCK_RXKAD_STATS return RXKADEXPIRED; + LOCK_RXKAD_STATS; + rxkad_stats.expired++; + UNLOCK_RXKAD_STATS; + return RXKADEXPIRED; } preSeq = sconn->preSeq; } else { /* client connection */ @@ -354,9 +366,10 @@ rxkad_CheckPacket(struct rx_securityClass *aobj, struct rx_call *acall, if (!(tcp->type & rxkad_client)) return RXKADINCONSISTENCY; level = tcp->level; - LOCK_RXKAD_STATS rxkad_stats. - checkPackets[rxkad_StatIndex(rxkad_client, level)]++; - UNLOCK_RXKAD_STATS cconn->stats.packetsReceived++; + LOCK_RXKAD_STATS; + rxkad_stats.checkPackets[rxkad_StatIndex(rxkad_client, level)]++; + UNLOCK_RXKAD_STATS; + cconn->stats.packetsReceived++; cconn->stats.bytesReceived += len; preSeq = cconn->preSeq; schedule = (fc_KeySchedule *) tcp->keysched; @@ -421,15 +434,19 @@ rxkad_PreparePacket(struct rx_securityClass *aobj, struct rx_call *acall, if (sconn && sconn->authenticated && (osi_Time() < sconn->expirationTime)) { level = sconn->level; - LOCK_RXKAD_STATS rxkad_stats. + LOCK_RXKAD_STATS; + rxkad_stats. preparePackets[rxkad_StatIndex(rxkad_server, level)]++; - UNLOCK_RXKAD_STATS sconn->stats.packetsSent++; + UNLOCK_RXKAD_STATS; + sconn->stats.packetsSent++; sconn->stats.bytesSent += len; schedule = (fc_KeySchedule *) sconn->keysched; ivec = (fc_InitializationVector *) sconn->ivec; } else { - LOCK_RXKAD_STATS rxkad_stats.expired++; /* this is a pretty unlikely path... */ - UNLOCK_RXKAD_STATS return RXKADEXPIRED; + LOCK_RXKAD_STATS; + rxkad_stats.expired++; /* this is a pretty unlikely path... */ + UNLOCK_RXKAD_STATS; + return RXKADEXPIRED; } preSeq = sconn->preSeq; } else { /* client connection */ @@ -440,9 +457,10 @@ rxkad_PreparePacket(struct rx_securityClass *aobj, struct rx_call *acall, if (!(tcp->type & rxkad_client)) return RXKADINCONSISTENCY; level = tcp->level; - LOCK_RXKAD_STATS rxkad_stats. - preparePackets[rxkad_StatIndex(rxkad_client, level)]++; - UNLOCK_RXKAD_STATS cconn->stats.packetsSent++; + LOCK_RXKAD_STATS; + rxkad_stats.preparePackets[rxkad_StatIndex(rxkad_client, level)]++; + UNLOCK_RXKAD_STATS; + cconn->stats.packetsSent++; cconn->stats.bytesSent += len; preSeq = cconn->preSeq; schedule = (fc_KeySchedule *) tcp->keysched; @@ -530,23 +548,23 @@ rxkad_GetStats(struct rx_securityClass *aobj, struct rx_connection *aconn, rxkad_level rxkad_StringToLevel(char *name) { - if (strcmp(name, "clear") == 0) - return rxkad_clear; - if (strcmp(name, "auth") == 0) - return rxkad_auth; - if (strcmp(name, "crypt") == 0) - return rxkad_crypt; - return -1; + if (strcmp(name, "clear") == 0) + return rxkad_clear; + if (strcmp(name, "auth") == 0) + return rxkad_auth; + if (strcmp(name, "crypt") == 0) + return rxkad_crypt; + return -1; } char * rxkad_LevelToString(rxkad_level level) { - if (level == rxkad_clear) - return "clear"; - if (level == rxkad_auth) - return "auth"; - if (level == rxkad_crypt) - return "crypt"; - return "unknown"; + if (level == rxkad_clear) + return "clear"; + if (level == rxkad_auth) + return "auth"; + if (level == rxkad_crypt) + return "crypt"; + return "unknown"; } diff --git a/src/rxkad/rxkad_prototypes.h b/src/rxkad/rxkad_prototypes.h index c689ea2d8c..adffe54faa 100644 --- a/src/rxkad/rxkad_prototypes.h +++ b/src/rxkad/rxkad_prototypes.h @@ -87,19 +87,25 @@ extern struct rx_securityClass *rxkad_NewServerSecurityObject(rxkad_level level, char *get_key_rock, int (*get_key) - (char - *get_key_rock, - int kvno, - struct - ktc_encryptionKey - * serverKey), + + + + (char + *get_key_rock, + int kvno, + struct + ktc_encryptionKey + * serverKey), int (*user_ok) - (char *name, - char - *instance, - char *cell, - afs_int32 - kvno)); + + + + (char *name, + char + *instance, + char *cell, + afs_int32 + kvno)); extern int rxkad_CheckAuthentication(struct rx_securityClass *aobj, struct rx_connection *aconn); extern int rxkad_CreateChallenge(struct rx_securityClass *aobj, diff --git a/src/rxkad/rxkad_server.c b/src/rxkad/rxkad_server.c index 6a4c32b569..bb14d1c0cd 100644 --- a/src/rxkad/rxkad_server.c +++ b/src/rxkad/rxkad_server.c @@ -59,9 +59,9 @@ static struct rx_securityOps rxkad_server_ops = { rxkad_CheckPacket, /* check data packet */ rxkad_DestroyConnection, rxkad_GetStats, - 0, /* spare 1 */ - 0, /* spare 2 */ - 0, /* spare 3 */ + 0, /* spare 1 */ + 0, /* spare 2 */ + 0, /* spare 3 */ }; extern afs_uint32 rx_MyMaxSendSize; @@ -79,8 +79,8 @@ static fc_KeySchedule random_int32_schedule; #include pthread_mutex_t rxkad_random_mutex; -#define LOCK_RM assert(pthread_mutex_lock(&rxkad_random_mutex)==0); -#define UNLOCK_RM assert(pthread_mutex_unlock(&rxkad_random_mutex)==0); +#define LOCK_RM assert(pthread_mutex_lock(&rxkad_random_mutex)==0) +#define UNLOCK_RM assert(pthread_mutex_unlock(&rxkad_random_mutex)==0) #else #define LOCK_RM #define UNLOCK_RM @@ -92,8 +92,10 @@ init_random_int32(void) struct timeval key; gettimeofday(&key, NULL); - LOCK_RM fc_keysched(&key, random_int32_schedule); -UNLOCK_RM} + LOCK_RM; + fc_keysched(&key, random_int32_schedule); + UNLOCK_RM; +} static afs_int32 get_random_int32(void) @@ -101,9 +103,11 @@ get_random_int32(void) static struct timeval seed; afs_int32 rc; - LOCK_RM fc_ecb_encrypt(&seed, &seed, random_int32_schedule, ENCRYPT); + LOCK_RM; + fc_ecb_encrypt(&seed, &seed, random_int32_schedule, ENCRYPT); rc = seed.tv_sec; - UNLOCK_RM return rc; + UNLOCK_RM; + return rc; } /* Called with four parameters. The first is the level of encryption, as @@ -156,8 +160,10 @@ rxkad_NewServerSecurityObject(rxkad_level level, char *get_key_rock, tsp->user_ok = user_ok; /* to inform server of client id. */ init_random_int32(); - LOCK_RXKAD_STATS rxkad_stats_serverObjects++; - UNLOCK_RXKAD_STATS return tsc; + LOCK_RXKAD_STATS; + rxkad_stats_serverObjects++; + UNLOCK_RXKAD_STATS; + return tsc; } /* server: called to tell if a connection authenticated properly */ @@ -232,8 +238,10 @@ rxkad_GetChallenge(struct rx_securityClass *aobj, struct rx_connection *aconn, rx_packetwrite(apacket, 0, challengeSize, challenge); rx_SetDataSize(apacket, challengeSize); sconn->tried = 1; - LOCK_RXKAD_STATS rxkad_stats.challengesSent++; - UNLOCK_RXKAD_STATS return 0; + LOCK_RXKAD_STATS; + rxkad_stats.challengesSent++; + UNLOCK_RXKAD_STATS; + return 0; } /* server: process a response to a challenge packet */ @@ -397,11 +405,11 @@ rxkad_CheckResponse(struct rx_securityClass *aobj, return RXKADLEVELFAIL; sconn->level = level; rxkad_SetLevel(aconn, sconn->level); - LOCK_RXKAD_STATS rxkad_stats.responses[rxkad_LevelIndex(sconn->level)]++; - UNLOCK_RXKAD_STATS - /* now compute endpoint-specific info used for computing 16 bit checksum */ - rxkad_DeriveXORInfo(aconn, sconn->keysched, sconn->ivec, - sconn->preSeq); + LOCK_RXKAD_STATS; + rxkad_stats.responses[rxkad_LevelIndex(sconn->level)]++; + UNLOCK_RXKAD_STATS; + /* now compute endpoint-specific info used for computing 16 bit checksum */ + rxkad_DeriveXORInfo(aconn, sconn->keysched, sconn->ivec, sconn->preSeq); /* otherwise things are ok */ sconn->expirationTime = end; diff --git a/src/rxkad/ticket5.c b/src/rxkad/ticket5.c index 013a107be5..cd5b7d71ae 100644 --- a/src/rxkad/ticket5.c +++ b/src/rxkad/ticket5.c @@ -387,36 +387,36 @@ tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len, static int verify_checksum_md4(void *data, size_t len, - void *cksum, size_t cksumsz, - struct ktc_encryptionKey *key) + void *cksum, size_t cksumsz, + struct ktc_encryptionKey *key) { - MD4_CTX md4; - unsigned char tmp[16]; + MD4_CTX md4; + unsigned char tmp[16]; - MD4_Init(&md4); - MD4_Update(&md4, data, len); - MD4_Final (tmp, &md4); + MD4_Init(&md4); + MD4_Update(&md4, data, len); + MD4_Final(tmp, &md4); - if (memcmp(tmp, cksum, cksumsz) != 0) - return 1; - return 0; + if (memcmp(tmp, cksum, cksumsz) != 0) + return 1; + return 0; } static int verify_checksum_md5(void *data, size_t len, - void *cksum, size_t cksumsz, - struct ktc_encryptionKey *key) + void *cksum, size_t cksumsz, + struct ktc_encryptionKey *key) { - MD5_CTX md5; - unsigned char tmp[16]; + MD5_CTX md5; + unsigned char tmp[16]; - MD5_Init(&md5); - MD5_Update(&md5, data, len); - MD5_Final (tmp, &md5); + MD5_Init(&md5); + MD5_Update(&md5, data, len); + MD5_Final(tmp, &md5); - if (memcmp(tmp, cksum, cksumsz) != 0) - return 1; - return 0; + if (memcmp(tmp, cksum, cksumsz) != 0) + return 1; + return 0; } static int @@ -449,7 +449,7 @@ krb5_des_decrypt(struct ktc_encryptionKey *key, int etype, void *in, des_key_schedule s; char cksum[24]; size_t cksumsz; - int ret = 1; /* failure */ + int ret = 1; /* failure */ cksum_func = NULL; diff --git a/src/ubik/beacon.c b/src/ubik/beacon.c index 9d836d198a..645283b3e5 100644 --- a/src/ubik/beacon.c +++ b/src/ubik/beacon.c @@ -494,8 +494,8 @@ verifyInterfaceAddress(ame, info, aservers) } #ifdef AFS_NT40_ENV - /* get all my interface addresses in net byte order */ - count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR); + /* get all my interface addresses in net byte order */ + count = rx_getAllAddr(myAddr, UBIK_MAX_INTERFACE_ADDR); #else if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || AFSDIR_SERVER_NETINFO_FILEPATH) { /* diff --git a/src/ubik/remote.c b/src/ubik/remote.c index 54495cca60..733d72d2f1 100644 --- a/src/ubik/remote.c +++ b/src/ubik/remote.c @@ -537,7 +537,7 @@ SDISK_SendFile(rxcall, file, length, avers) (*dbase->truncate) (dbase, file, 0); /* truncate first */ tversion.epoch = 0; /* start off by labelling in-transit db as invalid */ tversion.counter = 0; - (*dbase->setlabel) (dbase, file, &tversion);/* setlabel does sync */ + (*dbase->setlabel) (dbase, file, &tversion); /* setlabel does sync */ memcpy(&ubik_dbase->version, &tversion, sizeof(struct ubik_version)); while (length > 0) { tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length); diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h index 5a1d20a979..b72a822327 100644 --- a/src/ubik/ubik.p.h +++ b/src/ubik/ubik.p.h @@ -87,8 +87,8 @@ struct ubik_client { }; #ifdef AFS_PTHREAD_ENV -#define LOCK_UBIK_CLIENT(client) assert(pthread_mutex_lock(&client->cm)==0); -#define UNLOCK_UBIK_CLIENT(client) assert(pthread_mutex_unlock(&client->cm)==0); +#define LOCK_UBIK_CLIENT(client) assert(pthread_mutex_lock(&client->cm)==0) +#define UNLOCK_UBIK_CLIENT(client) assert(pthread_mutex_unlock(&client->cm)==0) #else #define LOCK_UBIK_CLIENT(client) #define UNLOCK_UBIK_CLIENT(client) @@ -355,7 +355,8 @@ extern int ubik_ClientInit(register struct rx_connection **serverconns, extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient); /* ubik.c */ -extern int ubik_BeginTrans(register struct ubik_dbase *dbase, afs_int32 transMode, struct ubik_trans **transPtr); +extern int ubik_BeginTrans(register struct ubik_dbase *dbase, + afs_int32 transMode, struct ubik_trans **transPtr); extern int ubik_EndTrans(register struct ubik_trans *transPtr); #endif /* UBIK_H */ diff --git a/src/ubik/ubikclient.c b/src/ubik/ubikclient.c index ed81f7f67e..128294f9df 100644 --- a/src/ubik/ubikclient.c +++ b/src/ubik/ubikclient.c @@ -72,14 +72,17 @@ ubik_ParseClientList(int argc, char **argv, afs_int32 * aothers) if (*tp == '-') break; /* done */ /* otherwise this is a new host name */ - LOCK_GLOBAL_MUTEX th = gethostbyname(tp); + LOCK_GLOBAL_MUTEX; + th = gethostbyname(tp); if (!th) { - UNLOCK_GLOBAL_MUTEX return UBADHOST; + UNLOCK_GLOBAL_MUTEX; + return UBADHOST; } memmove((void *)&temp, (const void *)th->h_addr, sizeof(afs_int32)); - UNLOCK_GLOBAL_MUTEX if (counter++ >= MAXSERVERS) - return UNHOSTS; + UNLOCK_GLOBAL_MUTEX; + if (counter++ >= MAXSERVERS) + return UNHOSTS; *aothers++ = temp; } else { /* haven't seen a -server yet */ @@ -205,11 +208,11 @@ ubik_ClientInit(register struct rx_connection **serverconns, initialize_U_error_table(); if (*aclient) { /* the application is doing a re-initialization */ - LOCK_UBIK_CLIENT((*aclient)) - /* this is an important defensive check */ - if (!((*aclient)->initializationState)) { - UNLOCK_UBIK_CLIENT((*aclient)) - return UREINITIALIZE; + LOCK_UBIK_CLIENT((*aclient)); + /* this is an important defensive check */ + if (!((*aclient)->initializationState)) { + UNLOCK_UBIK_CLIENT((*aclient)); + return UREINITIALIZE; } /* release all existing connections */ @@ -223,9 +226,9 @@ ubik_ClientInit(register struct rx_connection **serverconns, rx_DestroyConnection(rxConn); #endif } - UNLOCK_UBIK_CLIENT((*aclient)) + UNLOCK_UBIK_CLIENT((*aclient)); #ifdef AFS_PTHREAD_ENV - if (pthread_mutex_destroy(&((*aclient)->cm))) + if (pthread_mutex_destroy(&((*aclient)->cm))) return UMUTEXDESTROY; #endif } else { @@ -335,8 +338,8 @@ pthread_once_t ubik_client_once = PTHREAD_ONCE_INIT; pthread_mutex_t ubik_client_mutex; #define LOCK_UCLNT_CACHE \ assert(pthread_once(&ubik_client_once, ubik_client_init_mutex) == 0 && \ - pthread_mutex_lock(&ubik_client_mutex)==0); -#define UNLOCK_UCLNT_CACHE assert(pthread_mutex_unlock(&ubik_client_mutex)==0); + pthread_mutex_lock(&ubik_client_mutex)==0) +#define UNLOCK_UCLNT_CACHE assert(pthread_mutex_unlock(&ubik_client_mutex)==0) void ubik_client_init_mutex() @@ -397,18 +400,19 @@ ubik_Call(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, rcode = UNOSERVERS; chaseCount = inlist = needsync = 0; - LOCK_UCLNT_CACHE for (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) { + LOCK_UCLNT_CACHE; + for (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) { if (calls_needsync[j] == (int *)aproc) { inlist = needsync = 1; break; } } - UNLOCK_UCLNT_CACHE - /* - * First pass, we try all servers that are up. - * Second pass, we try all servers. - */ - for (pass = 0; pass < 2; pass++) { /*p */ + UNLOCK_UCLNT_CACHE; + /* + * First pass, we try all servers that are up. + * Second pass, we try all servers. + */ + for (pass = 0; pass < 2; pass++) { /*p */ /* For each entry in our servers list */ for (count = 0;; count++) { /*s */ @@ -494,10 +498,11 @@ ubik_Call(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, done: if (needsync) { if (!inlist) { /* Remember proc call that needs sync site */ - LOCK_UCLNT_CACHE calls_needsync[synccount % SYNCCOUNT] = - (int *)aproc; + LOCK_UCLNT_CACHE; + calls_needsync[synccount % SYNCCOUNT] = (int *)aproc; synccount++; - UNLOCK_UCLNT_CACHE inlist = 1; + UNLOCK_UCLNT_CACHE; + inlist = 1; } if (!rcode) { /* Remember the sync site - cmd successful */ rxp = rx_PeerOf(aclient->conns[count]); @@ -605,7 +610,7 @@ CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7, p8, p9, short origLevel; if (needlock) { - LOCK_UBIK_CLIENT(aclient) + LOCK_UBIK_CLIENT(aclient); } origLevel = aclient->initializationState; @@ -616,7 +621,7 @@ CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7, p8, p9, tc = aclient->conns[*apos]; if (!tc) { if (needlock) { - UNLOCK_UBIK_CLIENT(aclient) + UNLOCK_UBIK_CLIENT(aclient); } return UNOSERVERS; } @@ -634,7 +639,7 @@ CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7, p8, p9, } if (*apos >= MAXSERVERS) { if (needlock) { - UNLOCK_UBIK_CLIENT(aclient) + UNLOCK_UBIK_CLIENT(aclient); } return UNOSERVERS; } @@ -644,7 +649,7 @@ CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7, p8, p9, p14, p15, p16); if (aclient->initializationState != origLevel) { if (needlock) { - UNLOCK_UBIK_CLIENT(aclient) + UNLOCK_UBIK_CLIENT(aclient); } return code; /* somebody did a ubik_ClientInit */ } @@ -659,7 +664,7 @@ CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7, p8, p9, (*apos)++; if (needlock) { - UNLOCK_UBIK_CLIENT(aclient) + UNLOCK_UBIK_CLIENT(aclient); } return code; } @@ -698,7 +703,7 @@ ubik_Call_New(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, int stepBack; short origLevel; - LOCK_UBIK_CLIENT(aclient) + LOCK_UBIK_CLIENT(aclient); restart: rcode = UNOSERVERS; origLevel = aclient->initializationState; @@ -732,13 +737,13 @@ ubik_Call_New(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, } } } else if ((code >= 0) && (code != UNOQUORUM)) { - UNLOCK_UBIK_CLIENT(aclient) - return code; /* success or global error condition */ + UNLOCK_UBIK_CLIENT(aclient); + return code; /* success or global error condition */ } } } - UNLOCK_UBIK_CLIENT(aclient) - return rcode; + UNLOCK_UBIK_CLIENT(aclient); + return rcode; } /* diff --git a/src/util/pthread_glock.h b/src/util/pthread_glock.h index 24e58913a7..da6aefd041 100644 --- a/src/util/pthread_glock.h +++ b/src/util/pthread_glock.h @@ -35,10 +35,10 @@ extern int pthread_recursive_mutex_lock(pthread_recursive_mutex_p); extern int pthread_recursive_mutex_unlock(pthread_recursive_mutex_p); #define LOCK_GLOBAL_MUTEX \ - assert(pthread_recursive_mutex_lock(&grmutex)==0); + assert(pthread_recursive_mutex_lock(&grmutex)==0) #define UNLOCK_GLOBAL_MUTEX \ - assert(pthread_recursive_mutex_unlock(&grmutex)==0); + assert(pthread_recursive_mutex_unlock(&grmutex)==0) #else