DARWIN: Convert crfree back into a macro
authorAndrew Deason <adeason@sinenomine.net>
Thu, 19 Dec 2013 20:04:56 +0000 (14:04 -0600)
committerDerrick Brashear <shadow@your-file-system.com>
Sun, 12 Jan 2014 19:52:38 +0000 (11:52 -0800)
Commit 1d8937b860509fcaabb041bc14faf7aa3023f3c9 turned crfree on
DARWIN into an inline function to work around an error flagged by
clang. A side effect of this is that the address passed to
kauth_cred_unref will not be the actual address of the value given to
crfree; we are instead giving kauth_cred_unref the address of our
function argument in order to adhere to the semantics of a function
call.

kauth_cred_unref seems to just take a pointer to the cred pointer in
order to set the value to effectively NULL afterwards, so this is not
a huge deal. However, this does mean that our current implementation
undoes any of the safeguards intended by making kauth_cred_unref work
this way in the first place.

So, revert 1d8937b860509fcaabb041bc14faf7aa3023f3c9 and put the crfree
definition back to the way it was. Fix the caller in
afs_StoreOnLastReference to not cause an error by just assigning the
cred pointer to a temporary value. While it's not ideal that some
callers may need to do this, this is the only place where this is
necessary and it's more of an artifact of the weirdness of storing a
cred pointer in linkData, which probably should be changed anyway.

Change-Id: I50557901203d22a7b19028be551eb40f0c4cd751
Reviewed-on: http://gerrit.openafs.org/10614
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>

src/afs/DARWIN/osi_machdep.h
src/afs/VNOPS/afs_vnop_write.c

index f513020..1750052 100644 (file)
@@ -105,7 +105,7 @@ enum vcexcl { EXCL, NONEXCL };
 #define crref kauth_cred_get_with_ref
 #define crhold kauth_cred_ref
 #ifdef AFS_DARWIN100_ENV
-static inline void crfree(kauth_cred_t X) { kauth_cred_unref(&X); }
+#define crfree(X) kauth_cred_unref(&X)
 #else
 #define crfree kauth_cred_rele
 #endif
index 0f6007b..5ef62aa 100644 (file)
@@ -47,6 +47,8 @@ afs_StoreOnLastReference(struct vcache *avc,
      * flag will already be clear, so we don't have to worry about
      * clearing it twice. */
     if (avc->f.states & CCore) {
+       afs_ucred_t *cred;
+
        avc->f.states &= ~CCore;
 #if defined(AFS_SGI_ENV)
        osi_Assert(avc->opens > 0 && avc->execsOrWriters > 0);
@@ -58,7 +60,8 @@ afs_StoreOnLastReference(struct vcache *avc,
        avc->opens--;
        avc->execsOrWriters--;
        AFS_RELE(AFSTOV(avc));  /* VN_HOLD at set CCore(afs_FakeClose) */
-       crfree((afs_ucred_t *)avc->linkData);   /* "crheld" in afs_FakeClose */
+       cred = (afs_ucred_t *)avc->linkData;    /* "crheld" in afs_FakeClose */
+       crfree(cred);
        avc->linkData = NULL;
     }