From: VMware, Inc <> Date: Mon, 26 Jul 2010 19:09:10 +0000 (-0700) Subject: lib/lock: improve a comment and review comment X-Git-Tag: 2010.07.25-280253~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c38dccd22168bb66bdf7667d5ffeda489bf5b868;p=thirdparty%2Fopen-vm-tools.git lib/lock: improve a comment and review comment Improve a review comment. One review comment from the ulRec.c change can be propogated to the other objects. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/lock/ulExcl.c b/open-vm-tools/lib/lock/ulExcl.c index 7c76fee32..99d147512 100644 --- a/open-vm-tools/lib/lock/ulExcl.c +++ b/open-vm-tools/lib/lock/ulExcl.c @@ -201,17 +201,15 @@ MXUser_CreateExclLock(const char *userName, // IN: lock->header.identifier = MXUserAllocID(); stats = Util_SafeCalloc(1, sizeof(*stats)); + + MXUserAcquisitionStatsSetUp(&stats->acquisitionStats); + MXUserBasicStatsSetUp(&stats->heldStats, MXUSER_STAT_CLASS_HELD); #else stats = NULL; #endif Atomic_WritePtr(&lock->statsMem, stats); - if (stats) { - MXUserAcquisitionStatsSetUp(&stats->acquisitionStats); - MXUserBasicStatsSetUp(&stats->heldStats, MXUSER_STAT_CLASS_HELD); - } - MXUserAddToList(&lock->header); return lock; diff --git a/open-vm-tools/lib/lock/ulRW.c b/open-vm-tools/lib/lock/ulRW.c index 94a481b2e..c9f5b7f02 100644 --- a/open-vm-tools/lib/lock/ulRW.c +++ b/open-vm-tools/lib/lock/ulRW.c @@ -460,16 +460,14 @@ MXUser_CreateRWLock(const char *userName, // IN: lock->header.statsFunc = MXUserStatsActionRW; lock->header.identifier = MXUserAllocID(); - stats = Util_SafeCalloc(1, sizeof(*stats)); + stats = Util_SafeCalloc(1, sizeof(*stats)); + + MXUserAcquisitionStatsSetUp(&stats->acquisitionStats); + MXUserBasicStatsSetUp(&stats->heldStats, MXUSER_STAT_CLASS_HELD); #else - stats = NULL; + stats = NULL; #endif - if (stats) { - MXUserAcquisitionStatsSetUp(&stats->acquisitionStats); - MXUserBasicStatsSetUp(&stats->heldStats, MXUSER_STAT_CLASS_HELD); - } - MXUserAddToList(&lock->header); } else { free(properName); diff --git a/open-vm-tools/lib/lock/ulRec.c b/open-vm-tools/lib/lock/ulRec.c index 87c2be922..2c25215f3 100644 --- a/open-vm-tools/lib/lock/ulRec.c +++ b/open-vm-tools/lib/lock/ulRec.c @@ -173,7 +173,8 @@ MXUserDumpRecLock(MXUserHeader *header) // IN: * MXUser_CreateRecLockEx -- * * Create a recursive lock specifying if the lock must always be - * silent - never logging any messages. + * silent - never logging any messages. Silent locks will never + * produce any statistics, amongst the other aspect of "silent". * * Only the owner (thread) of a recursive lock may recurse on it. * diff --git a/open-vm-tools/lib/lock/ulSema.c b/open-vm-tools/lib/lock/ulSema.c index 493cfb678..075e0d924 100644 --- a/open-vm-tools/lib/lock/ulSema.c +++ b/open-vm-tools/lib/lock/ulSema.c @@ -524,16 +524,14 @@ MXUser_CreateSemaphore(const char *userName, // IN: sema->header.identifier = MXUserAllocID(); stats = Util_SafeCalloc(1, sizeof(*stats)); + + MXUserAcquisitionStatsSetUp(&stats->acquisitionStats); #else stats = NULL; #endif Atomic_WritePtr(&sema->statsMem, stats); - if (stats) { - MXUserAcquisitionStatsSetUp(&stats->acquisitionStats); - } - MXUserAddToList(&sema->header); } else { free(properName); diff --git a/open-vm-tools/lib/lock/ulStats.c b/open-vm-tools/lib/lock/ulStats.c index 0f62194f4..2f3d3d8ff 100644 --- a/open-vm-tools/lib/lock/ulStats.c +++ b/open-vm-tools/lib/lock/ulStats.c @@ -868,7 +868,7 @@ MXUser_PerLockData(void) uint32 MXUserAllocID(void) { - static Atomic_uint32 firstFreeID = { 0 }; + static Atomic_uint32 firstFreeID = { 1 }; // must start not zero return Atomic_FetchAndInc(&firstFreeID); }